magento2 – How to cache GraphQL requests?

The storeConfig is cached in the lasted version of Magento, so you can update it to have it.

About other requests, you need to create a Resolver, then specified it in your GraphQL schema.

@doc(description: "The store config query") @cache(cacheIdentity: "Magento\\StoreGraphQl\\Model\\Resolver\\Store\\Identity")

You can see an example of it in the Magento 2 Core storeConfig cache implementation.

Don’t forget to make sure you configured the Caching with Varnish or Caching with Fastly steps too.

Read more here: Source link