Skip to content

Commit

Permalink
Update to Fed 2.6 (#267)
Browse files Browse the repository at this point in the history
* Update to latest Fed 2.6

* Remove account name
  • Loading branch information
smyrick authored Nov 29, 2023
1 parent 655309c commit 4c8a54b
Show file tree
Hide file tree
Showing 5 changed files with 883 additions and 855 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@
"check:tsc": "yarn tsc"
},
"dependencies": {
"@apollo/composition": "^2.5.7",
"@apollo/composition": "^2.6.1",
"@apollo/federation-1": "npm:@apollo/[email protected]",
"@apollo/federation-internals": "^2.5.7",
"@apollo/gateway": "^2.5.7",
"@apollo/query-planner": "^2.5.7",
"@apollo/federation-internals": "^2.6.1",
"@apollo/gateway": "^2.6.1",
"@apollo/query-planner": "^2.6.1",
"@apollo/query-planner-1": "npm:@apollo/[email protected]",
"@apollo/subgraph": "^2.5.7",
"@apollo/subgraph": "^2.6.1",
"@urql/core": "^2.6.0",
"cli-progress": "^3.11.2",
"clipanion": "^3.2.0-rc.11",
"fuzzy": "^0.1.3",
"graphql": "^16.5.0",
"graphql": "^16.8.1",
"inquirer": "^8.2.4",
"inquirer-autocomplete-prompt": "^2.0.0",
"jest-diff": "^28.1.1",
Expand Down
5 changes: 3 additions & 2 deletions src/federation/normalize-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ function visitQueryPlan(plan, visitor) {
*/
function recurse(node) {
const newNode = { ...node };
switch (newNode?.kind) {
const nodeKind = newNode?.kind;
switch (nodeKind) {
case 'Fetch':
if (visitor.Fetch) {
const result = visitor.Fetch(newNode);
Expand Down Expand Up @@ -63,7 +64,7 @@ function visitQueryPlan(plan, visitor) {
newNode.nodes = newNode.nodes.map((child) => recurse(child));
break;
default:
throw new Error('invalid node kind');
throw new Error(`Invalid query plan node kind: ${nodeKind}. This tool may need to update its Federation version. Please reach out to Apollo`);
}

return newNode;
Expand Down
20 changes: 19 additions & 1 deletion src/federation/normalize-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,26 @@ function visitQueryPlan(plan, visitor) {

newNode.nodes = newNode.nodes.map((child) => recurse(child));
break;
case 'Condition':
if (visitor.Condition) {
const result = visitor.Condition(newNode);
if (result !== undefined) {
newNode.condition = result.condition;
newNode.ifClause = result.ifClause;
newNode.elseClause = result.elseClause;
}
}
break;
case 'Defer':
if (visitor.Defer) {
const result = visitor.Defer(newNode);
if (result !== undefined) {
newNode.deferred = result.deferred;
}
}
break;
default:
throw new Error('invalid node kind');
throw new Error(`Invalid query plan node kind: ${newNode?.kind}. This tool may need to update its Federation version. Please reach out to Apollo`);
}

return newNode;
Expand Down
4 changes: 4 additions & 0 deletions src/typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import {
FlattenNode,
ParallelNode,
SequenceNode,
ConditionNode,
DeferNode,
} from '@apollo/query-planner';
import {
FetchNode1,
Expand Down Expand Up @@ -55,6 +57,8 @@ interface QueryPlanVisitor2 {
Flatten?: (node: FlattenNode) => FlattenNode | undefined;
Parallel?: (node: ParallelNode) => ParallelNode | undefined;
Sequence?: (node: SequenceNode) => SequenceNode | undefined;
Condition?: (node: ConditionNode) => ConditionNode | undefined;
Defer?: (node: DeferNode) => DeferNode | undefined;
}

interface QueryPlanVisitor1 {
Expand Down
Loading

0 comments on commit 4c8a54b

Please sign in to comment.