You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When integrating our existing websocket server into graphql-yoga, we used the example recipe for integration, which wraps the request with envelop. This forwards the request object from the initial connection, which is a GET request, and so the usePreventMutationViaGET kicks in and prevents any mutation operations over the websocket.
Expected Behaviour
Mutations should be possible across the websocket.
Actual Behaviour
Mutations fail with an HTTP error 405 (method not allowed).
Debug Information
Example stack:
GraphQLError: Can only perform a mutation operation from a POST request.
at createGraphQLError (/Users/richardhonor/uw/crm-graphql/node_modules/graphql-yoga/node_modules/@graphql-tools/utils/cjs/errors.js:9:12)
at assertMutationViaGet (/Users/richardhonor/uw/crm-graphql/node_modules/graphql-yoga/cjs/plugins/requestValidation/usePreventMutationViaGET.js:21:46)
at /Users/richardhonor/uw/crm-graphql/node_modules/graphql-yoga/cjs/plugins/requestValidation/usePreventMutationViaGET.js:57:17
at /Users/richardhonor/uw/crm-graphql/node_modules/@envelop/core/cjs/orchestrator.js:110:17
at onSubscribe (/Users/richardhonor/uw/crm-graphql/src/main.ts:106:27)
at onMessage (/Users/richardhonor/uw/crm-graphql/node_modules/graphql-ws/lib/server.js:147:124)
at WebSocket.<anonymous> (/Users/richardhonor/uw/crm-graphql/src/websocket.ts:149:21)
at WebSocket.emit (node:events:513:28)
at WebSocket.emit (node:domain:489:12)
at Receiver.receiverOnMessage (/Users/richardhonor/uw/crm-graphql/node_modules/ws/lib/websocket.js:1180:20)
Further Information
As a workaround, I modified the request object so all operations are passed through as a POST:
Overview
When integrating our existing websocket server into graphql-yoga, we used the example recipe for integration, which wraps the request with envelop. This forwards the request object from the initial connection, which is a GET request, and so the usePreventMutationViaGET kicks in and prevents any mutation operations over the websocket.
Expected Behaviour
Mutations should be possible across the websocket.
Actual Behaviour
Mutations fail with an HTTP error 405 (method not allowed).
Debug Information
Example stack:
Further Information
As a workaround, I modified the request object so all operations are passed through as a POST:
Related previous issue: dotansimha/graphql-yoga#1704
The text was updated successfully, but these errors were encountered: