mirror of
https://github.com/seigler/graphql-playground
synced 2025-07-26 00:56:09 +00:00
Initial commit
This commit is contained in:
commit
0bd76ac5dc
8 changed files with 1386 additions and 0 deletions
8
.editorconfig
Normal file
8
.editorconfig
Normal file
|
@ -0,0 +1,8 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = false
|
||||
insert_final_newline = false
|
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
node_modules/
|
||||
.vscode/
|
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2020 Joshua Seigler
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
8
README.md
Normal file
8
README.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
Repository for following https://www.youtube.com/watch?v=ed8SzALpx1Q
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
npm install
|
||||
npm start
|
||||
```
|
14
server/app.js
Normal file
14
server/app.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
const express = require('express');
|
||||
const graphqlHTTP = require('express-graphql');
|
||||
|
||||
const schema = require('./schema/schema');
|
||||
|
||||
const app = express();
|
||||
|
||||
app.use('/graphql', graphqlHTTP({
|
||||
schema
|
||||
}));
|
||||
|
||||
app.listen(4000, () => {
|
||||
console.log('Listening on http://localhost:4000');
|
||||
});
|
1272
server/package-lock.json
generated
Normal file
1272
server/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
28
server/package.json
Normal file
28
server/package.json
Normal file
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"name": "graphql-playground",
|
||||
"version": "1.0.0",
|
||||
"description": "Playing with GraphQL to learn it",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "nodemon app",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/seigler/graphql.git"
|
||||
},
|
||||
"author": "Joshua Seigler",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/seigler/graphql/issues"
|
||||
},
|
||||
"homepage": "https://github.com/seigler/graphql#readme",
|
||||
"dependencies": {
|
||||
"express": "^4.17.1",
|
||||
"express-graphql": "^0.9.0",
|
||||
"graphql": "^14.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodemon": "^2.0.2"
|
||||
}
|
||||
}
|
33
server/schema/schema.js
Normal file
33
server/schema/schema.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
const graphql = require('graphql');
|
||||
|
||||
const {
|
||||
GraphQLObjectType,
|
||||
GraphQLString,
|
||||
GraphQLSchema
|
||||
} = graphql;
|
||||
|
||||
const BookType = new GraphQLObjectType({
|
||||
name: 'Book',
|
||||
fields: () => ({
|
||||
id: { type: GraphQLString },
|
||||
name: { type: GraphQLString },
|
||||
genre: { type: GraphQLString }
|
||||
})
|
||||
});
|
||||
|
||||
const RootQuery = new GraphQLObjectType({
|
||||
name: 'RootQueryType',
|
||||
fields: {
|
||||
book: {
|
||||
type: BookType,
|
||||
args: { id: { GraphQLString } },
|
||||
resolve (parent, { id }) {
|
||||
// code to retrieve data from db or other source
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = new GraphQLSchema({
|
||||
query: RootQuery
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue