Skip to content

Commit

Permalink
Add perf test (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
smyrick authored May 24, 2024
1 parent 52422a8 commit ab32e7a
Show file tree
Hide file tree
Showing 3 changed files with 229 additions and 193 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "MIT",
"type": "module",
"dependencies": {
"@apollo/gateway": "^2.7.1",
"@apollo/gateway": "^2.7.8",
"clipanion": "^3.2.0-rc.13",
"graphql": "^16.8.1",
"graphql-request": "^4.3.0",
Expand All @@ -25,6 +25,7 @@
"gql": "yarn graphql-codegen && yarn tsc -p studio/tsconfig.json",
"dev": "node bin/index.js",
"dev:example": "yarn dev --supergraph example/supergraph.graphql --operation example/operation.graphql",
"dev:example:pretty": "yarn dev:example --pretty"
"dev:example:pretty": "yarn dev:example --pretty",
"dev:example:perf": "yarn dev --supergraph example/supergraph.graphql --operation example/operation.graphql --skipLog"
}
}
11 changes: 10 additions & 1 deletion src/commands/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export class DefaultCommand extends Command {

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

skipLog = Option.Boolean("--skipLog");

async execute() {
if (this.supergraph && this.graphref) {
this.context.stderr.write(
Expand All @@ -43,6 +45,10 @@ export class DefaultCommand extends Command {

const queryPlan = await generateQueryPlan(result, operation);

if (this.skipLog) {
return;
}

if (this.pretty) {
this.context.stdout.write(prettyFormatQueryPlan(queryPlan));
} else {
Expand All @@ -63,7 +69,10 @@ export async function generateQueryPlan(supergraph, operationDoc, operationName)
operationName,
});
const queryPlanner = new QueryPlanner(supergraph);
return queryPlanner.buildQueryPlan(operation);
console.time('Query Plan');
const plan = queryPlanner.buildQueryPlan(operation);
console.timeEnd('Query Plan');
return plan;
}

/**
Expand Down
Loading

0 comments on commit ab32e7a

Please sign in to comment.