Skip to content

Instantly share code, notes, and snippets.

@JakeDawkins
Created June 13, 2018 16:20
Show Gist options
  • Save JakeDawkins/987aefbe289198f9ef87806c64535c1a to your computer and use it in GitHub Desktop.
Save JakeDawkins/987aefbe289198f9ef87806c64535c1a to your computer and use it in GitHub Desktop.
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