Closed krejko closed 1 year ago
You don't need a dependency on graphql, gql_websocket_link provides the link you need
But if you want to use a link from the graphql package, you can add a dependency override on normalize
Thank you, trying the gql_websocket_link package now instead of graphql 🙏
gql_wbsocket_link
package does solve the error around the missing WebSocketLink class. However, I am unsure how to use this link with my client. In the linked graphql documentation they do something like
/// subscriptions must be split otherwise `HttpLink` will. swallow them
if (websocketEndpoint != null){
final _wsLink = WebSocketLink(websockeEndpoint);
_link = Link.split((request) => request.isSubscription, _wsLink, _link);
}
However, the request object doesn't have a isSubscription property or method. Is the idea that I'd have two different clients with Ferry; one for HTTP and another for WS? Or is there some other way run the above check?
There very well may be a better way to do this, but possibly something like this would work in the short-term:
final link = Link.split((request) {
return request.operation
.toString()
.toLowerCase()
.contains("subscription");
}, wsLink, httpLink);
yes, there are better ways which are not documented at the moment. see:
Thank you. This has been extremely helpful.
I am trying to follow the examples linked to in this issue: https://github.com/gql-dart/ferry/issues/387
However, this appears to require the GraphQL flutter package in order to have access to the WebSocketLink class.
Whenever I run
flutter pub add graphql
to get this package, I get the following error:It would seem as though Ferry has updated past the point where it can still be used with the GraphQL flutter library. Is there anything that can be done on my end to get past this issue, or based on this are subscriptions now unavailable when using Ferry?
Any help would be appreciated. Thanks!