Skip to content

Support reading array of multiple sub protocols from client #242

Answered by enisdenjo
dushaniw asked this question in Q&A
Discussion options

You must be logged in to vote

Hi there,

the client is fixed using "graphql-transport-ws" subprotocol intentionally because it does not know which subprotocol the server chose when multiple are supplied. The client just knows if the connection was accepted or not. This means that sending both subprotocols (["graphql-transport-ws", "graphql-ws"]) from the createClient will break if the latter is selected by the server due to subprotocol mismatch.

Instead, what you should do is check one by one. To check if this library ("graphql-transport-ws") is supported, you can do something like:

function supportsGraphQLTransportWS(url: string): Promise<boolean> {
  return new Promise((resolve) => {
    const client = createClient({

Replies: 3 comments 8 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by enisdenjo
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
8 replies
@enisdenjo
Comment options

@enisdenjo
Comment options

@leszekhanusz
Comment options

@leszekhanusz
Comment options

@enisdenjo
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #240 on October 12, 2021 14:03.