Home

Awesome

Magento 2 GraphQL Introspection Cache

<div align="center">

Packagist Downloads Packagist Version Packagist License Unit Test Integration Test

</div>

This module allows you to use the same mechanism that is used for caching regular GraphQL resolvers, for introspection queries.

This helps minimize the number of times Magento is bootstrapped.

The following introspection types are supported out of the box:

This module is experimental, it contains BC-fixes for older Magento versions (<2.4.2). Class internals will likely change when support for those versions end.

Getting Started

This module is intended to be installed with composer. From the root of your Magento 2 project:

  1. Download the package
composer require graycore/magento2-graphql-introspection-cache
  1. Enable the package
./bin/magento module:enable Graycore_GraphQlIntrospectionCache

Usage

You can add your own introspection cache identity by adding a bit of di.xml:

<type name="Graycore\GraphQlIntrospectionCache\Plugin\CachePlugin">
    <arguments>
        <argument xsi:type="array" name="introspectionHandlers">
            <item xsi:type="object" name="NameOfInspectedType">Namespace\Module\Model\Cache\Identity\Introspection\NameOfInspectedType</item>
        </argument>
    </arguments>
</type>

Your class must implement Magento\Framework\GraphQl\Query\Resolver\IdentityInterface.

For more information on GraphQL Cache Identities, please visit the official documentation.

Internals

Check out the unit/integration tests to get a better picture.