Compound models at API gateway


#1

Hi there!
In your project there is clear separation in controllers according to a domain objects. But what if some view in UI needs information of 2+ objects? Whats is the correct way of providing such behavior? I see such solutions:

  • Send N queries from UI and add custom logic on front end
  • Create view models on API Gateway level, call several services and return ready objects to the UI

What’s your opinion on that case?


#2

Ideally, you want your microservice to return the required data model. However, if it’s not possible, you should probably send the multiple requests from the API Gateway to the different services, and eventually, aggregate them into the desired model.