diff --git a/server/schema/schema.js b/server/schema/schema.js index 1b4134f..cae4a48 100644 --- a/server/schema/schema.js +++ b/server/schema/schema.js @@ -1,4 +1,5 @@ const graphql = require('graphql'); +const _ = require('lodash'); const { GraphQLObjectType, @@ -6,6 +7,13 @@ const { GraphQLSchema } = graphql; +// temp data +const books = [ + { name: 'Name of the Wind', genre: 'Fantasy', id: '1' }, + { name: 'The Final Empire', genre: 'Fantasy', id: '2' }, + { name: 'The Long Earth', genre: 'Sci-Fi', id: '3' } +]; + const BookType = new GraphQLObjectType({ name: 'Book', fields: () => ({ @@ -22,7 +30,7 @@ const RootQuery = new GraphQLObjectType({ type: BookType, args: { id: { GraphQLString } }, resolve (parent, { id }) { - // code to retrieve data from db or other source + return _.find(books, { id }); } } }