Created
March 21, 2018 23:18
-
-
Save jaigouk/6b7ac1260525d2f7234484c136867169 to your computer and use it in GitHub Desktop.
fowarding-mutation
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
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