Suppose I have 3 datapoints in 3 separate subgraphs
Data Point A in "Subgraph 1"
Data Point B in "Subgraph 2"
Data Point C in "Subgraph 3"
A depends on B and C conditionally. There is another data point D in “Subgraph 1”, basis the value of datapoint D Subgraph 1 needs to fetch from B from Subgraph 2 or C from Subgraph 3.
How would I do this by doing minimal subgraph calls.
As of now, I have to make calls to Both Subgraph 2 and Subgraph 3 and pass the value D to them for taking the decision.
// Subgraph 1
type EntityHere @key (fields: "D"){
D: boolean
A: string @requires(fields: "B C") // both are required hence both subgraphs are called
B: string @external
C: string @external
}
// Subgraph 2
type EntityHere @key (fields: "D") {
D: boolean
B: string
}
// Subgraph 3
type EntityHere @key (fields: "D"){
D: boolean
C: string @external
}
As you can see in the above example, because A requires B and C both since there is no way to conditionally call them, both subgraphs are called, and the value of D is passed to them.
I have left out the implementation of resolvers to keep it simple. I can add it if needed.
I need a way to call the Subgraph 2 or Subgraph 3 conditionally so that I don’t have to unnecessarily scale up infra of one when another is supposed to receive major amount of traffic.