Skip to content

Instantly share code, notes, and snippets.

@scottdomes
Created January 26, 2019 00:04
Show Gist options
  • Save scottdomes/462a7de842c3a7a72384ef1aaf5df2e4 to your computer and use it in GitHub Desktop.
Save scottdomes/462a7de842c3a7a72384ef1aaf5df2e4 to your computer and use it in GitHub Desktop.
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
email
name
}
}
}
}
`;
const MutationComponent = () => {
return (
<Mutation mutation={CREATE_CONTACT} update={updateLocalStore}>
{(create, { data }) => (
<Form
onSubmit={(name, email) => {
create({
variables: {
input: {
name,
email
}
}
});
}}
/>
)}
</Mutation>
);
};
export default MutationComponent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment