graphql-yoga icon indicating copy to clipboard operation
graphql-yoga copied to clipboard

usePreventMutationViaGET default plugin breaks mutations via WS

Open qw-in opened this issue 3 years ago • 0 comments

Describe the bug

Not sure if mutation over ws is something you even support. If not please disregard!

Following the WS subscriptions guide in the docs works for query & subscription. However, it breaks when attempting to run a mutation via WS.

This example: https://www.the-guild.dev/graphql/yoga-server/docs/features/subscriptions#subscriptions-over-websockets-with-graphql-ws

Results in an error here Cannot read properties of undefined (reading 'method').

https://github.com/dotansimha/graphql-yoga/blob/049d6a06ab0b50597d2544ba1f7f35e3c562e5d8/packages/common/src/plugins/requestValidation/usePreventMutationViaGET.ts#L37

Your Example Website or App

Can provide if needed

Steps to Reproduce the Bug or Issue

  1. Create graphql-ws integration as per docs example above.
  2. Run a mutation via the ws (use client from graphql-ws for example)
  3. Notice error

Expected behavior

I dunno, I am pretty deep in the sauce here. Not sure you want to support this. Maybe some option to disable default plugins without having to rewrite the whole server?

Screenshots or Videos

No response

Platform

  • OS: V8 isolate I guess?
  • NodeJS: Nope! Cloudflare
  • @graphql-yoga/common version(s): 2.12.11

Additional context

No response

qw-in avatar Sep 05 '22 21:09 qw-in