Hey all.
We currently have multiple micro services each implementing grpc services.
Each service has external and internal api.
We have come to a point where we need to consolidate requests from several microservices in order to display it properly on the frontend (we use grpc-web, if that matters). Up until this point the frontend would communicate with each service's external api, and it would be difficult to consolidate responses from several services.
The pattern that immediately comes up is the "backend for frontend" (
https://microservices.io/patterns/apigateway.html). This seems great. However it seems to require us to duplicate all our proto messages. Because the BFF is supposed to "stand on its own" and provide full api. In most cases it just forwards requests to underlying services, in some, it queries multiple services and builds a consolidated response.
It's a bummer duplicating the same proto messages accross several microservices.
How would you guys handle this issue?
Say I have
message Product {
string name;
string id;
}
which is produced by the ProductService
The BFF may have an API called GetProductsWithOwners which essentially could be
message Product {
string name;
string id;
string owner;
}
you get the point.. duplication.. especially when you have complex structures it starts to be hell.
Anyone using this pattern? How do you manage the proto files?
Thanks in advance.