enisdenjo / graphql-composite

MIT License
5 stars 0 forks source link

Resolve new resolver's variables from other subgraphs if not available in the current subgraph #48

Closed enisdenjo closed 2 weeks ago

enisdenjo commented 2 months ago

Closes #17

A resolver may require variables that are not available in the parent resolver, but instead need to be resolved elsewhere. In such cases, during the gather phase - a preceeding resolver will be created that fetches the necessary variables. This is done recursively so othat any additional variables will repeat the same process.

Note that we DO NOT nest the new resolver under the includes of the parent because there may be more than one variable that needs to be fetched from different subgraphs. If we were to nest, then this resolver would be duplicated for each additional resolver. Instead, we keep the resolvers flat and have the executor decide which ones go first.

Then, while resolving includes during execution the executor will inspect which exports are available and compare them to the necessary "select" variables. includes that have all "select" variables will be resolved first and inject the result to the export data. Finally, the remaining ones are recursively ensuring the same check.