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
{{ message }}
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.
Since v1.11.0, for some reason invalid queries (for example querying a field on an object that does not exist, or forgetting to add a required argument) always result in a PUSH responses from processRequest if the client has text/event-stream in the accepts header.
But if the server does not actually implement PUSH responses, for example when using websockets for subscriptions and implementing that as in the graphql-ws example:
errors: [newGraphQLError("Subscriptions should be sent over WebSocket.")],
});
}
Then instead of getting a GraphQL validation error you get that "Subscriptions should be sent over WebSocket" message. Notably the version of GraphiQL supplied by graphql-helix has text/event-stream in the accepts header.
My server roughly follows the graphql-ws example, but with some differences like using fastify and having the ws handler in a separate POST-only route, but the issue stems from processRequest returning a PUSH response for GraphQL validation errors when my server does not even implement those otherwise.
To reproduce:
Start the graphql-ws example and execute the (invalid) query in GraphiQL:
mutation { echo(someArgThatDoesNotExist: 1) }
The response will be:
{
"errors": [
{
"message": "Subscriptions should be sent over WebSocket."
}
]
}
Whereas executing the query from a client that only accepts application/json the response will be:
Is it a bug that GraphQL validation errors are sent by graphql-helix as PUSH responses in the first place?
Or alternatively, is there some option missing in the graphql-ws example to stop the server from sending a PUSH response?
If I implement sendPushResult then obviously the error is correctly returned, but then a client can also query subscriptions over HTTP, which is not my intention.
The text was updated successfully, but these errors were encountered:
Ah, interesting. You're running the express example which does not allow websocket connections and wouldn't have the issue I'm describing, but my issue should occur with the graphql-ws example. And if I try that in the sandbox then you're right, it doesn't seem to occur there either.
I explicitly tested it with the graphql-helix example to make sure it wasn't some issue with my project, and when I tried it before submitting this issue it happened there too.
I will make a minimal reproduction later and post it here. Thanks for checking it!
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Since v1.11.0, for some reason invalid queries (for example querying a field on an object that does not exist, or forgetting to add a required argument) always result in a PUSH responses from
processRequest
if the client hastext/event-stream
in the accepts header.But if the server does not actually implement PUSH responses, for example when using websockets for subscriptions and implementing that as in the graphql-ws example:
graphql-helix/examples/graphql-ws/server.ts
Lines 50 to 55 in 3a1c91d
Then instead of getting a GraphQL validation error you get that "Subscriptions should be sent over WebSocket" message. Notably the version of GraphiQL supplied by graphql-helix has
text/event-stream
in the accepts header.My server roughly follows the graphql-ws example, but with some differences like using fastify and having the ws handler in a separate POST-only route, but the issue stems from
processRequest
returning a PUSH response for GraphQL validation errors when my server does not even implement those otherwise.To reproduce:
Start the graphql-ws example and execute the (invalid) query in GraphiQL:
The response will be:
Whereas executing the query from a client that only accepts
application/json
the response will be:Is it a bug that GraphQL validation errors are sent by graphql-helix as PUSH responses in the first place?
Or alternatively, is there some option missing in the graphql-ws example to stop the server from sending a PUSH response?
If I implement
sendPushResult
then obviously the error is correctly returned, but then a client can also query subscriptions over HTTP, which is not my intention.The text was updated successfully, but these errors were encountered: