Skip to content

Instantly share code, notes, and snippets.

@mxlje
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mxlje/07524f33bb04702bd7dd to your computer and use it in GitHub Desktop.
Save mxlje/07524f33bb04702bd7dd to your computer and use it in GitHub Desktop.
let BlogAuthor = new GraphQLObjectType({
name: 'Author',
fields: () => ({
id: { type: GraphQLString },
name: { type: GraphQLString }
})
})
let BlogArticle = new GraphQLObjectType({
name: 'Article',
fields: {
id: { type: new GraphQLNonNull(GraphQLString) },
isPublished: { type: GraphQLBoolean },
author: { type: BlogAuthor },
title: { type: GraphQLString },
body: { type: GraphQLString },
keywords: { type: new GraphQLList(GraphQLString) }
}
})
let RootQuery = new GraphQLObjectType({
name: 'Query',
fields: {
article: {
type: BlogArticle,
args: { id: { type: GraphQLID } },
// fetches an article from the database, including the author
resolve: (_, {id}) => article(id)
}
}
})
let schema = new GraphQLSchema({
query: RootQuery
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment