File tree 7 files changed +459
-216
lines changed
packages/vscode-graphql-syntax
7 files changed +459
-216
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' vscode-graphql-syntax ' : patch
3
+ ---
4
+
5
+ Fix TextMate grammar to support string literals that don’t immediately follow a function call's left-parenthesis (` ( ` ).
Original file line number Diff line number Diff line change 4
4
"patterns" : [
5
5
{
6
6
"contentName" : " meta.embedded.block.graphql" ,
7
- "begin" : " \\ s*+(?:(?:(Relay)\\ ??\\ .)(QL)|(gql|graphql|graphql\\ .experimental)|(/\\ * GraphQL \\ */))\\ s*\\ (?\\ s*(`|')" ,
8
- "beginCaptures" : {
9
- "1" : {
10
- "name" : " variable.other.class.js"
11
- },
12
- "2" : {
13
- "name" : " entity.name.function.tagged-template.js"
14
- },
15
- "3" : {
16
- "name" : " entity.name.function.tagged-template.js"
17
- },
18
- "4" : {
19
- "name" : " comment.graphql.js"
20
- },
21
- "5" : {
22
- "name" : " punctuation.definition.string.template.begin.js"
23
- }
24
- },
25
- "end" : " (`|')" ,
26
- "endCaptures" : {
27
- "0" : {
28
- "name" : " punctuation.definition.string.template.end.js"
29
- }
30
- },
7
+ "begin" : " (?<=(?:(?:Relay\\ ??\\ .)QL|gql|graphql|graphql\\ .experimental)\\ s*(?:<.*>)?\\ s*)\\ (" ,
8
+ "end" : " \\ )" ,
31
9
"patterns" : [
32
10
{
33
- "include" : " source.graphql"
11
+ "begin" : " (`|')" ,
12
+ "end" : " (`|')" ,
13
+ "beginCaptures" : {
14
+ "0" : {
15
+ "name" : " punctuation.definition.string.template.begin.js"
16
+ }
17
+ },
18
+ "endCaptures" : {
19
+ "0" : {
20
+ "name" : " punctuation.definition.string.template.end.js"
21
+ }
22
+ },
23
+ "patterns" : [
24
+ {
25
+ "include" : " source.graphql"
26
+ }
27
+ ]
34
28
}
35
29
]
36
30
},
37
31
{
38
32
"contentName" : " meta.embedded.block.graphql" ,
39
- "begin" : " \\ s*+(?:(?:(Relay)\\ ??\\ .)(QL)|(gql|graphql|graphql\\ .experimental)) \\ s*\\ (? \\ s*(?:<.*>) (`|')" ,
33
+ "begin" : " \\ s*+(?:(?:(?:( Relay)\\ ??\\ .)(QL)|(gql|graphql|graphql\\ .experimental)\\ s*(?:<.*>)? \\ s*)|(/ \\ * GraphQL \\ */)) \\ s* (`|')" ,
40
34
"beginCaptures" : {
41
35
"1" : {
42
36
"name" : " variable.other.class.js"
48
42
"name" : " entity.name.function.tagged-template.js"
49
43
},
50
44
"4" : {
45
+ "name" : " comment.graphql.js"
46
+ },
47
+ "5" : {
51
48
"name" : " punctuation.definition.string.template.begin.js"
52
49
}
53
50
},
Original file line number Diff line number Diff line change @@ -26,6 +26,50 @@ const Component = () => {
26
26
};
27
27
```
28
28
29
+ ``` js
30
+ const variable = 1 ;
31
+
32
+ const queryA = graphql (`
33
+ query {
34
+ something(arg: ${ variable} )
35
+ }
36
+ ` );
37
+
38
+ const queryB = graphql (
39
+ `
40
+ query {
41
+ something(arg: ${ variable} )
42
+ }
43
+ `
44
+ );
45
+
46
+ const queryC = graphql (
47
+ ' query { something(arg: ${variable}) }'
48
+ );
49
+ ```
50
+
51
+ ``` ts
52
+ const variable: number = 1 ;
53
+
54
+ const queryA = graphql (`
55
+ query {
56
+ something(arg: ${variable })
57
+ }
58
+ ` );
59
+
60
+ const queryB = graphql (
61
+ `
62
+ query {
63
+ something(arg: ${variable })
64
+ }
65
+ `
66
+ );
67
+
68
+ const queryC = graphql (
69
+ ' query { something(arg: ${variable}) }'
70
+ );
71
+ ```
72
+
29
73
### svelte
30
74
31
75
``` svelte
Original file line number Diff line number Diff line change @@ -37,8 +37,18 @@ const graphql = graphql(`
37
37
}
38
38
` ) ;
39
39
40
+ const graphql = graphql (
41
+ `
42
+ query($id: ID!) { test }
43
+ ` ,
44
+ [ var1 , var2 ]
45
+ ) ;
46
+
40
47
const query = /* GraphQL */ 'query { id } ' ;
41
- const query = graphql ( 'query { id } ' ) ;
48
+ const query = graphql ( 'query($id: ID!) { id } ' ) ;
49
+ const query = graphql (
50
+ 'query($id: ID!) { test }'
51
+ ) ;
42
52
43
53
const queryWithInlineComment = `#graphql
44
54
query {
@@ -59,7 +69,6 @@ const queryWithInlineComment = `#graphql
59
69
}
60
70
}
61
71
` ;
62
- // TODO: fix this
63
72
const queryWithInlineComment = `
64
73
#graphql
65
74
query {
Original file line number Diff line number Diff line change @@ -25,9 +25,27 @@ const query = graphql<SomeGeneric>`
25
25
}
26
26
` ;
27
27
28
- // TODO: Fix this
29
28
const query = graphql < Generic > ( 'query { id }' ) ;
30
29
30
+ const query = graphql (
31
+ 'query { id }'
32
+ ) ;
33
+
34
+ const query = graphql < Generic > (
35
+ 'query { id }'
36
+ ) ;
37
+
38
+ const query = graphql ( `
39
+ query { id }
40
+ ` ) ;
41
+
42
+ const query = graphql (
43
+ `
44
+ query { id }
45
+ ` ,
46
+ [ var1 , var2 ]
47
+ ) ;
48
+
31
49
const queryWithInlineComment = `#graphql
32
50
query {
33
51
user(id: "5", name: boolean) {
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -107,6 +107,50 @@ graphql\` |
107
107
const Component = () => { |
108
108
return <div > </div >; |
109
109
} ; |
110
+ \`\`\` |
111
+ |
112
+ \`\`\`js |
113
+ const variable = 1; |
114
+ |
115
+ const queryA = graphql(\` |
116
+ query { |
117
+ something (arg : \$ {variable }) |
118
+ } |
119
+ \`); |
120
+ |
121
+ const queryB = graphql( |
122
+ \` |
123
+ query { |
124
+ something (arg : \$ {variable }) |
125
+ } |
126
+ \` |
127
+ ); |
128
+ |
129
+ const queryC = graphql( |
130
+ 'query { something (arg : \$ {variable }) } ' |
131
+ ); |
132
+ \`\`\` |
133
+ |
134
+ \`\`\`ts |
135
+ const variable: number = 1; |
136
+ |
137
+ const queryA = graphql(\` |
138
+ query { |
139
+ something (arg : \$ {variable }) |
140
+ } |
141
+ \`); |
142
+ |
143
+ const queryB = graphql( |
144
+ \` |
145
+ query { |
146
+ something (arg : \$ {variable }) |
147
+ } |
148
+ \` |
149
+ ); |
150
+ |
151
+ const queryC = graphql( |
152
+ 'query { something (arg : \$ {variable }) } ' |
153
+ ); |
110
154
\`\`\` |
111
155
|
112
156
### svelte |
You can’t perform that action at this time.
0 commit comments