Skip to content

Instantly share code, notes, and snippets.

@jaigouk
Created March 21, 2018 23:18
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 jaigouk/6b7ac1260525d2f7234484c136867169 to your computer and use it in GitHub Desktop.
Save jaigouk/6b7ac1260525d2f7234484c136867169 to your computer and use it in GitHub Desktop.
fowarding-mutation
onst { forwardTo } = require('prisma-binding')
// Here you see the difference between forwarding and delegating a mutation
const Mutation = {
// We are forwarding the `createPost` 1-to-1 from the app to the database API.
// That's why we use `forwardTo('db')` here.
// It is called `db` because that's the name of the binding instance that's
// created in `index.js`.
createPost: forwardTo('db'),
// We are transforming the input arguments for the deletePost mutation.
// That's why we use ctx.db.mutation here.
deletePost(parent, { id }, ctx, info) {
return ctx.db.mutation.deletePost({ where: { id } })
},
}
module.exports = { Mutation }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment