Skip to content

Instantly share code, notes, and snippets.

@timothyde
Created November 11, 2018 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timothyde/e41ce8cdafce405c237978a62de60a6c to your computer and use it in GitHub Desktop.
Save timothyde/e41ce8cdafce405c237978a62de60a6c to your computer and use it in GitHub Desktop.
onUpdate = (cache, { data: { createBoard } }) => {
const { myBoards } = cache.readQuery({ query: MYBOARDS_QUERY });
cache.writeQuery({
query: MYBOARDS_QUERY,
data: { myBoards: myBoards.concat([createBoard]) }
});
this.handleCancel();
};
...
<Mutation mutation={CREATE_BOARD_MUTATION} update={this.onUpdate}>
{(createBoardMutation, { loading, error }) => (
<Search
placeholder="e.g. ACME Ping Pong"
enterButton={
<Button type="primary" loading={loading}>
Create!
</Button>
}
size="large"
onSearch={value => {
createBoardMutation({ variables: { name: value } });
}}
/>
)}
</Mutation>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment