Conversation
|
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
|
dariuszkuc
left a comment
There was a problem hiding this comment.
Please add directive validations to FederationBlueprint#onValidation (link).
We should check whether tag value is provided (i.e. non-null string) and also whether it is a valid selection (for dynamic values).
duckki
left a comment
There was a problem hiding this comment.
I think the best way to add @cacheTag was
- to make it a federation directive (no new link spec), but we need to bump up the federation version.
- to use
@join__directivein supergraph (this was already the case). - But, this combination was not a paved path. So, I implemented some paving for it.
I also added some subgraph validation tests (as a placeholder).
Sorry for pushing my commit without a prior discussion.
duckki
left a comment
There was a problem hiding this comment.
BTW, shall we rename cachekey.test.ts to cachetag.test.ts?
|
I'm ok with deferring validation to a separate PR (& Jira ticket) so that the router implementation can be unblocked. |
|
BTW this PR should be targeting the |
Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
- bumped up the federation version to 2.12 - added some subgraph validation tests - paved a path to merge any federation directives using `@join__directive` in supergraph
2319ce2 to
1959454
Compare
Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
|
Thanks a lot @duckki that's awesome ! I renamed the test file to cachetag instead of cachekey. What's missing now ? What are the next steps I could do to land this first PR ? |
…deration directives
|
BTW, we may not be able to merge into |
There was a problem hiding this comment.
Two things here:
- There's no way to easily determine whether a supergraph schema is using
cacheTag(you have to parse all@join__directivecalls to know). This means gateway won't know it should reject such supergraph schemas, as it currently relies on checking for specs it knows (similar story if router wanted to check for entitlements/rate limits). The simplest way to fix this is to add acacheTagspec to the supergraph schema. It doesn't necessarily need any directives in it, and can be just a marker spec; that's currently what theconnectspec means in supergraph schemas, IIRC. - The pre-PR/existing implementation for
addJoinDirectiveDirectives()has several things wrong with it. That may have been fine for connectors, but if we're going to use@join__directivemore generally, we should fix the issues.- It currently relies on
schemaToImportNameToFeatureUrl, which is computed bycomputeMapFromImportNameToIdentityUrl(). This function doesn't account for default-named directives, e.g.@federation__cacheTag, only imported ones. It should really be usingSchema.coreFeatures, specifically theCoreFeatures.sourceFeature()function, which already accounts for this. - It checks
directive.namedirectly againstlink, but it should really be checking against what the link's name in the subgraph schema is. - It's re-parsing each
@link's information, when it should really just useSchema.coreFeatures. - For some reason, the code thinks it's possible
directive.namecan start with@(the line withdirective.name.startsWith('@')), but it can't, and that part should be simplified.
- It currently relies on
I'd like to avoid adding a new supergraph spec link, since we have too many already. I wish there was a way to indicate the composition version in supergraph beyond the Having said that, in practice, older Router versions will fail to resolve
100% agreed. I'll address that. |
- to indicate the supergraph uses `@federation__cacheTag` directive (wrapped in `@join__directive`). - The @cacheTag itself is not directly used in supergraphs. - added `useJoinDirective` option for directive specifications, so spec link can be added in supergraph while directives are composed using `@join__directive`. - fixed feature url computation logic in `addJoinDirectiveDirectives` to use `Schema.coreFeatures`. - fixed link identity check logic in `addJoinDirectiveDirectives`.
8b9e769 to
461967c
Compare
… directive. - added cacheTag spec to the router supported spec list.
sachindshinde
left a comment
There was a problem hiding this comment.
Just some minor things to fix below, but after that it should be good to go!
| args = [], | ||
| composes = false, | ||
| supergraphSpecification = undefined, | ||
| useJoinDirective = undefined, |
There was a problem hiding this comment.
Since this is a boolean, you'll want
| useJoinDirective = undefined, | |
| useJoinDirective = false, |
here instead.
There was a problem hiding this comment.
I changed the DirectiveCompositionSpecification type definition to be non-nullable bool, so it's simpler/clearer.
But, I'd like to keep the useJoinDirective parameter optional for this function, while the default value was changed to false. Otherwise, all call sites need to be updated.
8c571e1 to
fc24723
Compare
Add support of
@cacheTagdirective.