-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I distinguish between two queries with the same __typename to get Apollo Client typePolicies cache to work properly #9192
Comments
@meesfrenkelfrank Though there are a few different ways to approach this kind of problem, I'll focus on your First of all, just in case you weren't aware, defining However, based on your description, it sounds like you have not just one Putting
|
@benjamn thanks a lot for your clear explanation! I'll discuss if solution one is possible (to update the schema with a type field). When I debug below, in the console,
Also I tried a third option, but I don't know if thats possible? Another option which I am going to discuss is to replace Then my
Is that correct? What would be the best option to change the schemas in your opinion. Adding two different object to distinguish or adding a |
@benjamn I need your help. Backend has been changed and now I have two singleton objects My typePolicies are configured like this now:
The issue I am facing is the following also described here: When navigating from the overview page to a detail node page it's rendered (and merged) correctly. Query and fetchMore is working fine. Now when pressing the browser back button to overview page and from there navigate to another node the results from the first cache are presented (merged) with the new ones from this current node? So the content/results are mixed up now. What I also tried is the following:
But then the fetchMore isn't working anymore, looks like existing and incoming are not merged correctly? Whats causing this issue and how to solve it? Many thanks! |
I have a related question: I have two different queries that both return the an object with the same key, and typeName but the value is different. so my firstQuery returns: { { Customer:{ some object/different object are both partials to the getCurrent query. |
I have two GraphQL queries from our GraphQL server (see below), but they both have the same
__typename
:"__typename": "RelatedNodes",
.I am building a Carousel with pagination using Apollo Client fetchMore function. When I use just one query all works fine.
But when I use both queries, Apollo Client cache gets confused.
The Apollo Client
typePolicies
configured like:Query one:
Which returns:
And query two:
Which returns:
How do I have to set up my typePolicies so that the cache can distinguish between the two queries? Or do I have to change the GraphQL server types?
The text was updated successfully, but these errors were encountered: