Given a subgraph that contains order information including a product id for each product that is in the order, and a separate subgraph that contains a list of images and their appropriate product ids. These are served by a supergraph.
The order subgraph contains a list of products for a given order and will have a list of product ids.
I need to return an order and it’s related product images.
This is likely to cause a huge number of calls because for each product in an order it will hit the images subgraph to find the appropriate matching image. So if an order contains 10 products, it will hit the images subgraph 10 times to fetch the 10 matching images.
In an attempt to resolve this we have tailored the images subgraph so you can specify X product ids in a single delimited query: 12,123,1234,12345 etc.
Is there a way to make this performant? I’ve looked through the docs but am unclear how we can avoid such a large number of queries.
My idea was to pull a given order from the subgraph, and then using javascript pull all the product ids out of that response and then hit the images subgraph using the (above mentioned query) that allows for a query based off X delimited product ids to try and make it just one query. But this feels like an antipattern, as I’d likely need to invoke axios or something to hit the other subgraph.
I’m not sure how this is supposed to work when using subgraph, or if I’m going down the wrong route entirely.
Any help would be much appreciated.
Thank you