Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 15 additions & 19 deletions packages/apollo/src/commands/client/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@ type ValidationResult = graphqlTypes.ValidateOperations_service_validateOperatio
interface Operation {
body: string;
name: string;
relativePath: string;
locationOffset: LocationOffset;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

locationOffset didn't seem useful, as far as I could tell it was always 1

}
interface LocationOffset {
column: number;
line: number;
relativePaths: string[];
}

export default class ClientCheck extends ClientCommand {
Expand All @@ -48,15 +43,18 @@ export default class ClientCheck extends ClientCommand {

ctx.operations = Object.entries(
this.project.mergedOperationsAndFragmentsForService
).map(([name, doc]) => ({
body: print(doc),
name,
relativePath: relative(
config.configURI ? config.configURI.fsPath : "",
URI.parse(doc.definitions[0].loc!.source.name).fsPath
),
locationOffset: doc.definitions[0].loc!.source.locationOffset
}));
).map(
([name, doc]): Operation => ({
body: print(doc),
name,
relativePaths: doc.definitions.map(definition =>
relative(
config.configURI ? config.configURI.fsPath : "",
URI.parse(definition.loc!.source.name).fsPath
)
)
})
);

ctx.validationResults = await project.engine.validateOperations({
id: config.graph,
Expand Down Expand Up @@ -146,10 +144,8 @@ export default class ClientCheck extends ClientCommand {
validationResults: ValidationResult[];
operation: Operation;
}) => {
const { name, locationOffset, relativePath } = operation;
this.log(
`${name}: ${chalk.cyan(`${relativePath}:${locationOffset.line}`)}\n`
);
const { name, relativePaths } = operation;
this.log(`${name}: ${chalk.cyan(`${relativePaths.join(",")}`)}\n`);

const byErrorType = validationResults.reduce(
(byError, validation) => {
Expand Down