Skip to content
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

Modify type of argument of @requiresScope #2738

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .changeset/great-lions-work.md
Original file line number Diff line number Diff line change
@@ -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.

6 changes: 3 additions & 3 deletions composition-js/src/__tests__/compose.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
`);
});

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]!\"",
]);
});

Expand Down
2 changes: 1 addition & 1 deletion internals-js/src/requiresScopesSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}],
Expand Down