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

fix mutation over websocket/subscription #986

Merged
merged 2 commits into from Apr 27, 2023

Conversation

tomi-bigpi
Copy link
Contributor

Fixes issue where mutations are not allowed over web sockets (subscriptions).

See: #977

index.js Outdated
@@ -471,7 +471,7 @@ const plugin = fp(async function (app, opts) {
document = cached.document
}

if (reply && reply.request.raw.method === 'GET') {
if (reply && reply.request.raw.method === 'GET' && reply.request.headers.upgrade?.toLowerCase() !== 'websocket') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (reply && reply.request.raw.method === 'GET' && reply.request.headers.upgrade?.toLowerCase() !== 'websocket') {
if (reply && reply.request.raw.method === 'GET' && !reply.request.ws) {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should work, check it out!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, it worked with manual testing, so I updated the corresponding test to set that flag on the request like fastify-websocket does.

Copy link
Collaborator

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina merged commit f49c129 into mercurius-js:master Apr 27, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants