When to normalise data - a question about the Apollo Cache

Hi, I’ll try to keep my question brief:

I want to normalise the data that is returned from my API, in a pretty standard way - turning a list of ‘X’ into { Xs: { ... } } for example.

I can do this as soon as the data is returned from the query and use it how I want, eg:

const { data } = await client.query(...);
const normalizedData normalize(data);

My question is this - normally I’d use a library like Redux to store this normalised data, but I understand that Apollo has its own normalised cache/local state, and so I’m wondering if it’s possible to integrate this kind of thing into the cache? Would I have to always normalise the data, it would just not get re-fetched, or is there a way to always store the data in the Apollo Cache in the way that I want?

Thank you!

Hi! You could define a custom read function, as documented here.