Closed hamzablx195 closed 2 years ago
This is the reason of your null value
facing same issue!!!!
@vincenzopalazzo facing same issue with WebSocketLink
@dhruvinwebelight @hamzablx195 can you please try your code with subProtocol: SocketSubProtocol.graphqlWs
there is a collision name here
This is the reason https://github.com/zino-hofmann/graphql-flutter/pull/1180
Hey @vincenzopalazzo , tried SocketSubProtocol.graphqlWs. Still it wont work and keeps returning null on the subscription result.
Sorry I made a typo, I mean if you want try with SocketSubProtocol.graphqlTransportWs
that is the new protocol, I get the correct data back, on my demo that I'm preparing for integration testing
Still no luck. It keeps returning the same result. I went through these protocols earlier as well. Can you please share the example that you're using?
Sure this is the example: https://github.com/zino-hofmann/graphql-flutter/tree/macros/chat_example/packages/graphql_flutter/example/graphql_chat
And this is the Apollo Server https://github.com/vincenzopalazzo/keep-safe-graphql
This needs to investigate but please fix your example because it is completely normal that you have null in the data if you are using the wrong protocol
Keeping alive for a bit
Sure this is the example: https://github.com/zino-hofmann/graphql-flutter/tree/macros/chat_example/packages/graphql_flutter/example/graphql_chat
And this is the Apollo Server https://github.com/vincenzopalazzo/keep-safe-graphql
This needs to investigate but please fix your example because it is completely normal that you have null in the data if you are using the wrong protocol
I tried the graphql_chat repo you shared. The subscription still don't work. New updates on the subscription are not received in both, the graphql implementation & the flutter_graphql implementation.
When configured, the first read is successful now, it gets the latest value once. But if I trigger mutations on the apollo-server attached, I don't receive any updates on this subscription.
I tried the graphql_chat repo you shared. The subscription still don't work. New updates on the subscription are not received in both, the graphql implementation & the flutter_graphql implementation. When configured, the first read is successful now, it gets the latest value once. But if I trigger mutations on the apollo-server attached, I don't receive any updates on this subscription.
Can you reach me on discord? we can try track this!
I found the bug, is how you create the link!
Please use the static method provided by the Link Library
final Link link = Link.split(
(request) => request.isSubscription,
wsLink,
httpLink,
);
Perfect, yes that was it. Thank you so much for your time and effort!!
Lovely!
Hello, I used your code and the subscription is still returning null, but I noticed a successive disconnection after using
final Link link = Link.split(
(request) => request.isSubscription,
wsLink,
httpLink,
);
Console log:
Initialising connection
Disconnected from websocket.
I am using graphql_flutter: 5.1.2 Any hints? Thank you.
Hello @BS-Wissem,
Please use the latest beta version of the plugin available, and update the subProtocol in SocketConfig:
instead of
subProtocol: SocketSubProtocol.graphqlWs,
add
subProtocol: GraphQLProtocol.graphqlTransportWs,
This should resolve the issue. Hope this works for you as well.
Hello @malik19995 , Thanks so much it worked for version 5.1.2 and 5.1.1-beta.5.
The definition for the GraphQL Client is integrated into the code. Just trying to hook up the Subscription widget as provided by graphQL flutter.
The Query and Mutations work fine with the graphql endpoint. This is a public endpoint. We don't have any authorisation headers.
With the Subscription operation, the value being returned is always null and it is not listening to any updates.
Package version: graphql_flutter: ^5.1.1-beta.3
To Reproduce Sample Main file::
The Subscription operation keeps returning null value.
Expected behavior A listener to work properly as it does with the exposed apollo client on the server.
device / execution context Tested on Android physical and emulated devices.
Other useful/optional fields
Please fill or delete these sections if you don't fill them in
Query Result Response as received by the subscription.
Stacktrace:
```dart { QueryResult(source: QueryResultSource.network, data: {numberIncremented: null}, context: Context({ResponseExtensions: Instance of 'ResponseExtensions', HttpLinkResponseContext: Instance of 'HttpLinkResponseContext'}), exception: null, timestamp: 2022-06-16 02:27:51.565108)} ```What backend are you trying to use? We have a node express instance configured with graphql and ws on AWS ec2.
If you have a network issue, does your operation work with GraphiQL? We tried an implementation based on graphiQL and that worked with our Subscription client.