feat(server): add dummy data

This commit is contained in:
Joshua Seigler 2020-01-28 23:17:10 -05:00
parent 0bd76ac5dc
commit 27a5900978

View file

@ -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 });
}
}
}