Skip to content

Commit

Permalink
Merge pull request #1410 from aarsham/fix-null-check
Browse files Browse the repository at this point in the history
Address null check error and prevent duplicate events on socket reconnect
  • Loading branch information
vincenzopalazzo authored Apr 8, 2024
2 parents eebac38 + acdaabc commit 385c331
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/graphql/lib/src/core/fetch_more.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ Future<QueryResult<TParsed>> fetchMoreImplementation<TParsed>(
final data = fetchMoreOptions.updateQuery(
previousResult.data,
fetchMoreResult.data,
)!;
);

fetchMoreResult.data = data;

if (originalOptions.fetchPolicy != FetchPolicy.noCache) {
if (originalOptions.fetchPolicy != FetchPolicy.noCache && data != null) {
queryManager.attemptCacheWriteFromClient(
request,
data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@ class SocketClient {
}

void onConnectionLost([Object? e]) async {
var code = socketChannel!.closeCode;
var reason = socketChannel!.closeReason;
var code = socketChannel?.closeCode;
var reason = socketChannel?.closeReason;

await _closeSocketChannel();
if (e != null) {
Expand Down Expand Up @@ -502,6 +502,7 @@ class SocketClient {
)
: waitForConnectedStateWithoutTimeout;

sub?.cancel();
sub = waitForConnectedState.listen((_) {
final Stream<GraphQLSocketMessage> dataErrorComplete = _messages.where(
(GraphQLSocketMessage message) {
Expand Down

0 comments on commit 385c331

Please sign in to comment.