Combining graphql-ws with Apollo on the client side with single HTTP stream. #234
-
@enisdenjo - I am wondering how to go about combining graphql-ws and HTTP streams on the client side. I have a working example of subscriptions-transport-ws with Apollo 3.0 :- https://github.com/AaronNGray/fullstack-apollo-3.0-subscription-example And hopefully got graphql-ws server side code in place :- I am unsure on how to go about creating a graphql-ws client compatible with Apollo and with a single combined HTTP stream. But have put a provisional client in place :- that obviously does not work and comes up with the following error :-
Is there an existing way of doing these both or either of these two things :-
Ideally there would be a package that would provide compatibility between apollo-client and graphql-ws. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
Hey there! I dont quite understand by what you mean by "a single HTTP stream", can you elaborate a bit more on that? You can indeed use |
Beta Was this translation helpful? Give feedback.
-
"a single HTTP stream" passing Queries and Mutations over HTTP and Subscriptions over WebSockets. Your above example gives me the WebSocketLink to do that in the same ways as my Many thanks ! |
Beta Was this translation helpful? Give feedback.
-
Ah ok, I follow.
No, your example is not the same as suggested. Please remove the |
Beta Was this translation helpful? Give feedback.
-
@enisdenjo Yes that is what I was saying. Now I have attempted to implement what you said and came up with a compile time error :-
Here's a repo with the code :- https://github.com/AaronNGray/apollo-client-graphql-ws |
Beta Was this translation helpful? Give feedback.
-
I have a superficially working repo with commented out CloseEvent error case code, here :- https://github.com/AaronNGray/fullstack-apollo-graphql-ws-subscription-test |
Beta Was this translation helpful? Give feedback.
Ah ok, I follow.
No, your example is not the same as suggested. Please remove the
apollo-link-ws
library completely and implement the WebSocketLink as described in the "Client usage with Apollo" recipe, then use it to instantiate thewsLink
.