-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure cost directives are picked up when not explicitly imported #6328
Draft
tninesling
wants to merge
15
commits into
dev
Choose a base branch
from
tninesling/cost-with-updated-composition
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+329
−468
Conversation
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
…directive name map to account for the new way cost directives are copied over to the supergraph in composition. This works for the supergraph, but currently fails on extracted subgraphs, likely because the cost link is not being carried over
… provided by the federation spec
…we always fall back to the federation spec when the cost spec is missing from the schema
…on takes schema instead
✅ Docs Preview ReadyNo new or changed pages found. |
CI performance tests
|
@tninesling, please consider creating a changeset entry in |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With the recent composition changes, importing
@cost
results in a supergraph schema with the cost specification import at the top. The@cost
directive itself is not explicitly imported, as it's expected to be available based on being the default export from the cost specification. In contrast, uses of@listSize
to translate to an explicit import in the supergraph.This exposed the brittle initial implementation of cost directive handling, which built up a map of directive name aliases from import statements. The core change made to address this issue is to remove the directive name map and replace it with calls to
SpecDefinition::directive_name_in_schema
, which is equivalent to the change we made on the composition side.The fallout from this is that we need access to a
FederationSchema
, which is private to theapollo-federation
package. I've pushed the cost directive parsing logic into theCostSpecDefinition
to abstract away the import name aliasing while cutting down on the public surface area of the federation package. Now, the consuming plugin can simply pass in a schema and a field to get the relevant directive information.Checklist
Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.
Exceptions
Note any exceptions here
Notes
Footnotes
It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this. ↩
Configuration is an important part of many changes. Where applicable please try to document configuration examples. ↩
Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions. ↩