Skip to content

Instantly share code, notes, and snippets.

@timhudson
Created May 1, 2017 19:51
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 timhudson/c2e6a0cce7fb5b358ba4f88d6919badf to your computer and use it in GitHub Desktop.
Save timhudson/c2e6a0cce7fb5b358ba4f88d6919badf to your computer and use it in GitHub Desktop.
Colocating GraphQL resolvers with types
export default `
type RootQuery {
user(id = String, email = String) User
}
`
export const user = async (_, { id, email }, ctx) => {
return {
id: 'this',
name: 'that'
}
}
export default `
type User {
id: String!
created: String
isAdmin: Boolean
name: String
lastSeen: String
email: String
}
`
export const isAdmin = async ({ id }, _, ctx) => ctx.checkAdmin(id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment