Skip to content

Commit ab32e7a

Browse files
authored
Add perf test (#312)
1 parent 52422a8 commit ab32e7a

File tree

3 files changed

+229
-193
lines changed

3 files changed

+229
-193
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"license": "MIT",
77
"type": "module",
88
"dependencies": {
9-
"@apollo/gateway": "^2.7.1",
9+
"@apollo/gateway": "^2.7.8",
1010
"clipanion": "^3.2.0-rc.13",
1111
"graphql": "^16.8.1",
1212
"graphql-request": "^4.3.0",
@@ -25,6 +25,7 @@
2525
"gql": "yarn graphql-codegen && yarn tsc -p studio/tsconfig.json",
2626
"dev": "node bin/index.js",
2727
"dev:example": "yarn dev --supergraph example/supergraph.graphql --operation example/operation.graphql",
28-
"dev:example:pretty": "yarn dev:example --pretty"
28+
"dev:example:pretty": "yarn dev:example --pretty",
29+
"dev:example:perf": "yarn dev --supergraph example/supergraph.graphql --operation example/operation.graphql --skipLog"
2930
}
3031
}

src/commands/default.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export class DefaultCommand extends Command {
2020

2121
sudo = Option.Boolean("--sudo");
2222

23+
skipLog = Option.Boolean("--skipLog");
24+
2325
async execute() {
2426
if (this.supergraph && this.graphref) {
2527
this.context.stderr.write(
@@ -43,6 +45,10 @@ export class DefaultCommand extends Command {
4345

4446
const queryPlan = await generateQueryPlan(result, operation);
4547

48+
if (this.skipLog) {
49+
return;
50+
}
51+
4652
if (this.pretty) {
4753
this.context.stdout.write(prettyFormatQueryPlan(queryPlan));
4854
} else {
@@ -63,7 +69,10 @@ export async function generateQueryPlan(supergraph, operationDoc, operationName)
6369
operationName,
6470
});
6571
const queryPlanner = new QueryPlanner(supergraph);
66-
return queryPlanner.buildQueryPlan(operation);
72+
console.time('Query Plan');
73+
const plan = queryPlanner.buildQueryPlan(operation);
74+
console.timeEnd('Query Plan');
75+
return plan;
6776
}
6877

6978
/**

0 commit comments

Comments
 (0)