Skip to content

Commit

Permalink
fix: serialize to string
Browse files Browse the repository at this point in the history
  • Loading branch information
izatop committed Sep 14, 2021
1 parent 5977fd1 commit daf7c7b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/ws/src/Connection/ClientConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export class ClientConnection extends ClientConnectionAbstract<string> {
return payload.toString("utf-8");
}

protected serialize(payload: string): Buffer {
return Buffer.from(payload);
protected serialize(payload: string): string {
return payload;
}

}
2 changes: 1 addition & 1 deletion packages/ws/src/Connection/ClientConnectionAbstract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export abstract class ClientConnectionAbstract<T> implements IClientConnection<T
return asyncCallback[Symbol.asyncIterator]();
}

protected abstract serialize(payload: T): Buffer;
protected abstract serialize(payload: T): string | Buffer;

protected abstract parse(payload: Buffer): T;
}
4 changes: 2 additions & 2 deletions packages/ws/src/Protocol/GQL/GQLClientConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class GQLClientConnection extends ClientConnectionAbstract<GQLOperationMe
return JSON.parse(payload.toString("utf-8"));
}

protected serialize(payload: GQLOperationMessage): Buffer {
return Buffer.from(JSON.stringify(payload));
protected serialize(payload: GQLOperationMessage): string {
return JSON.stringify(payload);
}
}

0 comments on commit daf7c7b

Please sign in to comment.