vscode-apollo 2.0.0 → 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 (39) hide show
  1. package/.circleci/config.yml +1 -1
  2. package/.vscode/launch.json +4 -1
  3. package/CHANGELOG.md +33 -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 +43 -10
  22. package/src/language-server/config/config.ts +26 -1
  23. package/src/language-server/config/loadConfig.ts +7 -1
  24. package/src/language-server/config/loadTsConfig.ts +70 -0
  25. package/src/language-server/config/which.d.ts +19 -0
  26. package/src/language-server/document.ts +86 -53
  27. package/src/language-server/fileSet.ts +7 -0
  28. package/src/language-server/project/base.ts +58 -316
  29. package/src/language-server/project/client.ts +730 -7
  30. package/src/language-server/project/internal.ts +349 -0
  31. package/src/language-server/project/rover/DocumentSynchronization.ts +308 -0
  32. package/src/language-server/project/rover/__tests__/DocumentSynchronization.test.ts +302 -0
  33. package/src/language-server/project/rover/project.ts +276 -0
  34. package/src/language-server/server.ts +129 -62
  35. package/src/language-server/utilities/__tests__/source.test.ts +162 -0
  36. package/src/language-server/utilities/source.ts +38 -3
  37. package/src/language-server/workspace.ts +34 -9
  38. package/syntaxes/graphql.js.json +18 -21
  39. package/src/language-server/languageProvider.ts +0 -795
@@ -0,0 +1,41 @@
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 */ `query Foo {test}`;
6
+
7
+ // prettier-ignore
8
+ {
9
+ const _1 = /* GraphQL */`query Q1 {test}`;
10
+ const _2 =
11
+ /* GraphQL */`
12
+ query Q2 {
13
+ test
14
+ }
15
+ `;
16
+ }
17
+
18
+ /* GraphQL */ `query Q3 {test}`;
19
+ /*GraphQL*/ `query Q4 {test}`;
20
+ /** GraphQL */ `query Q5 {test}`;
21
+
22
+ const _3 = /* GraphQL */ `
23
+ query Q6 {
24
+ test
25
+ }
26
+ `;
27
+
28
+ // syntax highlighting cannot work in all examples after this - textmate grammars don't work over multiple lines like this
29
+
30
+ /**
31
+ * GraphQL
32
+ */ `query Q7 {test}`;
33
+
34
+ /* GraphQL */
35
+ `query Q8 {test}`;
36
+
37
+ /* graphql */
38
+ `query Q9 {test}`;
39
+
40
+ /* gql */
41
+ `query Q10 {test}`;
@@ -0,0 +1,185 @@
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 */ `query Foo {test}`;
12
+ #^^ source.ts comment.block.ts punctuation.definition.comment.ts
13
+ # ^^^^^^^^^^^^^^^ source.ts comment.block.ts
14
+ # ^^ source.ts comment.block.ts punctuation.definition.comment.ts
15
+ # ^ source.ts
16
+ # ^ source.ts string.template.ts punctuation.definition.string.template.begin.ts
17
+ # ^^^^^^^^^^^^^^^^ source.ts string.template.ts
18
+ # ^ source.ts string.template.ts punctuation.definition.string.template.end.ts
19
+ # ^ source.ts punctuation.terminator.statement.ts
20
+ >
21
+ >// prettier-ignore
22
+ #^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
23
+ # ^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts
24
+ >{
25
+ #^ source.ts meta.block.ts punctuation.definition.block.ts
26
+ >const _1 = /* GraphQL */`query Q1 {test}`;
27
+ #^^^^^ source.ts meta.block.ts meta.var.expr.ts storage.type.ts
28
+ # ^ source.ts meta.block.ts meta.var.expr.ts
29
+ # ^^ source.ts meta.block.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.definition.variable.ts variable.other.constant.ts
30
+ # ^ source.ts meta.block.ts meta.var.expr.ts meta.var-single-variable.expr.ts
31
+ # ^ source.ts meta.block.ts meta.var.expr.ts keyword.operator.assignment.ts
32
+ # ^ source.ts meta.block.ts meta.var.expr.ts
33
+ # ^^^ source.ts meta.block.ts meta.var.expr.ts
34
+ # ^^^^^^^ source.ts meta.block.ts meta.var.expr.ts markup.italic
35
+ # ^^^^ source.ts meta.block.ts meta.var.expr.ts
36
+ # ^^^^^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql keyword.operation.graphql
37
+ # ^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql
38
+ # ^^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql entity.name.function.graphql
39
+ # ^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql
40
+ # ^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
41
+ # ^^^^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql
42
+ # ^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
43
+ # ^ source.ts meta.block.ts meta.var.expr.ts
44
+ # ^ source.ts meta.block.ts punctuation.terminator.statement.ts
45
+ >const _2 =
46
+ #^^^^^ source.ts meta.block.ts meta.var.expr.ts storage.type.ts
47
+ # ^ source.ts meta.block.ts meta.var.expr.ts
48
+ # ^^ source.ts meta.block.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.definition.variable.ts variable.other.constant.ts
49
+ # ^ source.ts meta.block.ts meta.var.expr.ts meta.var-single-variable.expr.ts
50
+ # ^ source.ts meta.block.ts meta.var.expr.ts keyword.operator.assignment.ts
51
+ >/* GraphQL */`
52
+ #^^^ source.ts meta.block.ts meta.var.expr.ts
53
+ # ^^^^^^^ source.ts meta.block.ts meta.var.expr.ts markup.italic
54
+ # ^^^^ source.ts meta.block.ts meta.var.expr.ts
55
+ >query Q2 {
56
+ #^^^^^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql keyword.operation.graphql
57
+ # ^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql
58
+ # ^^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql entity.name.function.graphql
59
+ # ^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql
60
+ # ^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
61
+ > test
62
+ #^^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql
63
+ # ^^^^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql
64
+ >}
65
+ #^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
66
+ >`;
67
+ #^ source.ts meta.block.ts meta.var.expr.ts
68
+ # ^ source.ts meta.block.ts punctuation.terminator.statement.ts
69
+ >}
70
+ #^ source.ts meta.block.ts punctuation.definition.block.ts
71
+ >
72
+ >/* GraphQL */ `query Q3 {test}`;
73
+ #^^^ source.ts
74
+ # ^^^^^^^ source.ts markup.italic
75
+ # ^^^^^ source.ts
76
+ # ^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql
77
+ # ^ source.ts meta.embedded.block.graphql
78
+ # ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql
79
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
80
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
81
+ # ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql
82
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
83
+ # ^ source.ts
84
+ # ^ source.ts punctuation.terminator.statement.ts
85
+ >/*GraphQL*/ `query Q4 {test}`;
86
+ #^^ source.ts
87
+ # ^^^^^^^ source.ts markup.italic
88
+ # ^^^^ source.ts
89
+ # ^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql
90
+ # ^ source.ts meta.embedded.block.graphql
91
+ # ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql
92
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
93
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
94
+ # ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql
95
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
96
+ # ^ source.ts
97
+ # ^ source.ts punctuation.terminator.statement.ts
98
+ >/** GraphQL */ `query Q5 {test}`;
99
+ #^^^^ source.ts
100
+ # ^^^^^^^ source.ts markup.italic
101
+ # ^^^^^ source.ts
102
+ # ^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql
103
+ # ^ source.ts meta.embedded.block.graphql
104
+ # ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql
105
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql
106
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
107
+ # ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql
108
+ # ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
109
+ # ^ source.ts
110
+ # ^ source.ts punctuation.terminator.statement.ts
111
+ >
112
+ >const _3 = /* GraphQL */ `
113
+ #^^^^^ source.ts meta.var.expr.ts storage.type.ts
114
+ # ^ source.ts meta.var.expr.ts
115
+ # ^^ source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.definition.variable.ts variable.other.constant.ts
116
+ # ^ source.ts meta.var.expr.ts meta.var-single-variable.expr.ts
117
+ # ^ source.ts meta.var.expr.ts keyword.operator.assignment.ts
118
+ # ^ source.ts meta.var.expr.ts
119
+ # ^^^ source.ts meta.var.expr.ts
120
+ # ^^^^^^^ source.ts meta.var.expr.ts markup.italic
121
+ # ^^^^^ source.ts meta.var.expr.ts
122
+ > query Q6 {
123
+ #^^ source.ts meta.var.expr.ts meta.embedded.block.graphql
124
+ # ^^^^^ source.ts meta.var.expr.ts meta.embedded.block.graphql keyword.operation.graphql
125
+ # ^ source.ts meta.var.expr.ts meta.embedded.block.graphql
126
+ # ^^ source.ts meta.var.expr.ts meta.embedded.block.graphql entity.name.function.graphql
127
+ # ^ source.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql
128
+ # ^ source.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
129
+ > test
130
+ #^^^^ source.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql
131
+ # ^^^^ source.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql
132
+ > }
133
+ #^^ source.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql
134
+ # ^ source.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
135
+ >`;
136
+ #^ source.ts meta.var.expr.ts
137
+ # ^ source.ts punctuation.terminator.statement.ts
138
+ >
139
+ >// syntax highlighting cannot work in all examples after this - textmate grammars don't work over multiple lines like this
140
+ #^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
141
+ # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts
142
+ >
143
+ >/**
144
+ #^^^ source.ts comment.block.documentation.ts punctuation.definition.comment.ts
145
+ > * GraphQL
146
+ #^^^^^^^^^^^ source.ts comment.block.documentation.ts
147
+ > */ `query Q7 {test}`;
148
+ #^ source.ts comment.block.documentation.ts
149
+ # ^^ source.ts comment.block.documentation.ts punctuation.definition.comment.ts
150
+ # ^ source.ts
151
+ # ^ source.ts string.template.ts punctuation.definition.string.template.begin.ts
152
+ # ^^^^^^^^^^^^^^^ source.ts string.template.ts
153
+ # ^ source.ts string.template.ts punctuation.definition.string.template.end.ts
154
+ # ^ source.ts punctuation.terminator.statement.ts
155
+ >
156
+ >/* GraphQL */
157
+ #^^ source.ts comment.block.ts punctuation.definition.comment.ts
158
+ # ^^^^^^^^^ source.ts comment.block.ts
159
+ # ^^ source.ts comment.block.ts punctuation.definition.comment.ts
160
+ >`query Q8 {test}`;
161
+ #^ source.ts string.template.ts punctuation.definition.string.template.begin.ts
162
+ # ^^^^^^^^^^^^^^^ source.ts string.template.ts
163
+ # ^ source.ts string.template.ts punctuation.definition.string.template.end.ts
164
+ # ^ source.ts punctuation.terminator.statement.ts
165
+ >
166
+ >/* graphql */
167
+ #^^ source.ts comment.block.ts punctuation.definition.comment.ts
168
+ # ^^^^^^^^^ source.ts comment.block.ts
169
+ # ^^ source.ts comment.block.ts punctuation.definition.comment.ts
170
+ >`query Q9 {test}`;
171
+ #^ source.ts string.template.ts punctuation.definition.string.template.begin.ts
172
+ # ^^^^^^^^^^^^^^^ source.ts string.template.ts
173
+ # ^ source.ts string.template.ts punctuation.definition.string.template.end.ts
174
+ # ^ source.ts punctuation.terminator.statement.ts
175
+ >
176
+ >/* gql */
177
+ #^^ source.ts comment.block.ts punctuation.definition.comment.ts
178
+ # ^^^^^ source.ts comment.block.ts
179
+ # ^^ source.ts comment.block.ts punctuation.definition.comment.ts
180
+ >`query Q10 {test}`;
181
+ #^ source.ts string.template.ts punctuation.definition.string.template.begin.ts
182
+ # ^^^^^^^^^^^^^^^^ source.ts string.template.ts
183
+ # ^ source.ts string.template.ts punctuation.definition.string.template.end.ts
184
+ # ^ source.ts punctuation.terminator.statement.ts
185
+ >
@@ -0,0 +1,93 @@
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
+ declare function gql<A = any, B = any>(arg: string, ...args: any[]): void;
6
+ declare function foo<A = any, B = any>(...args: any[]): void;
7
+ declare type SomeResult = any;
8
+ declare type SomeVariables = any;
9
+
10
+ // for comparison - this is what a normal function all is colored
11
+ foo(`query Foo { test }`);
12
+
13
+ // if possible, these should look the same
14
+ foo("notATemplate");
15
+ gql("notATemplate");
16
+ foo<"">("notATemplate");
17
+ gql<"">("notATemplate");
18
+
19
+ // prettier-ignore
20
+ gql(`query Q1($arg: String!) { test }`)
21
+
22
+ // prettier-ignore
23
+ gql<SomeResult, SomeVariables>(`query Q2 { test }`)
24
+
25
+ // prettier-ignore
26
+ gql ( `query Q3 { test }` )
27
+
28
+ gql(`
29
+ query Q4 {
30
+ test
31
+ }
32
+ `);
33
+
34
+ // prettier-ignore
35
+ gql ( `
36
+ query Q5 {
37
+ test
38
+ }
39
+ ` );
40
+
41
+ // syntax highlighting cannot work in all examples after this - textmate grammars don't work over multiple lines like this
42
+
43
+ gql<
44
+ {
45
+ test: string;
46
+ },
47
+ {
48
+ test: string;
49
+ }
50
+ >(`
51
+ query Q6 {
52
+ test
53
+ }
54
+ `);
55
+
56
+ // prettier-ignore
57
+ gql(
58
+ `
59
+ query Q7 {
60
+ test
61
+ }
62
+ `
63
+ );
64
+
65
+ gql<SomeResult, SomeVariables>(
66
+ // ts-ignore
67
+ `
68
+ query Q8 {
69
+ test
70
+ }
71
+ `,
72
+ `query {}`,
73
+ );
74
+
75
+ // prettier-ignore
76
+ gql<{
77
+ test: string;
78
+ },{
79
+ test: string;
80
+ }>(`query Q9 { test }`)
81
+
82
+ // prettier-ignore
83
+ gql(
84
+ `query Q10 { test }`
85
+ )
86
+
87
+ // prettier-ignore
88
+ gql
89
+ (
90
+ `query Q11 { test }`
91
+ )
92
+
93
+ export {};