Skip to content

Commit 90a56c9

Browse files
[AT-36] Improve client:check output (#934)
Improve client:check output * Update language server to replace checkOperations with validateOperations mutation. * Leverage new mutation from the CLI to provide file specific data for validation errors. * Display messages grouped by query, with a clickable link to each query * Update CHANGELOG
1 parent 0b22a57 commit 90a56c9

6 files changed

Lines changed: 285 additions & 85 deletions

File tree

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
"node_modules": false,
1313
"lib": true
1414
},
15-
"typescript.tsdk": "node_modules/typescript/lib"
15+
"typescript.tsdk": "node_modules/typescript/lib",
16+
"debug.node.autoAttach": "on"
1617
}

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
- `apollo`
66
- Fix configuration loading and schema tag support [#925](https://github.com/apollographql/apollo-tooling/pull/925)
7+
- Improve client:check output [#934](https://github.com/apollographql/apollo-tooling/pull/934)
8+
- `apollo-language-server`
9+
- Replace checkOperations mutation with new validateOperations mutation [#934](https://github.com/apollographql/apollo-tooling/pull/934)
710

811
## `apollo@2.3.1`
912

packages/apollo-language-server/src/engine/index.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import {
1010
} from "./operations/uploadSchema";
1111

1212
import {
13-
CHECK_OPERATIONS,
14-
CheckOperationsVariables
15-
} from "./operations/checkOperations";
13+
VALIDATE_OPERATIONS,
14+
ValidateOperationsVariables,
15+
ValidationResult
16+
} from "./operations/validateOperations";
1617

1718
import {
1819
REGISTER_OPERATIONS,
@@ -161,8 +162,8 @@ export class ApolloEngineClient extends GraphQLDataSource {
161162
});
162163
}
163164

164-
public async checkOperations(variables: CheckOperationsVariables) {
165-
return this.execute({ query: CHECK_OPERATIONS, variables }).then(
165+
public async validateOperations(variables: ValidateOperationsVariables) {
166+
return this.execute({ query: VALIDATE_OPERATIONS, variables }).then(
166167
({ data, errors }) => {
167168
if (data && !data.service) {
168169
throw new Error(
@@ -176,7 +177,9 @@ export class ApolloEngineClient extends GraphQLDataSource {
176177
if (!data) {
177178
throw new Error("Error in request from Engine");
178179
}
179-
return data.service.checkOperations;
180+
181+
return data.service.validateOperations
182+
.validationResults as ValidationResult[];
180183
}
181184
);
182185
}

packages/apollo-language-server/src/engine/operations/checkOperations.ts

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import gql from "graphql-tag";
2+
import { GitContextInput } from "./checkSchema";
3+
4+
export interface OperationDocument {
5+
body: string;
6+
name: string;
7+
}
8+
9+
export enum ValidationErrorType {
10+
WARNING = "WARNING",
11+
FAILURE = "FAILURE",
12+
INVALID = "INVALID"
13+
}
14+
15+
export enum ValidationErrorCode {
16+
NON_PARSEABLE_DOCUMENT = "NON_PARSEABLE_DOCUMENT",
17+
INVALID_OPERATION = "INVALID_OPERATION",
18+
DEPRECATED_FIELD = "DEPRECATED_FIELD"
19+
}
20+
21+
export interface ValidationResult {
22+
type: ValidationErrorType;
23+
code: ValidationErrorCode;
24+
description: string;
25+
operation: OperationDocument;
26+
}
27+
28+
export interface ValidateOperationsVariables {
29+
id: string;
30+
tag: string;
31+
gitContext: GitContextInput;
32+
operations: [OperationDocument];
33+
}
34+
35+
export const VALIDATE_OPERATIONS = gql`
36+
mutation ValidateOperations(
37+
$id: ID!
38+
$operations: [OperationDocumentInput!]!
39+
$tag: String
40+
$gitContext: GitContextInput
41+
) {
42+
service(id: $id) {
43+
validateOperations(
44+
tag: $tag
45+
operations: $operations
46+
gitContext: $gitContext
47+
) {
48+
validationResults {
49+
type
50+
code
51+
description
52+
operation {
53+
name
54+
}
55+
}
56+
}
57+
}
58+
}
59+
`;

0 commit comments

Comments
 (0)