Created
August 25, 2017 15:39
-
-
Save gc-codesnippets/42dac6c6c5015830815e3bbe045bff7c to your computer and use it in GitHub Desktop.
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 { | |
| commitMutation, | |
| graphql, | |
| } from 'react-relay' | |
| import {ConnectionHandler} from 'relay-runtime' | |
| import environment from './Environment' | |
| | |
| const mutation = graphql` | |
| mutation DeletePostMutation($input: DeletePostInput!) { | |
| deletePost(input: $input) { | |
| deletedId | |
| } | |
| } | |
| ` | |
| | |
| export default (postId, viewerId) => { | |
| const variables = { | |
| input: { | |
| id: postId, | |
| clientMutationId: "" | |
| }, | |
| } | |
| commitMutation( | |
| environment, | |
| { | |
| mutation, | |
| variables, | |
| onError: err => console.error(err), | |
| optimisticUpdater: (proxyStore) => { | |
| // ... you'll implement this in a bit | |
| }, | |
| updater: (proxyStore) => { | |
| // ... this as well | |
| }, | |
| }, | |
| ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment