I’m running into an issue where the returned data of mutations is not synchronizing with the query data in the Redux cache.
I have a simple example of a user profile form using Apollo. The container has 1 query viewer which returns a PublicUser type with a profile object. It also has a mutation called updateViewerProfile that updates the user’s profile. The mutation returns the type PublicUser with a profile object as well.
For example, when I fetch the user profile in the query it comes back as expected with a profile.name field of "Ted". Then when I call the mutation with an updated name field of "Bob" the response I get back in the mutation has a profile with the name of Bob. However, the cached data in the query has a name of Ted.
Is there a way around this? Having duped data on mutations and queries is a deal breaker for me but I wanted to check if anyone had a solution before I switched to the core apollo-client API.
I know it is not super intuitive and it is not super well documented, but as for now, Apollo Client has no way to correlate different objects in store without a unique identifier for every object.
Ah thanks @slava for referring to this! I’m going to have to re-read the docs to catch up on new stuff
So it sounds like if I return the id in both that might work… I’m hoping it might be as simple as (doc) => doc.id ? Once I get it working i’ll submit a PR for the docs
Also I forgot to paste in the queries but it sounds like the above may do it (though i’ll need to return the id)