0

I was looking into apollo federation but was not able to deduce from a first scan of their docs if I will be able to respond from the router with union of responses from two different subgraphs.

For example, I have two responses from subgraph A=[1,4,6,2,9] and B=[5,3]. Now if I query for the first 5 entries, my router should return [1,2,3,4,5].

Can this kind of responses union be achieved using apollo federation? If not, is there any other preferred way to achieve this?

Example use case: Take the example of bank transactions. There are two types of txs: deposit and withdraw. I have a deposit service which keeps track of all the deposit txs and a withdraw service to keep track of all the withdraw txs. I want to implement a service in front of these two services which when queried for txs of a particular account number will return me both the deposit and withdraw txs in chronological order in a single array. Assuming deposit and withdraw services have their own graphQL interface, what tools can I use to build this gateway service in front of them?

zoid
  • 1
  • 2
  • Can you give an example of the kinds of queries you're hoping to execute, and what the corresponding subgraphs would look like? Federation tends to be a little more applicable when one subgraph refers to another subgraph's objects, or if you have different parts of the system providing the fields for a single object. – David Maze May 18 '23 at 01:09
  • @DavidMaze I've edited the question with my example use case. So if not federation, is there a standard tooling or way I can manage the result I want? I want the frontend's job to be as simple as possible. I don't want them to fetch from multiple apis and merge them on the frontend. – zoid May 18 '23 at 04:37

0 Answers0