vscode-apollo 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/.circleci/config.yml +1 -1
  2. package/.vscode/launch.json +4 -1
  3. package/CHANGELOG.md +27 -0
  4. package/package.json +9 -3
  5. package/renovate.json +2 -1
  6. package/sampleWorkspace/localSchema/src/test.js +3 -0
  7. package/sampleWorkspace/rover/apollo.config.js +3 -0
  8. package/sampleWorkspace/rover/src/test.graphql +14 -0
  9. package/sampleWorkspace/rover/src/test.js +30 -0
  10. package/sampleWorkspace/sampleWorkspace.code-workspace +25 -19
  11. package/src/language-server/__tests__/document.test.ts +161 -3
  12. package/src/language-server/__tests__/fixtures/TypeScript.tmLanguage.json +5749 -0
  13. package/src/language-server/__tests__/fixtures/documents/commentWithTemplate.ts +41 -0
  14. package/src/language-server/__tests__/fixtures/documents/commentWithTemplate.ts.snap +185 -0
  15. package/src/language-server/__tests__/fixtures/documents/functionCall.ts +93 -0
  16. package/src/language-server/__tests__/fixtures/documents/functionCall.ts.snap +431 -0
  17. package/src/language-server/__tests__/fixtures/documents/taggedTemplate.ts +80 -0
  18. package/src/language-server/__tests__/fixtures/documents/taggedTemplate.ts.snap +353 -0
  19. package/src/language-server/__tests__/fixtures/documents/templateWithComment.ts +38 -0
  20. package/src/language-server/__tests__/fixtures/documents/templateWithComment.ts.snap +123 -0
  21. package/src/language-server/config/__tests__/loadConfig.ts +19 -10
  22. package/src/language-server/config/config.ts +26 -1
  23. package/src/language-server/config/which.d.ts +19 -0
  24. package/src/language-server/document.ts +86 -53
  25. package/src/language-server/fileSet.ts +7 -0
  26. package/src/language-server/project/base.ts +58 -316
  27. package/src/language-server/project/client.ts +730 -7
  28. package/src/language-server/project/internal.ts +349 -0
  29. package/src/language-server/project/rover/DocumentSynchronization.ts +308 -0
  30. package/src/language-server/project/rover/__tests__/DocumentSynchronization.test.ts +302 -0
  31. package/src/language-server/project/rover/project.ts +276 -0
  32. package/src/language-server/server.ts +129 -62
  33. package/src/language-server/utilities/__tests__/source.test.ts +162 -0
  34. package/src/language-server/utilities/source.ts +38 -3
  35. package/src/language-server/workspace.ts +34 -9
  36. package/syntaxes/graphql.js.json +18 -21
  37. package/src/language-server/languageProvider.ts +0 -795
@@ -0,0 +1,353 @@
1
+ >// hint for reading the snapshots generated by this file:
2
+ #^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
3
+ # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts
4
+ >// it is important to check that a rule doesn't only enter `meta.embedded.block.graphql`
5
+ #^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
6
+ # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts
7
+ >// but also leaves it again
8
+ #^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
9
+ # ^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts
10
+ >
11
+ >declare function gql<A = any, B = any>(strings: TemplateStringsArray): void;
12
+ #^^^^^^^ source.ts meta.function.ts storage.modifier.ts
13
+ # ^ source.ts meta.function.ts
14
+ # ^^^^^^^^ source.ts meta.function.ts storage.type.function.ts
15
+ # ^ source.ts meta.function.ts
16
+ # ^^^ source.ts meta.function.ts meta.definition.function.ts entity.name.function.ts
17
+ # ^ source.ts meta.function.ts meta.type.parameters.ts punctuation.definition.typeparameters.begin.ts
18
+ # ^ source.ts meta.function.ts meta.type.parameters.ts entity.name.type.ts
19
+ # ^ source.ts meta.function.ts meta.type.parameters.ts
20
+ # ^ source.ts meta.function.ts meta.type.parameters.ts keyword.operator.assignment.ts
21
+ # ^ source.ts meta.function.ts meta.type.parameters.ts
22
+ # ^^^ source.ts meta.function.ts meta.type.parameters.ts support.type.primitive.ts
23
+ # ^ source.ts meta.function.ts meta.type.parameters.ts punctuation.separator.comma.ts
24
+ # ^ source.ts meta.function.ts meta.type.parameters.ts
25
+ # ^ source.ts meta.function.ts meta.type.parameters.ts entity.name.type.ts
26
+ # ^ source.ts meta.function.ts meta.type.parameters.ts
27
+ # ^ source.ts meta.function.ts meta.type.parameters.ts keyword.operator.assignment.ts
28
+ # ^ source.ts meta.function.ts meta.type.parameters.ts
29
+ # ^^^ source.ts meta.function.ts meta.type.parameters.ts support.type.primitive.ts
30
+ # ^ source.ts meta.function.ts meta.type.parameters.ts punctuation.definition.typeparameters.end.ts
31
+ # ^ source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.begin.ts
32
+ # ^^^^^^^ source.ts meta.function.ts meta.parameters.ts variable.parameter.ts
33
+ # ^ source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
34
+ # ^ source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts
35
+ # ^^^^^^^^^^^^^^^^^^^^ source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts entity.name.type.ts
36
+ # ^ source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.end.ts
37
+ # ^ source.ts meta.function.ts meta.return.type.ts keyword.operator.type.annotation.ts
38
+ # ^ source.ts meta.function.ts meta.return.type.ts
39
+ # ^^^^ source.ts meta.function.ts meta.return.type.ts support.type.primitive.ts
40
+ # ^ source.ts punctuation.terminator.statement.ts
41
+ >declare function foo<A = any, B = any>(strings: TemplateStringsArray): void;
42
+ #^^^^^^^ source.ts meta.function.ts storage.modifier.ts
43
+ # ^ source.ts meta.function.ts
44
+ # ^^^^^^^^ source.ts meta.function.ts storage.type.function.ts
45
+ # ^ source.ts meta.function.ts
46
+ # ^^^ source.ts meta.function.ts meta.definition.function.ts entity.name.function.ts
47
+ # ^ source.ts meta.function.ts meta.type.parameters.ts punctuation.definition.typeparameters.begin.ts
48
+ # ^ source.ts meta.function.ts meta.type.parameters.ts entity.name.type.ts
49
+ # ^ source.ts meta.function.ts meta.type.parameters.ts
50
+ # ^ source.ts meta.function.ts meta.type.parameters.ts keyword.operator.assignment.ts
51
+ # ^ source.ts meta.function.ts meta.type.parameters.ts
52
+ # ^^^ source.ts meta.function.ts meta.type.parameters.ts support.type.primitive.ts
53
+ # ^ source.ts meta.function.ts meta.type.parameters.ts punctuation.separator.comma.ts
54
+ # ^ source.ts meta.function.ts meta.type.parameters.ts
55
+ # ^ source.ts meta.function.ts meta.type.parameters.ts entity.name.type.ts
56
+ # ^ source.ts meta.function.ts meta.type.parameters.ts
57
+ # ^ source.ts meta.function.ts meta.type.parameters.ts keyword.operator.assignment.ts
58
+ # ^ source.ts meta.function.ts meta.type.parameters.ts
59
+ # ^^^ source.ts meta.function.ts meta.type.parameters.ts support.type.primitive.ts
60
+ # ^ source.ts meta.function.ts meta.type.parameters.ts punctuation.definition.typeparameters.end.ts
61
+ # ^ source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.begin.ts
62
+ # ^^^^^^^ source.ts meta.function.ts meta.parameters.ts variable.parameter.ts
63
+ # ^ source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
64
+ # ^ source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts
65
+ # ^^^^^^^^^^^^^^^^^^^^ source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts entity.name.type.ts
66
+ # ^ source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.end.ts
67
+ # ^ source.ts meta.function.ts meta.return.type.ts keyword.operator.type.annotation.ts
68
+ # ^ source.ts meta.function.ts meta.return.type.ts
69
+ # ^^^^ source.ts meta.function.ts meta.return.type.ts support.type.primitive.ts
70
+ # ^ source.ts punctuation.terminator.statement.ts
71
+ >declare type SomeResult = any;
72
+ #^^^^^^^ source.ts meta.type.declaration.ts storage.modifier.ts
73
+ # ^ source.ts meta.type.declaration.ts
74
+ # ^^^^ source.ts meta.type.declaration.ts storage.type.type.ts
75
+ # ^ source.ts meta.type.declaration.ts
76
+ # ^^^^^^^^^^ source.ts meta.type.declaration.ts entity.name.type.alias.ts
77
+ # ^ source.ts meta.type.declaration.ts
78
+ # ^ source.ts meta.type.declaration.ts keyword.operator.assignment.ts
79
+ # ^ source.ts meta.type.declaration.ts
80
+ # ^^^ source.ts meta.type.declaration.ts support.type.primitive.ts
81
+ # ^ source.ts punctuation.terminator.statement.ts
82
+ >declare type SomeVariables = any;
83
+ #^^^^^^^ source.ts meta.type.declaration.ts storage.modifier.ts
84
+ # ^ source.ts meta.type.declaration.ts
85
+ # ^^^^ source.ts meta.type.declaration.ts storage.type.type.ts
86
+ # ^ source.ts meta.type.declaration.ts
87
+ # ^^^^^^^^^^^^^ source.ts meta.type.declaration.ts entity.name.type.alias.ts
88
+ # ^ source.ts meta.type.declaration.ts
89
+ # ^ source.ts meta.type.declaration.ts keyword.operator.assignment.ts
90
+ # ^ source.ts meta.type.declaration.ts
91
+ # ^^^ source.ts meta.type.declaration.ts support.type.primitive.ts
92
+ # ^ source.ts punctuation.terminator.statement.ts
93
+ >
94
+ >// for comparison - this is what a normal function all is colored
95
+ #^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
96
+ # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts
97
+ >foo`query Foo { test }`;
98
+ #^^^ source.ts entity.name.function.tagged-template.ts
99
+ # ^ source.ts string.template.ts punctuation.definition.string.template.begin.ts
100
+ # ^^^^^^^^^^^^^^^^^^ source.ts string.template.ts
101
+ # ^ source.ts string.template.ts punctuation.definition.string.template.end.ts
102
+ # ^ source.ts punctuation.terminator.statement.ts
103
+ >foo<SomeResult, SomeVariables>`query Foo { test }`;
104
+ #^^^ source.ts entity.name.function.tagged-template.ts
105
+ # ^ source.ts meta.type.parameters.ts punctuation.definition.typeparameters.begin.ts
106
+ # ^^^^^^^^^^ source.ts meta.type.parameters.ts entity.name.type.ts
107
+ # ^ source.ts meta.type.parameters.ts punctuation.separator.comma.ts
108
+ # ^ source.ts meta.type.parameters.ts
109
+ # ^^^^^^^^^^^^^ source.ts meta.type.parameters.ts entity.name.type.ts
110
+ # ^ source.ts meta.type.parameters.ts punctuation.definition.typeparameters.end.ts
111
+ # ^ source.ts string.template.ts punctuation.definition.string.template.begin.ts
112
+ # ^^^^^^^^^^^^^^^^^^ source.ts string.template.ts
113
+ # ^ source.ts string.template.ts punctuation.definition.string.template.end.ts
114
+ # ^ source.ts punctuation.terminator.statement.ts
115
+ >
116
+ >// prettier-ignore
117
+ #^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
118
+ # ^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts
119
+ >gql`query Q1 { test }`
120
+ #^^^^ source.ts
121
+ # ^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql
122
+ # ^ source.ts meta.embedded.block.graphql
123
+ # ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql
124
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
125
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
126
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
127
+ # ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql
128
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
129
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
130
+ # ^ source.ts
131
+ >
132
+ >// prettier-ignore
133
+ #^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
134
+ # ^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts
135
+ >gql<SomeResult, SomeVariables>`query Q2 { test }`
136
+ #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts
137
+ # ^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql
138
+ # ^ source.ts meta.embedded.block.graphql
139
+ # ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql
140
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
141
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
142
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
143
+ # ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql
144
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
145
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
146
+ # ^ source.ts
147
+ >
148
+ >// prettier-ignore
149
+ #^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
150
+ # ^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts
151
+ >gql <SomeResult, SomeVariables> `
152
+ #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts
153
+ >query Q3 { test }`
154
+ #^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql
155
+ # ^ source.ts meta.embedded.block.graphql
156
+ # ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql
157
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
158
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
159
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
160
+ # ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql
161
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
162
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
163
+ # ^ source.ts
164
+ >
165
+ >// prettier-ignore
166
+ #^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
167
+ # ^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts
168
+ >gql `query Q4 { test }`
169
+ #^^^^^^^^ source.ts
170
+ # ^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql
171
+ # ^ source.ts meta.embedded.block.graphql
172
+ # ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql
173
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
174
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
175
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
176
+ # ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql
177
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
178
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
179
+ # ^ source.ts
180
+ >
181
+ >gql`
182
+ #^^^^ source.ts
183
+ > query Q5 {
184
+ #^^ source.ts meta.embedded.block.graphql
185
+ # ^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql
186
+ # ^ source.ts meta.embedded.block.graphql
187
+ # ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql
188
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
189
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
190
+ > test
191
+ #^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
192
+ # ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql
193
+ > }
194
+ #^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
195
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
196
+ >`;
197
+ #^ source.ts
198
+ # ^ source.ts punctuation.terminator.statement.ts
199
+ >
200
+ >gql<SomeResult, SomeVariables>`
201
+ #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts
202
+ > query Q6 {
203
+ #^^ source.ts meta.embedded.block.graphql
204
+ # ^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql
205
+ # ^ source.ts meta.embedded.block.graphql
206
+ # ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql
207
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
208
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
209
+ > test
210
+ #^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
211
+ # ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql
212
+ > }
213
+ #^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
214
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
215
+ >`;
216
+ #^ source.ts
217
+ # ^ source.ts punctuation.terminator.statement.ts
218
+ >
219
+ >// prettier-ignore
220
+ #^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
221
+ # ^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts
222
+ >gql `
223
+ #^^^^^^^ source.ts
224
+ > query Q7 {
225
+ #^^ source.ts meta.embedded.block.graphql
226
+ # ^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql
227
+ # ^ source.ts meta.embedded.block.graphql
228
+ # ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql
229
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
230
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
231
+ > test
232
+ #^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
233
+ # ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql
234
+ > }
235
+ #^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
236
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
237
+ >`;
238
+ #^ source.ts
239
+ # ^ source.ts punctuation.terminator.statement.ts
240
+ >
241
+ >// syntax highlighting cannot work in all examples after this - textmate grammars don't work over multiple lines like this
242
+ #^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
243
+ # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts
244
+ >
245
+ >// prettier-ignore
246
+ #^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
247
+ # ^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts
248
+ >gql
249
+ #^^^ source.ts variable.other.readwrite.ts
250
+ >`query Q8 { test }`
251
+ #^ source.ts string.template.ts punctuation.definition.string.template.begin.ts
252
+ # ^^^^^^^^^^^^^^^^^ source.ts string.template.ts
253
+ # ^ source.ts string.template.ts punctuation.definition.string.template.end.ts
254
+ >
255
+ >// prettier-ignore
256
+ #^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
257
+ # ^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts
258
+ >gql<{
259
+ #^^^ source.ts meta.function-call.ts entity.name.function.ts
260
+ # ^ source.ts meta.type.parameters.ts punctuation.definition.typeparameters.begin.ts
261
+ # ^ source.ts meta.type.parameters.ts meta.object.type.ts punctuation.definition.block.ts
262
+ > test: string;
263
+ #^^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts
264
+ # ^^^^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts meta.definition.property.ts variable.object.property.ts
265
+ # ^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
266
+ # ^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts
267
+ # ^^^^^^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts support.type.primitive.ts
268
+ # ^ source.ts meta.type.parameters.ts meta.object.type.ts punctuation.terminator.statement.ts
269
+ >},{
270
+ #^ source.ts meta.type.parameters.ts meta.object.type.ts punctuation.definition.block.ts
271
+ # ^ source.ts meta.type.parameters.ts punctuation.separator.comma.ts
272
+ # ^ source.ts meta.type.parameters.ts meta.object.type.ts punctuation.definition.block.ts
273
+ > test: string;
274
+ #^^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts
275
+ # ^^^^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts meta.definition.property.ts variable.object.property.ts
276
+ # ^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
277
+ # ^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts
278
+ # ^^^^^^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts support.type.primitive.ts
279
+ # ^ source.ts meta.type.parameters.ts meta.object.type.ts punctuation.terminator.statement.ts
280
+ >}>`query Q9 { test }`
281
+ #^ source.ts meta.type.parameters.ts meta.object.type.ts punctuation.definition.block.ts
282
+ # ^ source.ts meta.type.parameters.ts punctuation.definition.typeparameters.end.ts
283
+ # ^ source.ts string.template.ts punctuation.definition.string.template.begin.ts
284
+ # ^^^^^^^^^^^^^^^^^ source.ts string.template.ts
285
+ # ^ source.ts string.template.ts punctuation.definition.string.template.end.ts
286
+ >
287
+ >gql<
288
+ #^^^ source.ts variable.other.readwrite.ts
289
+ # ^ source.ts keyword.operator.relational.ts
290
+ > {
291
+ #^^ source.ts
292
+ # ^ source.ts meta.block.ts punctuation.definition.block.ts
293
+ > test: string;
294
+ #^^^^ source.ts meta.block.ts
295
+ # ^^^^ source.ts meta.block.ts entity.name.label.ts
296
+ # ^ source.ts meta.block.ts punctuation.separator.label.ts
297
+ # ^ source.ts meta.block.ts
298
+ # ^^^^^^ source.ts meta.block.ts variable.other.readwrite.ts
299
+ # ^ source.ts meta.block.ts punctuation.terminator.statement.ts
300
+ > },
301
+ #^^ source.ts meta.block.ts
302
+ # ^ source.ts meta.block.ts punctuation.definition.block.ts
303
+ # ^ source.ts punctuation.separator.comma.ts
304
+ > {
305
+ #^^ source.ts
306
+ # ^ source.ts meta.block.ts punctuation.definition.block.ts
307
+ > test: string;
308
+ #^^^^ source.ts meta.block.ts
309
+ # ^^^^ source.ts meta.block.ts entity.name.label.ts
310
+ # ^ source.ts meta.block.ts punctuation.separator.label.ts
311
+ # ^ source.ts meta.block.ts
312
+ # ^^^^^^ source.ts meta.block.ts variable.other.readwrite.ts
313
+ # ^ source.ts meta.block.ts punctuation.terminator.statement.ts
314
+ > }
315
+ #^^ source.ts meta.block.ts
316
+ # ^ source.ts meta.block.ts punctuation.definition.block.ts
317
+ >>`
318
+ #^ source.ts keyword.operator.relational.ts
319
+ # ^ source.ts string.template.ts punctuation.definition.string.template.begin.ts
320
+ > query Q10 {
321
+ #^^^^^^^^^^^^^^ source.ts string.template.ts
322
+ > test
323
+ #^^^^^^^^^ source.ts string.template.ts
324
+ > }
325
+ #^^^^ source.ts string.template.ts
326
+ >`;
327
+ #^ source.ts string.template.ts punctuation.definition.string.template.end.ts
328
+ # ^ source.ts punctuation.terminator.statement.ts
329
+ >
330
+ >// prettier-ignore
331
+ #^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
332
+ # ^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts
333
+ >gql
334
+ #^^^ source.ts variable.other.readwrite.ts
335
+ >`
336
+ #^ source.ts string.template.ts punctuation.definition.string.template.begin.ts
337
+ > query Q11 {
338
+ #^^^^^^^^^^^^^^ source.ts string.template.ts
339
+ > test
340
+ #^^^^^^^^^ source.ts string.template.ts
341
+ > }
342
+ #^^^^ source.ts string.template.ts
343
+ >`;
344
+ #^ source.ts string.template.ts punctuation.definition.string.template.end.ts
345
+ # ^ source.ts punctuation.terminator.statement.ts
346
+ >
347
+ >export {};
348
+ #^^^^^^ source.ts meta.export.ts keyword.control.export.ts
349
+ # ^ source.ts meta.export.ts
350
+ # ^ source.ts meta.export.ts meta.block.ts punctuation.definition.block.ts
351
+ # ^ source.ts meta.export.ts meta.block.ts punctuation.definition.block.ts
352
+ # ^ source.ts punctuation.terminator.statement.ts
353
+ >
@@ -0,0 +1,38 @@
1
+ // hint for reading the snapshots generated by this file:
2
+ // it is important to check that a rule doesn't only enter `meta.embedded.block.graphql`
3
+ // but also leaves it again
4
+
5
+ `#NormalComment
6
+ query Foo {test}`;
7
+
8
+ `#graphql
9
+ query Q1 {test}`;
10
+
11
+ ` # graphql
12
+ query Q2 {test}`;
13
+
14
+ `# GraphQL
15
+ query Q3 {
16
+ test
17
+ }`;
18
+
19
+ `#gql
20
+ # normal comment
21
+ query Q4 {
22
+ test
23
+ }`;
24
+
25
+ `#graphql
26
+ query Q5 {
27
+ test
28
+ }`;
29
+
30
+ // syntax highlighting cannot work in all examples after this - textmate grammars don't work over multiple lines like this
31
+ `
32
+
33
+ # graphql
34
+
35
+ query Q6 {
36
+ test
37
+ }
38
+ `;
@@ -0,0 +1,123 @@
1
+ >// hint for reading the snapshots generated by this file:
2
+ #^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
3
+ # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts
4
+ >// it is important to check that a rule doesn't only enter `meta.embedded.block.graphql`
5
+ #^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
6
+ # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts
7
+ >// but also leaves it again
8
+ #^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
9
+ # ^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts
10
+ >
11
+ >`#NormalComment
12
+ #^ source.ts string.template.ts punctuation.definition.string.template.begin.ts
13
+ # ^^^^^^^^^^^^^^^ source.ts string.template.ts
14
+ >query Foo {test}`;
15
+ #^^^^^^^^^^^^^^^^ source.ts string.template.ts
16
+ # ^ source.ts string.template.ts punctuation.definition.string.template.end.ts
17
+ # ^ source.ts punctuation.terminator.statement.ts
18
+ >
19
+ >`#graphql
20
+ #^ source.ts
21
+ # ^ source.ts meta.embedded.block.graphql comment.line.graphql.js
22
+ # ^^^^^^^ source.ts meta.embedded.block.graphql comment.line.graphql.js markup.italic
23
+ >query Q1 {test}`;
24
+ #^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql
25
+ # ^ source.ts meta.embedded.block.graphql
26
+ # ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql
27
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
28
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
29
+ # ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql
30
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
31
+ # ^ source.ts
32
+ # ^ source.ts punctuation.terminator.statement.ts
33
+ >
34
+ >` # graphql
35
+ #^ source.ts
36
+ # ^^^ source.ts meta.embedded.block.graphql comment.line.graphql.js
37
+ # ^^^^^^^ source.ts meta.embedded.block.graphql comment.line.graphql.js markup.italic
38
+ >query Q2 {test}`;
39
+ #^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql
40
+ # ^ source.ts meta.embedded.block.graphql
41
+ # ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql
42
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
43
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
44
+ # ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql
45
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
46
+ # ^ source.ts
47
+ # ^ source.ts punctuation.terminator.statement.ts
48
+ >
49
+ >`# GraphQL
50
+ #^ source.ts
51
+ # ^^ source.ts meta.embedded.block.graphql comment.line.graphql.js
52
+ # ^^^^^^^ source.ts meta.embedded.block.graphql comment.line.graphql.js markup.italic
53
+ >query Q3 {
54
+ #^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql
55
+ # ^ source.ts meta.embedded.block.graphql
56
+ # ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql
57
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
58
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
59
+ > test
60
+ #^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
61
+ # ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql
62
+ >}`;
63
+ #^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
64
+ # ^ source.ts
65
+ # ^ source.ts punctuation.terminator.statement.ts
66
+ >
67
+ >`#gql
68
+ #^ source.ts
69
+ # ^ source.ts meta.embedded.block.graphql comment.line.graphql.js
70
+ # ^^^ source.ts meta.embedded.block.graphql comment.line.graphql.js markup.italic
71
+ ># normal comment
72
+ #^^^^^^^^^^^^^^^^ source.ts meta.embedded.block.graphql comment.line.graphql.js
73
+ >query Q4 {
74
+ #^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql
75
+ # ^ source.ts meta.embedded.block.graphql
76
+ # ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql
77
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
78
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
79
+ > test
80
+ #^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
81
+ # ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql
82
+ >}`;
83
+ #^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
84
+ # ^ source.ts
85
+ # ^ source.ts punctuation.terminator.statement.ts
86
+ >
87
+ >`#graphql
88
+ #^ source.ts
89
+ # ^ source.ts meta.embedded.block.graphql comment.line.graphql.js
90
+ # ^^^^^^^ source.ts meta.embedded.block.graphql comment.line.graphql.js markup.italic
91
+ >query Q5 {
92
+ #^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql
93
+ # ^ source.ts meta.embedded.block.graphql
94
+ # ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql
95
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
96
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
97
+ > test
98
+ #^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
99
+ # ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql
100
+ >}`;
101
+ #^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
102
+ # ^ source.ts
103
+ # ^ source.ts punctuation.terminator.statement.ts
104
+ >
105
+ >// syntax highlighting cannot work in all examples after this - textmate grammars don't work over multiple lines like this
106
+ #^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
107
+ # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts
108
+ >`
109
+ #^ source.ts string.template.ts punctuation.definition.string.template.begin.ts
110
+ >
111
+ ># graphql
112
+ #^^^^^^^^^^ source.ts string.template.ts
113
+ >
114
+ >query Q6 {
115
+ #^^^^^^^^^^^ source.ts string.template.ts
116
+ > test
117
+ #^^^^^^^ source.ts string.template.ts
118
+ >}
119
+ #^^ source.ts string.template.ts
120
+ >`;
121
+ #^ source.ts string.template.ts punctuation.definition.string.template.end.ts
122
+ # ^ source.ts punctuation.terminator.statement.ts
123
+ >
@@ -122,18 +122,27 @@ Object {
122
122
  }
123
123
  `,
124
124
  });
125
-
126
- const config = await loadConfig({
127
- configPath: dirPath,
128
- });
129
- expect(config?.rawConfig).toMatchInlineSnapshot(`
125
+ fs.mkdirSync(`${dir}/bin`);
126
+ fs.writeFileSync(`${dir}/bin/rover`, "", { mode: 0o755 });
127
+ let oldPath = process.env.PATH;
128
+ process.env.PATH = `${dir}/bin:${oldPath}`;
129
+ try {
130
+ const config = await loadConfig({
131
+ configPath: dirPath,
132
+ });
133
+ expect(config?.rawConfig).toMatchInlineSnapshot(`
130
134
  Object {
131
135
  "engine": Object {
132
136
  "endpoint": "https://graphql.api.apollographql.com/api/graphql",
133
137
  },
134
- "rover": Object {},
138
+ "rover": Object {
139
+ "bin": "${dir}/bin/rover",
140
+ },
135
141
  }
136
142
  `);
143
+ } finally {
144
+ process.env.PATH = oldPath;
145
+ }
137
146
  }));
138
147
 
139
148
  it("[deprecated] loads config from package.json", async () => {
@@ -267,7 +276,7 @@ Object {
267
276
  describe("env loading", () => {
268
277
  it("finds .env in config path & parses for key", async () => {
269
278
  writeFilesToDir(dir, {
270
- "apollo.config.js": `module.exports = { client: { name: 'hello' } }`,
279
+ "apollo.config.js": `module.exports = { client: { } }`,
271
280
  ".env": `APOLLO_KEY=service:harambe:54378950jn`,
272
281
  });
273
282
 
@@ -280,7 +289,7 @@ Object {
280
289
 
281
290
  it("finds .env.local in config path & parses for key", async () => {
282
291
  writeFilesToDir(dir, {
283
- "apollo.config.js": `module.exports = { client: { name: 'hello' } }`,
292
+ "apollo.config.js": `module.exports = { client: { } }`,
284
293
  ".env.local": `APOLLO_KEY=service:harambe:54378950jn`,
285
294
  });
286
295
 
@@ -293,7 +302,7 @@ Object {
293
302
 
294
303
  it("finds .env and .env.local in config path & parses for key, preferring .env.local", async () => {
295
304
  writeFilesToDir(dir, {
296
- "apollo.config.js": `module.exports = { client: { name: 'hello' } }`,
305
+ "apollo.config.js": `module.exports = { client: { } }`,
297
306
  ".env": `APOLLO_KEY=service:hamato:54378950jn`,
298
307
  ".env.local": `APOLLO_KEY=service:yoshi:65489061ko`,
299
308
  });
@@ -337,7 +346,7 @@ Object {
337
346
  it("infers rover projects from config", () =>
338
347
  withFeatureFlags("rover", async () => {
339
348
  writeFilesToDir(dir, {
340
- "apollo.config.js": `module.exports = { rover: {} }`,
349
+ "apollo.config.js": `module.exports = { rover: { bin: "/usr/bin/env" } }`,
341
350
  });
342
351
 
343
352
  const config = await loadConfig({
@@ -6,6 +6,8 @@ import z, { ZodError } from "zod";
6
6
  import { ValidationRule } from "graphql/validation/ValidationContext";
7
7
  import { Slot } from "@wry/context";
8
8
  import { fromZodError } from "zod-validation-error";
9
+ import which from "which";
10
+ import { accessSync, constants as fsConstants, statSync } from "node:fs";
9
11
 
10
12
  const ROVER_AVAILABLE = (process.env.APOLLO_FEATURE_FLAGS || "")
11
13
  .split(",")
@@ -79,7 +81,30 @@ const clientConfig = z.object({
79
81
  export type ClientConfigFormat = z.infer<typeof clientConfig>;
80
82
 
81
83
  const roverConfig = z.object({
82
- bin: z.string().optional(),
84
+ bin: z
85
+ .preprocess(
86
+ (val) => val || which.sync("rover", { nothrow: true }) || undefined,
87
+ z.string({
88
+ message:
89
+ "Rover binary not found. Please either install it system-wide in PATH, or provide the `bin` option. Also ensure that the binary is executable.",
90
+ }),
91
+ )
92
+ .refine(
93
+ (bin) => {
94
+ try {
95
+ // is executable?
96
+ accessSync(bin, fsConstants.X_OK);
97
+ // is a file and not a directory?
98
+ return statSync(bin).isFile();
99
+ } catch {
100
+ return false;
101
+ }
102
+ },
103
+ {
104
+ message:
105
+ "Rover binary is not marked as an executable. If you are using OS X or Linux, ensure to set the executable bit.",
106
+ },
107
+ ),
83
108
  profile: z.string().optional(),
84
109
  });
85
110
  type RoverConfigFormat = z.infer<typeof roverConfig>;
@@ -0,0 +1,19 @@
1
+ declare module "which" {
2
+ interface Options {
3
+ /** Use instead of the PATH environment variable. */
4
+ path?: string;
5
+ /** Use instead of the PATHEXT environment variable. */
6
+ pathExt?: string;
7
+ /** Return all matches, instead of just the first one. Note that this means the function returns an array of strings instead of a single string. */
8
+ all?: boolean;
9
+ }
10
+
11
+ function which(cmd: string, options?: Options): number;
12
+ namespace which {
13
+ function sync(
14
+ cmd: string,
15
+ options?: Options & { nothrow?: boolean },
16
+ ): string | null;
17
+ }
18
+ export = which;
19
+ }