Skip to content

Instantly share code, notes, and snippets.

@rafaelvicio
Created August 24, 2017 16:50
Show Gist options
  • Save rafaelvicio/fe70c25d432df3d3eeaf5b6ac46475f8 to your computer and use it in GitHub Desktop.
Save rafaelvicio/fe70c25d432df3d3eeaf5b6ac46475f8 to your computer and use it in GitHub Desktop.
resolvers: {
RootQuery: {
posts: () => posts,
post: async (_, { id }) =>
await Post.query()
},
RootMutations: {
createPost: async (_, { input }) =>
await Post.query.insert(input)
},
RootSubscriptions: {
postAdded: {
subscribe: () =>
pubsub.asyncIterator('postAdded')
},
Post: {
author: async post =>
await Usuario.query().where("id", "=", post.author_id)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment