Skip to content

Commit

Permalink
fix(client): prevent double serialization of operations for websockets
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
james-pellow committed Nov 23, 2023
1 parent baf555e commit 8b9a2b2
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8b9a2b2

Please sign in to comment.