Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const publishMutation = (
<Mutation
mutation={PUBLISH_MUTATION}
update={(cache, { data }) => {
const { drafts } = cache.readQuery({ query: DRAFTS_QUERY })
const { feed } = cache.readQuery({ query: FEED_QUERY })
cache.writeQuery({
query: FEED_QUERY,
data: { feed: feed.concat([data.publish]) },
})
cache.writeQuery({
query: DRAFTS_QUERY,
data: {
drafts: drafts.filter(draft => draft.id !== data.publish.id),
},
})
}}
>
{(publish, { data, loading, error }) => {
return (
<a
className="f6 dim br1 ba ph3 pv2 mb2 dib black pointer"
onClick={async () => {
await publish({
variables: { id },
})
this.props.history.replace('/')
}}
>
Publish
</a>
)
}}
</Mutation>
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.