Created
June 13, 2018 16:20
-
-
Save JakeDawkins/987aefbe289198f9ef87806c64535c1a 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
export const DELETE_DOG_MUTATION = gql` | |
mutation deleteDog($name: String!) { | |
deleteDog(name: $name) { | |
id | |
name | |
breed | |
} | |
} | |
`; | |
export const DeleteButton = () => ( | |
<Mutation mutation={DELETE_DOG_MUTATION}> | |
{(mutate, { loading, error, data }) => { | |
if (loading) return <p>Loading...</p>; | |
if (error) return <p>Error!</p>; | |
if (data) return <p>Deleted!</p>; | |
return ( | |
<button onClick={() => mutate({ variables: { name: 'Buck' } })}> | |
Click me to Delete Buck! | |
</button> | |
); | |
}} | |
</Mutation> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment