ThreeMammals / Ocelot

.NET API Gateway
https://www.nuget.org/packages/Ocelot
MIT License
8.4k stars 1.64k forks source link

Chain requests #549

Closed matheuswanted closed 6 years ago

matheuswanted commented 6 years ago

Hello!

I would like your help on a situation we are having here.

We have are developing a feature were our front-end app will need to access two resources in our API to process some data, let's say Resource A and Resource B. In this case Resource A loads some information that Resource B process, is it possible to Ocelot expose one url that chain the requests to Resource A and then Resource B?

I'm asking it because I didn't find a gateway able to do it, and I'm not sure it should be gateway responsibility. What do you think?

TomPallister commented 6 years ago

@matheuswanted thanks for your interest in the project. This is not currently possible with Ocelot. I would suggest either using something like GraphQL to do this logic and put Ocelot in front of that if you still want to use any of Ocelot's features.

ltouro commented 6 years ago

I think you are talking about API aggregation / composition. see here. These scenarios are very specific and implementation-heavy, making it hard to cross-cut. Can't see how one would use a declarative model to represent the agregation needed. My guess is that you need another resource to act as the aggregator in this case.

Just for the sake of discussion, take a look at one example of api aggregator. it basicly let one hook up a script to make the aggregation. This will make sense if you have a lot of aggregations to do. If is just one, guess you should let it be the resource c, client of a and b.

matheuswanted commented 6 years ago

Thanks @TomPallister and @ltouro I'll give a look into graphQL and nginx

But indeed I was talking about API aggregation. It would be good to have a way to configure a chain of requests to avoid scripting or programming it like the example of @ltouro. We also thought in making a http request inside the definedAggregator but it would break his responsibility.

thanks for your help :)

TomPallister commented 6 years ago

OK cool, Yeh I think you need another service for aggregation :) hope thats OK! Let me know if you want to reopen this.