https://github.com/graycoreio/magento2-graphql-introspection-cache
This package caches introspection results from the GraphQl native `__types` query.
https://github.com/graycoreio/magento2-graphql-introspection-cache
caching graphql mage-os magento2 performance
Last synced: 8 months ago
JSON representation
This package caches introspection results from the GraphQl native `__types` query.
- Host: GitHub
- URL: https://github.com/graycoreio/magento2-graphql-introspection-cache
- Owner: graycoreio
- License: mit
- Created: 2022-07-20T18:43:55.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2025-02-25T17:07:05.000Z (over 1 year ago)
- Last Synced: 2025-02-25T17:35:37.564Z (over 1 year ago)
- Topics: caching, graphql, mage-os, magento2, performance
- Language: PHP
- Homepage:
- Size: 65.4 KB
- Stars: 9
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Magento 2 GraphQL Introspection Cache
[](https://packagist.org/packages/graycore/magento2-graphql-introspection-cache/stats)
[](https://packagist.org/packages/graycore/magento2-graphql-introspection-cache)
[](https://github.com/graycoreio/magento2-graphql-introspection-cache/blob/main/LICENSE)
[](https://github.com/graycoreio/magento2-graphql-introspection-cache/actions/workflows/unit.yaml)
[](https://github.com/graycoreio/magento2-graphql-introspection-cache/actions/workflows/integration.yaml)
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:
- ProductAttributeFilterInput
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](https://getcomposer.org/). From the root of your Magento 2 project:
1. Download the package
```bash
composer require graycore/magento2-graphql-introspection-cache
```
2. Enable the package
```bash
./bin/magento module:enable Graycore_GraphQlIntrospectionCache
```
## Usage
You can add your own introspection cache identity by adding a bit of di.xml:
```xml
Namespace\Module\Model\Cache\Identity\Introspection\NameOfInspectedType
```
Your class must implement `Magento\Framework\GraphQl\Query\Resolver\IdentityInterface`.
For more information on GraphQL Cache Identities, please visit the [official documentation](https://devdocs.magento.com/guides/v2.4/graphql/develop/identity-class.html).
## Internals
- A before plugin is created on `QueryProcessor::process` to set a custom `ReferenceExecutor`. This `ReferenceExecutor` is instantiated using the Object Manager, so that we can use plugins on it in a later stage.
- An after plugin is created on `ReferenceExecutor::doExecute`. This plugin determines if we are dealing with an introspection request and if there is a cache identity registered for it. If there is, it will attempt to generate cache tags and add it to the request.
Check out the unit/integration tests to get a better picture.