-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allows passing the list of supported features when building a supergr…
…aph (#2656) When we parse/build a supergraph, one validation run checks that any feature in the supergraph marked for `EXECUTION` or `SECURITY` is actually supported. But the list of what was supported was currently completely hard-coded, and that means for instance that external use of the query planner (like in the Apollo router typically) could not modify this list of supported features. This commit allows that list to be provided (and default to the hard-coded one if not). Now, passing that list down to the validation that use it was not very convenient in the existing code. Taking the query planner as an example, it was taking the supergraph as argument as a `Schema` but the validation was then done somewhere within the code of the planner. Passing the list of supported options, so it can then be passed down to the relevant code, was technically possible, but it would have been a bit ugly, because 1) the query planner is one example, but supergraphs could be use elsewhere and 2) that list of supported feature isn't really a property of the planner (which mostly doesn't care), so passing it as a planner option is not too clean. So most of this commit is really a small refactor to introduce a `Supergraph` class, to essentially warp a schema that is known to be a supergraph schema. Places that expect a supergraph as argument now use `Supergraph` instead of just `Schema`. I'd argue that this refactor make sense regardless of the final goal of this issue for at least 2 reasons: 1. this provided nice symmetry with the `Subgraph` class we have had for a long time for very similar reasons. 2. it's a better use of the type system. Now that the query planner take a `Supergraph` instance, it's extra clear what the argument is, and if multiple methods take that instance, they know for a fact that the underlying schema is a valid supergraph and they don't have to defensively check it again.
- Loading branch information
Sylvain Lebresne
authored
Jul 10, 2023
1 parent
2b5796a
commit db90ba1
Showing
17 changed files
with
143 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
composition-js/src/__tests__/supergraph_reversibility.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.