-
-
Save skynode/3c96ff8b8f1ea7ff7b764470d324baea to your computer and use it in GitHub Desktop.
How to create a Hacker News API with Node.js and GraphQL https://medium.com/p/3b13ef04ec0f
This file contains hidden or 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
import { GraphQLSchema, GraphQLObjectType } from 'graphql'; | |
import { nodeField, nodesField } from './types/Node'; | |
import StoryType from './types/StoryType'; | |
import UserType from './types/UserType'; | |
import StoryMutations from './mutations/StoryMutations'; | |
import CommentMutations from './mutations/CommentMutations'; | |
export default new GraphQLSchema({ | |
query: new GraphQLObjectType({ | |
name: 'Query', | |
fields: { | |
node: nodeField, | |
nodes: nodesField, | |
me: { | |
type: UserType, | |
async resolve() { | |
// TODO: Resolve the currently logged in user | |
}, | |
}, | |
stories: { | |
type: StoryType /* TODO: Replace with StoryConnection type */, | |
args: {} /* TODO: StoryConnection args */, | |
async resolve() { | |
// TODO: Resolve the list of stories from a database | |
}, | |
}, | |
}, | |
}), | |
mutation: new GraphQLObjectType({ | |
name: 'Mutation', | |
fields: { | |
...StoryMutations, | |
...CommentMutations, | |
}, | |
}), | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment