Yoga/Envelop Response cache caches even when the result contains non-cacheable type

Author: wodCZCreated Nov 16, 2023Updated Sep 26, 2026
Labelskind/enhancementkind/docsgood first issue

Describe the bug

When using either yoga or envelop response cache plugin with:

  • global ttl set to 0
  • ttlPerType for an object type First set to 3600_000

Having a query that queries for both first and second, the whole result is cached, even though second didn't have an explicit ttlPerType defined - so should have the default ttl of 0, thus the response shouldn't be cached (or only partially, for the first result).

Your Example Website or App

https://codesandbox.io/p/sandbox/charming-yalow-q689gx-q689gx

Steps to Reproduce the Bug or Issue

Run the default query from the codesandbox.

Expected behavior

The query should not be cached, i.e. should return

    "responseCache": {
      "hit": false,
      "didCache": false
    }

instead, the result is cached.

Notice that if we explicitly add Second: 0 to ttlPerType, the query is not cached, as expected.

Screenshots or Videos

No response

Platform

  • OS: macOS
  • NodeJS: 21.2.0, but any supported, really
  • @graphql-yoga/plugin-response-cache: 3.1.0

Additional context

No response

Source: graphql-hive/graphql-yoga