If I want to insert nested local data to be normalized, I need to specify both id and __typename all around my json, for all entrees. But this is time consuming and error prone (e.g. if I forget it for one entry, the store will mix normalized and non-normalized data):
Assuming the combination of name and quantity is sufficient for differentiating one Ingredients object from another, this will remove the need to assign an id.
However, __typename is an essential part of normalization. You will still need to have objects with __typename: "Ingredients" in order for that type policy to work. If you find yourself duplicating a lot of __typename: "FooBar" expressions in your codebase, consider creating a utility function to reduce the amount of duplication. I hope that helps, let me know
Thanks a lot for your answer, too bad apollo can’t deal with this better, especially when client schema could be used for this.
Regarding lenz answer that does not recommend Apollo client for local state management, I’m really confused now: using redux + normalizr seems much more complicated to maintain than graphql that I find to bequite elegant, especially when we addionally use graphql to deal with remote content anyway. So would you recommend redux + normalizr + appolo for instance in that scenario? If yes, what is wrong with appolo alone?