Created
August 24, 2018 19:31
-
-
Save kdipaolo/56404fa5a6551f11536701f11ed67d0e 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
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