From 8b9a2b2a932cf25644e970c24f847679ba07e6fc Mon Sep 17 00:00:00 2001 From: James Pellow Date: Wed, 22 Nov 2023 16:29:11 -0800 Subject: [PATCH] fix(client): prevent double serialization of operations for websockets The commit resolves an issue where operations for websockets were being serialized twice when using the "graphql-transport-ws" protocol. This fix removes the redundant serialization step, aligning the process with expected behavior and improving efficiency. --- .../lib/src/links/websocket_link/websocket_client.dart | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/graphql/lib/src/links/websocket_link/websocket_client.dart b/packages/graphql/lib/src/links/websocket_link/websocket_client.dart index 1809cd65..52d754c2 100644 --- a/packages/graphql/lib/src/links/websocket_link/websocket_client.dart +++ b/packages/graphql/lib/src/links/websocket_link/websocket_client.dart @@ -576,15 +576,17 @@ class SocketClient { .listen((message) => response.addError(message)); if (!_subscriptionInitializers[id]!.hasBeenTriggered) { - GraphQLSocketMessage operation = StartOperation( - id, - serialize(payload), - ); + GraphQLSocketMessage operation; if (protocol == GraphQLProtocol.graphqlTransportWs) { operation = SubscribeOperation( id, serialize(payload), ); + } else { + operation = StartOperation( + id, + serialize(payload), + ); } _write(operation); _subscriptionInitializers[id]!.hasBeenTriggered = true;