Last active
August 5, 2019 10:22
-
-
Save hwillson/1b9974ef6122bf8d9a59994e0a615357 to your computer and use it in GitHub Desktop.
React Apollo 3 - Multiple Mutations
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
function Message() { | |
const [saveMessage, { loading }] = useMutation(SAVE_MESSAGE); | |
const [deleteMessage] = useMutation(DELETE_MESSAGE); | |
const { data } = useQuery(GET_MESSAGE); | |
return ( | |
<div> | |
<p> | |
{loading | |
? 'Loading ...' | |
: `Message: ${data && data.message ? data.message.content : ''}`} | |
</p> | |
<p> | |
<button onClick={() => saveMessage()}>Save</button> | |
<button onClick={() => deleteMessage()}>Delete</button> | |
</p> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment