You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a React application that uses msw.js for mocking requests. I'm able to to knock simple responses by serializing proto message. However things are getting complicating when the response is stream and I'm unable to find any method which would be helpful to serialize array of objects to binary which I could use as response body.
Do you know how I can serialize objects to stream?
For reference proto file looks like this.
syntax = "proto3"
message Point {
int32 latitude = 1;
int32 longitude = 2;
}
service RouteGuide {
rpc streamPoints() returns (stream Point) {}
}
The text was updated successfully, but these errors were encountered:
I assume you're using gRPC-web? It encodes messages and final trailers in the response body with a simple framing described in the spec.
protobuf-ts implements reading messages and a final trailer from a response body (here), but it only implements encoding a single message for a request body (here), because that's the only required case for clients.
To mock a gRPC-web response with MSW, a couple of parts are missing:
encoding trailers following the spec, with at least grpc-status and grpc-message fields
encoding 0 or more messages to support unary and server-streaming RPCs
conditionally base64 encoding the body based on the request content-type (only for the gRPC-web text encoding)
I do not have the spare time to implement those parts, but with a bit of patience, it's definitely doable 🙂
Hello!
I have a React application that uses msw.js for mocking requests. I'm able to to knock simple responses by serializing proto message. However things are getting complicating when the response is stream and I'm unable to find any method which would be helpful to serialize array of objects to binary which I could use as response body.
Do you know how I can serialize objects to stream?
For reference proto file looks like this.
The text was updated successfully, but these errors were encountered: