diff --git a/.changeset/great-lions-work.md b/.changeset/great-lions-work.md new file mode 100644 index 000000000..0d0c8eb66 --- /dev/null +++ b/.changeset/great-lions-work.md @@ -0,0 +1,13 @@ +--- +"@apollo/composition": patch +"@apollo/federation-internals": patch +--- + +Modifies the type for the argument of the `@requiresScopes` from `[federation__Scope!]!` to `[[federation__Scope!]!]!`. + +The `@requiresScopes` directives has been pre-emptively introduced in 2.5.0 to support an upcoming Apollo Router +feature around scoped accesses. The argument for `@requiresScopes` in that upcoming feature is changed to accommodate a +new semantic. Note that this technically a breaking change to the `@requiresScopes` directive definition, but as the +full feature using that directive has been released yet, this directive cannot effectively be used and this should have +no concrete impact. + diff --git a/composition-js/src/__tests__/compose.test.ts b/composition-js/src/__tests__/compose.test.ts index a92320874..71c09d67e 100644 --- a/composition-js/src/__tests__/compose.test.ts +++ b/composition-js/src/__tests__/compose.test.ts @@ -4493,7 +4493,7 @@ describe('composition', () => { "https://specs.apollo.dev/requiresScopes/v0.1" ); expect(printDirectiveDefinition(result.schema.directive('requiresScopes')!)).toMatchString(` - directive @requiresScopes(scopes: [requiresScopes__Scope!]!) on FIELD_DEFINITION | OBJECT | INTERFACE | SCALAR | ENUM + directive @requiresScopes(scopes: [[requiresScopes__Scope!]!]!) on FIELD_DEFINITION | OBJECT | INTERFACE | SCALAR | ENUM `); }); @@ -4527,7 +4527,7 @@ describe('composition', () => { const invalidDefinition = { typeDefs: gql` scalar federation__Scope - directive @requiresScopes(scopes: [federation__Scope!]!) on ENUM_VALUE + directive @requiresScopes(scopes: [[federation__Scope!]!]!) on ENUM_VALUE type Query { a: Int @@ -4565,7 +4565,7 @@ describe('composition', () => { const result = composeAsFed2Subgraphs([invalidDefinition]); expect(errors(result)[0]).toEqual([ "DIRECTIVE_DEFINITION_INVALID", - "[invalidDefinition] Invalid definition for directive \"@requiresScopes\": argument \"scopes\" should have type \"[federation__Scope!]!\" but found type \"[federation__Scope]!\"", + "[invalidDefinition] Invalid definition for directive \"@requiresScopes\": argument \"scopes\" should have type \"[[federation__Scope!]!]!\" but found type \"[federation__Scope]!\"", ]); }); diff --git a/internals-js/src/requiresScopesSpec.ts b/internals-js/src/requiresScopesSpec.ts index f0bdb918a..2d0744eb3 100644 --- a/internals-js/src/requiresScopesSpec.ts +++ b/internals-js/src/requiresScopesSpec.ts @@ -41,7 +41,7 @@ export class RequiresScopesSpecDefinition extends FeatureDefinition { const scopeName = feature.typeNameInSchema(RequiresScopesTypeName.SCOPE); const scopeType = schema.type(scopeName); assert(scopeType, () => `Expected "${scopeName}" to be defined`); - return new NonNullType(new ListType(new NonNullType(scopeType))); + return new NonNullType(new ListType(new NonNullType(new ListType(new NonNullType(scopeType))))); }, compositionStrategy: ARGUMENT_COMPOSITION_STRATEGIES.UNION, }],