enisdenjo / graphql-ws

Coherent, zero-dependency, lazy, simple, GraphQL over WebSocket Protocol compliant server and client.
https://the-guild.dev/graphql/ws
MIT License
1.75k stars 162 forks source link

Hasura connection error is not reported correctly #499

Closed lovasoa closed 1 year ago

lovasoa commented 1 year ago

Screenshot image

Reproduction

Connecting to a hasura graphql server with a jwt that does not contain the x-hasura-default-role claim.

Expected Behaviour The error returned by hasura is properly forwarded to the user.

Hasura returns {"type":"connection_error","payload":"JWT claim does not contain x-hasura-default-role"}

The error message returned by the library should contain the string JWT claim does not contain x-hasura-default-role

Actual Behaviour but instead the library threw the following error :

 Error: Invalid message 'type' property "connection_error"
    validateMessage common.mjs:142
    parseMessage common.mjs:168
    onmessage client.mjs:214
    connecting client.mjs:212
    connecting client.mjs:256