Skip to content

Commit ad6050a

Browse files
committed
apollo: add debug statements to service:check
Currently there isn't an easy way to determine the variables sent to engine by the apollo service:check command. This adds the ability to turn on debug mode and print out those commands. In order to show the statements, run `DEBUG=* apollo service:check` add changelog entry
1 parent 41332fa commit ad6050a

2 files changed

Lines changed: 23 additions & 14 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Upcoming
44

55
- `apollo`
6-
- <First `apollo` related entry goes here>
6+
- Add service:check debuggability [#1250](https://github.com/apollographql/apollo-tooling/pull/1250)
77
- `apollo-codegen-core`
88
- <First `apollo-codegen-core` related entry goes here>
99
- `apollo-codegen-flow`

packages/apollo/src/commands/service/check.ts

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import { flags } from "@oclif/command";
22
import { table } from "heroku-cli-util";
3-
import { introspectionFromSchema } from "graphql";
3+
import { introspectionFromSchema, printSchema } from "graphql";
44
import chalk from "chalk";
5-
import { gitInfo, GitContext } from "../../git";
5+
import { gitInfo } from "../../git";
66
import { ProjectCommand } from "../../Command";
77
import { validateHistoricParams } from "../../utils";
88
import {
99
CheckSchema_service_checkSchema,
1010
CheckSchema_service_checkSchema_diffToPrevious_changes as Change,
11-
ChangeSeverity
11+
ChangeSeverity,
12+
CheckSchemaVariables
1213
} from "apollo-language-server/lib/graphqlTypes";
1314
import { ApolloConfig } from "apollo-language-server";
1415
import moment from "moment";
@@ -268,18 +269,26 @@ export default class ServiceCheck extends ProjectCommand {
268269
});
269270

270271
task.output = "Validating schema";
272+
const variables: CheckSchemaVariables = {
273+
id: configName,
274+
// @ts-ignore
275+
// XXX Looks like TS should be generating ReadonlyArrays instead
276+
schema: introspectionFromSchema(schema).__schema,
277+
tag: flags.tag,
278+
gitContext: await gitInfo(this.log),
279+
frontend: flags.frontend || config.engine.frontend,
280+
...(historicParameters && { historicParameters })
281+
};
282+
const { schema: _, ...restVariables } = variables;
283+
this.debug("Variables sent to Engine:");
284+
this.debug(restVariables);
285+
this.debug("SDL of introspection sent to Engine:");
286+
this.debug(printSchema(schema));
271287

272288
const newContext: typeof ctx = {
273-
checkSchemaResult: await project.engine.checkSchema({
274-
id: configName,
275-
// @ts-ignore
276-
// XXX Looks like TS should be generating ReadonlyArrays instead
277-
schema: introspectionFromSchema(schema).__schema,
278-
tag: flags.tag,
279-
gitContext: await gitInfo(this.log),
280-
frontend: flags.frontend || config.engine.frontend,
281-
...(historicParameters && { historicParameters })
282-
}),
289+
checkSchemaResult: await project.engine.checkSchema(
290+
variables
291+
),
283292
config,
284293
shouldOutputJson: !!flags.json,
285294
shouldOutputMarkdown: !!flags.markdown

0 commit comments

Comments
 (0)