Closed ntziolis closed 3 years ago
We are happy to take on the implementation but before starting wanted some input in which solution path you would prefer or if any support for the legacy protocol is not an option for you.
I think you are referring to subscription-transport-ws
by graphql-ws
. We'd love to have both supported in url-loader
. It sounds good to me :)
Yes that's what I was referring to. I'll get right on it then and create 2 Prs:
Thank you @ntziolis ! We'd love to merge and release new versions for those.
@ardatan Any preferences on how the config option for the graphql handler should be named? I would suggest adding a boolean flag. Something like useLegacyWsProtocol
. But I'll go with whatever you prefer.
This flag would default to false. We can then pass this flag directly to the loader:
graphql-ws
lib (protocol graphql-transport-ws
)subscriptions-transport-ws
lib (protocol graphql-ws
)Btw the naming scheme of the libs their protocols is VERY confusing :D
Yes they are confusing unfortunately :D So I am fine with your approach.
PR for part one was just created. Part 2 is already done but requires part one to be released.
See for part 2 here: https://github.com/Urigo/graphql-mesh/compare/master...ntziolis:support-legacy-ws-protocol
For anyone finding this, once released this can be configured via
sources:
- name: countries
handler:
graphql:
endpoint: https://countries.trevorblades.com/
# this is the new flag
useWebSocketLegacyProtocol: true
The Problem:
graphql-ws
protocol mesh currently cannot be used as gateway for subscriptions.graphql-transport-ws
adoption is spreading there are many situations where an existing source only supports the legacygraphql-ws
protocol.Enabling the ability to connect graphql sources that are not yet
graphql-transport-ws
compliant would further extend the use cases for GraphQL Mesh. In addition it could assist in speeding up the transition to the new protocol since one barrier of entry (server side handling of the new protocol) would be removed or at least phased (at some point people should upgrade their downstream sources).Our Use Case:
Describe the solution you'd like
graphql-transport-ws
would be the default when not providedgraphql-ws
There are 2 general approaches:
buildWSSubscriber
being replaced with the legacy clientbuildWSSubscriber
implementationWe have already tested the first approach successfully via monkey patch. Afterwards Mesh was capable of receiving incoming requests in the new protocol but making outgoing requests with the legacy protocol.
Here is the patch we used: https://gist.github.com/ntziolis/e6eff864709b737aadbe82e1ca763010
This is what we replaced after copying the source from
@graphql-tools/url-loader
: