Skip to content

Instantly share code, notes, and snippets.

@kdipaolo
Created August 24, 2018 19:31
Show Gist options
  • Save kdipaolo/56404fa5a6551f11536701f11ed67d0e to your computer and use it in GitHub Desktop.
Save kdipaolo/56404fa5a6551f11536701f11ed67d0e to your computer and use it in GitHub Desktop.
const QUERY = gql`
// This query name needs to be named so that we can put this name in the refetch query array
query Resolutions {
resolutions {
_id
name
}
}
`
class ResolutionForm extends Component {
submitForm = async mutation => {
console.log(this.name.value)
console.log(mutation)
await mutation({
variables: {
name: this.name.value
}
})
}
render() {
return (
// Here
<Mutation mutation={CREATE_RESOLUTION} refetchQueries={['Resolutions']}>
{createResolution => (
<div>
<input type="text" ref={input => (this.name = input)} />
<button onClick={() => this.submitForm(createResolution)}>
Submit
</button>
</div>
)}
</Mutation>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment