Async-graphql: GraphQL over WebSocket Protocol does not support ConnectionError events

Created on 5 Feb 2021  路  4Comments  路  Source: async-graphql/async-graphql

Expected Behavior

If a error occurs during a connection using GraphQL over WebSocket Protocol then it should send a response that the graphql-ws client can parse.

Spec: https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md

Actual Behavior

The websocket send a ConnectionError event which is not spec'd for GraphQL over WebSocket Protocol

Steps to Reproduce the Problem

  1. Attempt to connect with ws-client to a server which results in a connection init error. Websocket code looks like:
            let connection = async_graphql::http::WebSocket::with_data(
                schema,
                message_stream,
                initializer,
                async_graphql::http::WebSocketProtocols::GraphQLWS,
            )
                .map(|msg| msg.into_bytes());
  1. Receive a response like: {"type":"connection_error","payload":{"message":"invalid type: string \"{\\\"type\\\":\\\"connection_init\\\"}\", expected internally tagged enum ClientMessage at line 1 column 32"}}
bug

All 4 comments

I'm not 100% sure about this but I think the expected behaviour is to close the websocket with an HTTP error.

You are right, I modified this question in the master branch, please help me test it, thanks.

Release in v2.5.2 馃檪

Sorry, got pulled off this for a couple weeks. Looks like it's working as expected now. Thanks!

Was this page helpful?
0 / 5 - 0 ratings