Last active
August 29, 2015 14:25
-
-
Save mxlje/07524f33bb04702bd7dd to your computer and use it in GitHub Desktop.
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
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