Skip to content

Yoga's useResponseCache plugin breaks subscriptions #3005

@gthau

Description

@gthau

Describe the bug

When using the Yoga's plugin useResponseCache, subscriptions stop working with error:

  • for named subscription "Subscription \"testSub\" must select only one top level field."
  • for anonymous subscription: "Anonymous Subscription must select only one top level field."

Disabling the plugin (either by not importing it or conditionally using it) makes the subscriptions work again as expected.

Your Example Website or App

https://codesandbox.io/p/sandbox/silly-lucy-sm9x48

Steps to Reproduce the Bug or Issue

  1. Launch yarn dev or yarn start, the response cache plugin is enabled, run the default query and observe the error
  2. Launch yarn dev:no-cache or yarn start:no-cache, the response cache is disabled, run the default query and observe it's working as expected

Expected behavior

The response cache should not affect the subscriptions, they should work as expected and not be cached.

Screenshots or Videos

No response

Platform

  • OS: Linux
  • NodeJS: 16
  • graphql-yoga version 4.0.4
  • @graphql-yoga/plugin-response-cache version 2.1.1

Additional context

No response

Metadata

Metadata

Assignees

Labels

stage/2-failing-testA failing test was created that describes the issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions