How to update InMemoryCache typePolicies

Hi, I’m new to AC3. I’d like to separate AC3 configuration by feature, for example when a page loads then add the AC3 configuration for queries on that page, rather than configuring AC3 for all pages when some may never be loaded.
I can see 2 solutions.

  1. Wrap each feature page in a ApolloProvider with a client for that page
  2. update the typePolicies when the page loads

Options 2 seems cleaner, something like

Screen Shot 2021-05-27 at 11.33.07 am

So my question: is it possible to update typePolicies or should I pursue another option?

@ray option 2 is almost right - it should be cache.policies.addTypePolicies() instead.

1 Like