zino-hofmann / graphql-flutter

A GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package.
https://zino-hofmann.github.io/graphql-flutter
MIT License
3.25k stars 620 forks source link

fix(graphql): send connection_init message during handshake #1145

Closed othorin closed 2 years ago

othorin commented 2 years ago

Describe the purpose of the pull request.

Fixes / Enhancements

The implementation of graphql-transport-ws fails on the first message as it's only sent if the connection controller is in the connected state. For this protocol, the state is instead set to handshake during the first _write().

https://github.com/zino-hofmann/graphql-flutter/blob/02be959597f0ffe0c21a227a2d1fdb02b3f56831/packages/graphql/lib/src/links/websocket_link/websocket_client.dart#L250-L256

Without this, the connection fails with the following log:

flutter: Initialising connection
flutter: There was an error causing connection lost: Bad state: No element
flutter: Disconnected from websocket.
codecov[bot] commented 2 years ago

Codecov Report

Merging #1145 (e6767f5) into main (02be959) will increase coverage by 4.86%. The diff coverage is 100.00%.

:exclamation: Current head e6767f5 differs from pull request most recent head 7d9b8d3. Consider uploading reports for the commit 7d9b8d3 to get more accurate results

@@            Coverage Diff             @@
##             main    #1145      +/-   ##
==========================================
+ Coverage   54.61%   59.48%   +4.86%     
==========================================
  Files          13       41      +28     
  Lines         249     1661    +1412     
==========================================
+ Hits          136      988     +852     
- Misses        113      673     +560     
Impacted Files Coverage Δ
...lib/src/links/websocket_link/websocket_client.dart 82.17% <100.00%> (ø)
...b/src/links/websocket_link/websocket_messages.dart 50.43% <0.00%> (ø)
...l/lib/src/links/websocket_link/websocket_link.dart 0.00% <0.00%> (ø)
packages/graphql/lib/src/cache/store.dart 100.00% <0.00%> (ø)
packages/graphql/lib/src/scheduler/scheduler.dart 4.16% <0.00%> (ø)
packages/graphql/lib/src/utilities/helpers.dart 91.30% <0.00%> (ø)
packages/graphql/lib/src/cache/cache.dart 79.06% <0.00%> (ø)
packages/graphql/lib/src/core/query_manager.dart 76.35% <0.00%> (ø)
packages/graphql/lib/src/cache/fragment.dart 20.45% <0.00%> (ø)
...graphql/lib/src/cache/_normalizing_data_proxy.dart 92.98% <0.00%> (ø)
... and 19 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 02be959...7d9b8d3. Read the comment docs.

othorin commented 2 years ago

Thank you!