Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yoga's useResponseCache plugin breaks subscriptions #3005

Closed
gthau opened this issue Sep 19, 2023 · 2 comments · Fixed by #3006
Closed

Yoga's useResponseCache plugin breaks subscriptions #3005

gthau opened this issue Sep 19, 2023 · 2 comments · Fixed by #3006
Assignees
Labels
stage/2-failing-test A failing test was created that describes the issue

Comments

@gthau
Copy link
Contributor

gthau commented Sep 19, 2023

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

@EmrysMyrddin EmrysMyrddin added the stage/2-failing-test A failing test was created that describes the issue label Sep 20, 2023
@EmrysMyrddin EmrysMyrddin self-assigned this Sep 20, 2023
@EmrysMyrddin
Copy link
Collaborator

Ok, I finally managed to run the CI on my branch. Sorry for the delay It's relying on a open PR so I had some rebasing issues...

You can try out @graphql-yoga/plugin-response-cache@2.2.0-alpha-20230922084337-37bdcd05, it should fix your issue. I will try to release this change as soon as possible, but it will probably have to wait until monday, the team is not very available this week :-)

@gthau
Copy link
Contributor Author

gthau commented Sep 23, 2023

Ok, I finally managed to run the CI on my branch. Sorry for the delay It's relying on a open PR so I had some rebasing issues...

You can try out @graphql-yoga/plugin-response-cache@2.2.0-alpha-20230922084337-37bdcd05, it should fix your issue. I will try to release this change as soon as possible, but it will probably have to wait until monday, the team is not very available this week :-)

Tested, it's working for me. I tested both in the codesandbox provided in this issue with a striped down Yoga project, and on my work project using Yoga Driver in NestJS.

Thank you!

No rush to deliver the fix for me, I need it in ~10 days.

This was referenced May 7, 2024
This was referenced May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage/2-failing-test A failing test was created that describes the issue
Projects
None yet
2 participants