Hello, I have Apollo Client setup with the REST link for some endpoints and I use the typePatcher to manually add __typename to nodes and each one as an id indentifier. The query result after patch is like:
But the cached result in Apollo Client shows only in ROOT_QUERY as current_order({ input: {}}). I’d like to show its payload cached like MealOrder:123, etc.
I wonder if the problem is related to any of these facts:
This REST endpoint is a POST instead of a GET. Yes, it’s the wrong method and that’s the reason why apollo caches it with empty input arguments in the query current_order({ input: {}}) instead of just current_order.
Deeply nested response without __typename or id in some nodes.
If your endpoint is GET or POST should not have any influence on how things are stored in the cache. If you provide variables to your query, your cache entry path also seems fine.
Generally, that part of your payload should be cached as a reference to MealOrder:123. Is this a basic Apollo Client, or do you have some InMemoryCache configuration that might have changed it’s behaviour?
I’m pretty sure that your payload does this pattern - to be honest, I’m not sure if it’s possible to return JSON that doesn’t match this (apart from a plain string or number).
Could you create some reproduction that shows this behaviour you see here? It’s hard to give any advice otherwise.
Generally, everything that has a typename and id should be normalized - no matter how many non-normalizable layers are between.