PHPackages                             graycore/magento2-graph-ql-cache - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. graycore/magento2-graph-ql-cache

ActiveMagento2-module[Caching](/categories/caching)

graycore/magento2-graph-ql-cache
================================

A Magento 2 module that modifies the built-in GraphQlCache FPC.

0.0.5(1mo ago)123.0k↓63.1%[3 PRs](https://github.com/graycoreio/magento2-graph-ql-cache/pulls)MITPHPCI passing

Since Jul 25Pushed 1w agoCompare

[ Source](https://github.com/graycoreio/magento2-graph-ql-cache)[ Packagist](https://packagist.org/packages/graycore/magento2-graph-ql-cache)[ GitHub Sponsors](https://github.com/graycoreio)[ RSS](/packages/graycore-magento2-graph-ql-cache/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (4)Dependencies (7)Versions (11)Used By (0)

graycore/magento2-graph-ql-cache
================================

[](#graycoremagento2-graph-ql-cache)

The Graycore GraphQL Cache module provides a structured mechanism for managing and applying cache lifetimes (TTLs) for Magento 2 GraphQL queries. It allows resolvers to contribute dynamic TTL values based on business logic, such as future dates, promotions, or entity validity. These TTLs are then automatically applied to the response as cache-control headers, enabling full-page caching and CDN integration for GraphQL endpoints.

[![Packagist Downloads](https://camo.githubusercontent.com/f2f40fd1dbb6efd862170dcc6a2e69d3f1c4efb35a5df24a87c5ce0cb3c3bf37/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f67726179636f72652f6d6167656e746f322d67726170682d716c2d63616368653f636f6c6f723d626c7565)](https://packagist.org/packages/graycore/magento2-graph-ql-cache/stats)[![Packagist Version](https://camo.githubusercontent.com/cffdafb0650575ecca6639bb95b6781d0a554a07d1cfa3e7654842da1908917c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f67726179636f72652f6d6167656e746f322d67726170682d716c2d63616368653f636f6c6f723d626c7565)](https://packagist.org/packages/graycore/magento2-graph-ql-cache)[![Packagist License](https://camo.githubusercontent.com/6dc7f08283eb3d93bf325b5d2c85222a41394a2b119e89ae6a98a8dd9c707fe5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f67726179636f72652f6d6167656e746f322d67726170682d716c2d6361636865)](https://github.com/graycoreio/magento2-graph-ql-cache/blob/main/LICENSE)[![MageCheck Status](https://camo.githubusercontent.com/ac48e1954aca3782b9f0dc34497d0c0d55bb241aab346bb7844dbf2ca30ea51c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f67726179636f7265696f2f6d6167656e746f322d67726170682d716c2d63616368652f636865636b2d657874656e73696f6e2e79616d6c3f266c6162656c3d4d616765436865636b266c6162656c436f6c6f723d316131613161)](https://github.com/graycoreio/magento2-graph-ql-cache/actions/workflows/check-extension.yaml)[![MageCheck Supported Version](https://camo.githubusercontent.com/7e39a6d24d42596e6ddf7d6a99b93d5ef0bfd0fd1190cdf79d08eb7d9e1ba773/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f63757272656e746c795f737570706f727465642d616e793f6c6162656c3d4d616765436865636b253230537570706f72746564266c6162656c436f6c6f723d31613161316126636f6c6f723d303930633962)](https://camo.githubusercontent.com/7e39a6d24d42596e6ddf7d6a99b93d5ef0bfd0fd1190cdf79d08eb7d9e1ba773/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f63757272656e746c795f737570706f727465642d616e793f6c6162656c3d4d616765436865636b253230537570706f72746564266c6162656c436f6c6f723d31613161316126636f6c6f723d303930633962)

Use Case
--------

[](#use-case)

This module is ideal for Magento stores that want to:

- Dynamically cache GraphQL queries based on data freshness
- Improve GraphQL performance with edge caching/CDNs
- Respect TTLs for time-sensitive data (e.g. flash sales, scheduled promotions, expiring inventory)

Key Features
------------

[](#key-features)

- **Resolver-Driven TTL Aggregation** - Resolver code can dynamically register TTLs using ResolverTtlStoreInterface, either with explicit seconds or based on future dates (with support for start-of-day and end-of-day cutoffs).
- **Automatic Cache Header Population** - This plugin will intercept GraphQL response rendering and applies the minimum TTL collected during the query lifecycle, enabling fine-grained cache-control behavior for GraphQL results.
- **Supports Flexible Input** - TTL input can be an integer, a DateTimeImmutable object, or a string (auto-parsed using the current store’s timezone).
- **Integration with Magento’s GraphQlCache system** - Honors and respects Magento's existing CacheableQuery mechanisms, enhancing them with automatic TTL computation.

Install
-------

[](#install)

```
composer require graycore/magento2-graph-ql-cache
bin/magento module:enable Graycore_GraphQlCache
bin/magento setup:upgrade
```

Usage
-----

[](#usage)

The primary mechanism that you interact with after installation is the `Graycore\GraphQlCache\Api\ResolverTtlStoreInterface`.

```
declare(strict_types=1);

namespace Vendor\Module\Model\Resolver;

use Graycore\GraphQlCache\Api\ResolverTtlStoreInterface;
use Magento\Framework\GraphQl\Config\Element\Field;
use Magento\Framework\GraphQl\Query\ResolverInterface;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;

class VendorResolver implements ResolverInterface
{

    public function __construct(
        private ResolverTtlStoreInterface $ttlStore
    ) {}

    /**
     * @inheritDoc
     */
    public function resolve(
        Field $field,
        $context,
        ResolveInfo $info,
        array $value = null,
        array $args = null
    ) {
        $this->ttl->add(300); // raw seconds
        $this->ttl->addForDate('2025-08-01T12:00:00'); // string or DateTimeImmutable
        $this->ttl->addForStartDate($date); // uses midnight of the provided date
        $this->ttl->addForEndDate($date);   // uses 23:59:59 of the provided date

        return $value;
    }
}
```

Upgrading
---------

[](#upgrading)

- [Semver Policy](https://semver.org/)

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance95

Actively maintained with recent releases

Popularity29

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 71.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~98 days

Total

4

Last Release

47d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cede4d8ff3624bd4e509cebd8a3da9abada797eb8e0737c6db26097fce82e67e?d=identicon)[damienwebdev](/maintainers/damienwebdev)

---

Top Contributors

[![damienwebdev](https://avatars.githubusercontent.com/u/9029654?v=4)](https://github.com/damienwebdev "damienwebdev (15 commits)")[![gray-bot](https://avatars.githubusercontent.com/u/120588553?v=4)](https://github.com/gray-bot "gray-bot (4 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/graycore-magento2-graph-ql-cache/health.svg)

```
[![Health](https://phpackages.com/badges/graycore-magento2-graph-ql-cache/health.svg)](https://phpackages.com/packages/graycore-magento2-graph-ql-cache)
```

###  Alternatives

[fastly/magento2

Fastly CDN Module for Magento 2.4.x

1564.4M1](/packages/fastly-magento2)[lizardmedia/module-varnish-warmer

Varnish Cache Warmer Magento2 module by Lizard Media

6180.3k](/packages/lizardmedia-module-varnish-warmer)[elgentos/magento2-varnish-extended

This extension extends the built-in Varnish functionalities

6920.7k](/packages/elgentos-magento2-varnish-extended)[litespeed/module-litemage

LiteMage Full Page Cache for LiteSpeed Web Server

3257.9k](/packages/litespeed-module-litemage)[pronko/selective-cache

Pronko Consulting Selective Cache

3520.4k](/packages/pronko-selective-cache)[myparcelnl/magento

A Magento 2 module that creates MyParcel labels

1860.2k](/packages/myparcelnl-magento)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
