Created
January 26, 2019 00:04
-
-
Save scottdomes/462a7de842c3a7a72384ef1aaf5df2e4 to your computer and use it in GitHub Desktop.
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
import React from 'react'; | |
import gql from 'graphql-tag'; | |
import { Mutation } from 'react-apollo'; | |
import Form from '../components/Form'; | |
import updateLocalStore from './updateLocalStore'; | |
const CREATE_CONTACT = gql` | |
mutation createContact($input: ContactInput!) { | |
createContact(input: $input) { | |
contactEdge { | |
__typename | |
node { | |
id | |
name | |
} | |
} | |
} | |
} | |
`; | |
const MutationComponent = () => { | |
return ( | |
<Mutation mutation={CREATE_CONTACT} update={updateLocalStore}> | |
{(create, { data }) => ( | |
<Form | |
onSubmit={(name, email) => { | |
create({ | |
variables: { | |
input: { | |
name, | |
} | |
} | |
}); | |
}} | |
/> | |
)} | |
</Mutation> | |
); | |
}; | |
export default MutationComponent; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment