You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR adds `@link` validations to detect invalid alias names and alias/import conflicts. To maintain backwards compatibility, we do allow some exceptions, and we also auto-generate supergraph spec aliases when conflicts are detected.
Add validations for `@link` usages to prevent name conflicts.
6
+
7
+
This change helps to avoid ambiguity for downstream `@link`-consuming code, which previously may have found different results for a spec schema element depending on search order. If your composition fails after this change, please rename conflicting elements via `@link(import:)` and conflicting specs/features via `@link(as:)`.
8
+
9
+
Note that if you were declaring `@link`s for the `https://specs.apollo.dev/tag` or `https://specs.apollo.dev/inaccessible` specs in your subgraph schema, you will need to instead import `@tag` and `@inaccessible` from the `https://specs.apollo.dev/federation` spec. This previous pattern only succeeded due to a now-fixed bug and is fragile/may lead to undesirable behavior.
`Directive "${directive}" in subgraph "subgraphA" cannot be composed because it is not a member of a core feature`,
878
+
'INVALID_LINK_DIRECTIVE_USAGE',
879
+
`Cannot import "@foo" as "${directive}" from feature "https://specs.apollo.dev/foo" since it can be confused with a namespaced name from another linked feature "https://specs.apollo.dev/join". Please rename the import or feature to avoid conflicts via "as".`,
it('errors when trying to use supergraph tag spec',()=>{
361
+
constsubgraphA={
362
+
typeDefs: gql`
363
+
schema
364
+
@link(url: "https://specs.apollo.dev/link/v1.0")
365
+
@link(url: "https://specs.apollo.dev/tag/v0.2")
366
+
{
367
+
query: Query
368
+
}
369
+
370
+
type Query {
371
+
q: Int
372
+
}
373
+
`,
374
+
name: 'subgraphA',
375
+
};
376
+
377
+
constresult=composeServices([subgraphA]);
378
+
379
+
expect(result.errors).toBeDefined();
380
+
expect(errors(result)).toStrictEqual([
381
+
['INVALID_LINK_DIRECTIVE_USAGE','[subgraphA] Please import "@tag" from the feature "https://specs.apollo.dev/federation" instead of using "https://specs.apollo.dev/tag" to avoid potential unexpected behavior in the future.'],
382
+
]);
383
+
});
384
+
385
+
it('errors when trying to use supergraph inaccessible spec',()=>{
['INVALID_LINK_DIRECTIVE_USAGE','[subgraphA] Please import "@inaccessible" from the feature "https://specs.apollo.dev/federation" instead of using "https://specs.apollo.dev/inaccessible" to avoid potential unexpected behavior in the future.'],
0 commit comments