close

Filter

loading table of contents...

Headless Server Developer Manual / Version 2207

Table Of Contents

14.2.2 Configuring Apollo Cache

It is necessary to configure the InMemoryCache for the caching to work correctly and to successfully map every item to an ID.

Since CoreMedia content types are more complex than just Boolean, string or number, the Apollo cache needs to know what kind of supertypes to expect and what types they consist of. This helps to identify cacheable content types like banner, CMArticle or CMCollection. Therefore, the possible types need to be generated from the schema and included in the cache configuration.

The easiest way is to create a separate script to download them as JSON and save it as possibleTypes.json in your app. More information on this and a complete code example can be found in the documentation for "generating possible types automatically".

import possibleTypes from './possibleTypes.json';

const client = new ApolloClient({
  cache: new InMemoryCache({
    possibleTypes
  })
  ...
});

Example 14.3. Configuring the Apollo Cache


Caution

Caution

If you don’t add the generated list of possible types to the ApolloClient, the following components do not include and render any other property than the id.

Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.