diff --git a/.changeset/rich-tips-study.md b/.changeset/rich-tips-study.md deleted file mode 100644 index 1bc53bdc6..000000000 --- a/.changeset/rich-tips-study.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"@apollo/query-planner": patch -"@apollo/query-graphs": patch ---- - -Ignore non-resolvable keys when adding a subgraph jump for `@requires`/`@fromContext`. diff --git a/query-graphs-js/src/graphPath.ts b/query-graphs-js/src/graphPath.ts index 610065d2a..e37751028 100644 --- a/query-graphs-js/src/graphPath.ts +++ b/query-graphs-js/src/graphPath.ts @@ -1930,9 +1930,6 @@ export function getLocallySatisfiableKey(graph: QueryGraph, typeVertex: Vertex): assert(metadata, () => `Could not find federation metadata for source ${typeVertex.source}`); const keyDirective = metadata.keyDirective(); for (const key of type.appliedDirectivesOf(keyDirective)) { - if (!(key.arguments().resolvable ?? true)) { - continue; - } const selection = parseFieldSetArgument({ parentType: type, directive: key }); if (!metadata.selectionSelectsAnyExternalField(selection)) { return selection; diff --git a/query-planner-js/src/__tests__/buildPlan.test.ts b/query-planner-js/src/__tests__/buildPlan.test.ts index 2f59fbdd6..af995c066 100644 --- a/query-planner-js/src/__tests__/buildPlan.test.ts +++ b/query-planner-js/src/__tests__/buildPlan.test.ts @@ -2986,97 +2986,6 @@ describe('@requires', () => { } `); }); - - it('ignores non-resolvable keys when inserting self jump for @requires', () => { - const subgraph1 = { - name: 'A', - typeDefs: gql` - type Query { - t: T - } - - type T @key(fields: "id1", resolvable: false) @key(fields: "id2 id3") { - id1: ID! - id2: ID! - id3: ID! - req: Int @external - v: Int @requires(fields: "req") - } - `, - }; - - const subgraph2 = { - name: 'B', - typeDefs: gql` - type T @key(fields: "id1") { - id1: ID! - req: Int - } - `, - }; - - const [api, queryPlanner] = composeAndCreatePlanner(subgraph1, subgraph2); - const operation = operationFromDocument( - api, - gql` - { - t { - v - } - } - `, - ); - - const plan = queryPlanner.buildQueryPlan(operation); - expect(plan).toMatchInlineSnapshot(` - QueryPlan { - Sequence { - Fetch(service: "A") { - { - t { - __typename - id1 - id2 - id3 - } - } - }, - Flatten(path: "t") { - Fetch(service: "B") { - { - ... on T { - __typename - id1 - } - } => - { - ... on T { - req - } - } - }, - }, - Flatten(path: "t") { - Fetch(service: "A") { - { - ... on T { - __typename - req - id2 - id3 - } - } => - { - ... on T { - v - } - } - }, - }, - }, - } - `); - }); }); describe('fetch operation names', () => {