So basically I want to update my UI after a mutation, but this has truly been a pain, been stuck for a few days now.

Some of my components rely on my root query, and map over the results.

Whenever I create a new resource and update my root query, the original results don't get loaded anymore, which causes a can't read property map of undefined , because the result isn't there anymore. Adding a check does nothing, it just keeps loading forever.

This is my mutation:

export const withCreateLink = graphql(createLink, { // Mutate normally gets passed as prop to wrapped component props({ownProps, mutate}) { return { // But for updating the store we're actually hijacking mutate to a custom function createLink(url, description, group) { return mutate({ variables: { url, description, group }, optimisticResponse: { createLink: { __typename: 'Link', id: -1, url, description, group: { id: group } } }, update: (proxy, mutationResult) => { const query = getAllGroups; const data = proxy.readQuery({query}); data.allGroups.forEach((groupData) => { if(groupData.id == group) groupData.links.push(mutationResult.data.createLink); }); proxy.writeQuery({ query, data }) } }) } } } });

I just want to simply update my UI by only refreshing the group that my resource was added to. Can anybody help me out?