mirror of
https://github.com/seigler/graphql-playground
synced 2025-07-27 09:36:09 +00:00
Initial commit
This commit is contained in:
commit
0bd76ac5dc
8 changed files with 1386 additions and 0 deletions
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