Created
July 13, 2018 08:53
-
-
Save jefelewis/98122cd7605edc0137e92603949d18cb to your computer and use it in GitHub Desktop.
grapql-express
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Imports: GraphQL | |
const graphQL = require('graphql'); | |
// Imports: GraphQL Packages | |
const { | |
GraphQLObjectType, | |
GraphQLString, | |
GraphQLSchema, | |
GraphQLInt, | |
GraphQLID, | |
GraphQLList, | |
GraphQLNonNull | |
} = graphQL; | |
// Imports: MongoDB Schema | |
const BOOK = require('../mongoose-schemas/bookschema.js'); | |
const AUTHOR = require('../mongoose-schemas/authorschema.js'); | |
// GraphQL: Book Type | |
const BOOKTYPE = new GraphQLObjectType({ | |
name: 'Book', | |
fields: () => ({ | |
id: { type: GraphQLID }, | |
name: { type: GraphQLString }, | |
genre: { type: GraphQLString }, | |
author: { | |
type: AUTHORTYPE | |
} | |
} | |
}) | |
}); | |
// GraphQL: Author Type | |
const AUTHORTYPE = new GraphQLObjectType({ | |
name: 'Author', | |
fields: () => ({ | |
id: { type: GraphQLID }, | |
name: { type: GraphQLString }, | |
age: { type: GraphQLInt }, | |
books: { | |
type: new GraphQLList(BOOKTYPE) | |
} | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment