Skip to content

Commit 2420a8a

Browse files
author
Kumar Harsh
committed
feat(syntax): add support for field descriptions. Closes #63
- graphql v0.12.0 has a new proposed way of adding field descriptions as strings rather than comments. See graphql/graphql-js#927. This commit adds support for the usecase.
1 parent 51bff20 commit 2420a8a

File tree

1 file changed

+52
-17
lines changed

1 file changed

+52
-17
lines changed

syntaxes/graphql.json

+52-17
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
"repository": {
1414
"graphql": {
1515
"patterns": [
16+
{ "include": "#graphql-comment" },
17+
{ "include": "#graphql-description" },
1618
{ "include": "#graphql-fragment-definition" },
1719
{ "include": "#graphql-type-interface" },
1820
{ "include": "#graphql-enum" },
1921
{ "include": "#graphql-scalar" },
2022
{ "include": "#graphql-union" },
2123
{ "include": "#graphql-schema" },
2224
{ "include": "#graphql-operation-def" },
23-
{ "include": "#graphql-comment" },
2425
{ "include": "#literal-quasi-embedded" }
2526
]
2627
},
@@ -45,6 +46,7 @@
4546
},
4647
"patterns": [
4748
{ "include": "#graphql-comment" },
49+
{ "include": "#graphql-description" },
4850
{ "include": "#graphql-selection-set" },
4951
{ "include": "#graphql-directive" },
5052
{ "include": "#graphql-skip-newlines" },
@@ -85,8 +87,9 @@
8587
{ "include": "#graphql-comma" }
8688
]
8789
},
88-
{ "include": "#graphql-directive" },
8990
{ "include": "#graphql-comment" },
91+
{ "include": "#graphql-description" },
92+
{ "include": "#graphql-directive" },
9093
{ "include": "#graphql-type-object" },
9194
{ "include": "#literal-quasi-embedded" }
9295
]
@@ -102,9 +105,9 @@
102105
"1": { "name": "punctuation.operation.graphql"}
103106
},
104107
"patterns": [
105-
{ "include": "#graphql-object-type" },
106-
107108
{ "include": "#graphql-comment" },
109+
{ "include": "#graphql-description" },
110+
{ "include": "#graphql-object-type" },
108111
{ "include": "#graphql-type-definition" },
109112
{ "include": "#literal-quasi-embedded" }
110113
]
@@ -121,6 +124,7 @@
121124
},
122125
"patterns": [
123126
{ "include": "#graphql-comment" },
127+
{ "include": "#graphql-description" },
124128
{ "include": "#graphql-variable-definitions" },
125129
{ "include": "#graphql-type-object" },
126130
{ "include": "#graphql-colon"},
@@ -161,26 +165,44 @@
161165
"1": { "name": "support.type.graphql" }
162166
}
163167
},
164-
{ "include": "#graphql-colon" },
165168
{ "include": "#graphql-comment" },
169+
{ "include": "#graphql-description" },
170+
{ "include": "#graphql-colon" },
166171
{ "include": "#graphql-skip-newlines" }
167172
]
168173
},
169174
{ "include": "#graphql-comment" },
175+
{ "include": "#graphql-description" },
170176
{ "include": "#graphql-skip-newlines" }
171177
]
172178
},
173179
{ "include": "#graphql-comment" },
180+
{ "include": "#graphql-description" },
174181
{ "include": "#graphql-skip-newlines" }
175182
]
176183
},
177184
"graphql-comment": {
178185
"comment": "need to prefix comment space with a scope else Atom's reflow cmd doesn't work",
179-
"name": "comment.line.graphql.js",
180-
"match": "(\\s*)(#).*",
181-
"captures": {
182-
"1": { "name": "punctuation.whitespace.comment.leading.graphql" }
183-
}
186+
"name": "comment.line.graphql",
187+
"match": "\\s*#.*"
188+
},
189+
"graphql-description": {
190+
"comment": "In new graphql spec 0.12.0, the description has to enclosed in two lines of triple quotes",
191+
"name": "graphql.description",
192+
"begin": "^\\s*(\"\"\")$",
193+
"beginCaptures": {
194+
"1": { "name": "comment.quoted.double.graphql.begin" }
195+
},
196+
"end": "^\\s*(\"\"\")$",
197+
"endCaptures": {
198+
"1": { "name": "comment.quoted.double.graphql.end" }
199+
},
200+
"patterns": [
201+
{
202+
"name": "comment.line.graphql",
203+
"match": "^\\s*.*$"
204+
}
205+
]
184206
},
185207
"graphql-variable-definitions": {
186208
"begin": "\\s*(\\()",
@@ -190,6 +212,7 @@
190212
},
191213
"patterns": [
192214
{ "include": "#graphql-comment" },
215+
{ "include": "#graphql-description" },
193216
{ "include": "#graphql-variable-definition"},
194217
{ "include": "#literal-quasi-embedded" }
195218
]
@@ -207,6 +230,7 @@
207230
},
208231
"patterns": [
209232
{ "include": "#graphql-comment" },
233+
{ "include": "#graphql-description" },
210234
{ "include": "#graphql-colon" },
211235
{ "include": "#graphql-input-types"},
212236
{ "include": "#graphql-variable-assignment"},
@@ -233,8 +257,9 @@
233257
"2": { "name": "keyword.operator.nulltype.graphql" }
234258
},
235259
"patterns": [
236-
{ "include": "#graphql-input-types" },
237260
{ "include": "#graphql-comment" },
261+
{ "include": "#graphql-description" },
262+
{ "include": "#graphql-input-types" },
238263
{ "include": "#graphql-comma" },
239264
{ "include": "#literal-quasi-embedded" }
240265
]
@@ -298,8 +323,9 @@
298323
"1": { "name": "entity.name.function.directive.graphql" }
299324
},
300325
"patterns": [
301-
{ "include": "#graphql-arguments"},
302326
{ "include": "#graphql-comment" },
327+
{ "include": "#graphql-description" },
328+
{ "include": "#graphql-arguments"},
303329
{ "include": "#literal-quasi-embedded" },
304330
{ "include": "#graphql-skip-newlines" }
305331
]
@@ -315,11 +341,12 @@
315341
"1": { "name": "punctuation.operation.graphql"}
316342
},
317343
"patterns": [
344+
{ "include": "#graphql-comment" },
345+
{ "include": "#graphql-description" },
318346
{ "include": "#graphql-field" },
319347
{ "include": "#graphql-fragment-spread" },
320348
{ "include": "#graphql-inline-fragment" },
321349
{ "include": "#graphql-comma" },
322-
{ "include": "#graphql-comment" },
323350
{ "include": "#native-interpolation" },
324351
{ "include": "#literal-quasi-embedded" }
325352
]
@@ -356,6 +383,7 @@
356383
},
357384
"patterns": [
358385
{ "include": "#graphql-comment" },
386+
{ "include": "#graphql-description" },
359387
{ "include": "#graphql-selection-set" },
360388
{ "include": "#graphql-directive" },
361389
{ "include": "#literal-quasi-embedded" },
@@ -373,6 +401,7 @@
373401
},
374402
"patterns": [
375403
{ "include": "#graphql-comment" },
404+
{ "include": "#graphql-description" },
376405
{ "include": "#graphql-selection-set" },
377406
{ "include": "#graphql-directive" },
378407
{ "include": "#graphql-skip-newlines" },
@@ -391,6 +420,7 @@
391420
},
392421
"patterns": [
393422
{ "include": "#graphql-comment" },
423+
{ "include": "#graphql-description" },
394424
{
395425
"begin": "\\s*([_A-Za-z][_0-9A-Za-z]*)(?:\\s*(:))",
396426
"end": "(?=\\s*(?:(?:([_A-Za-z][_0-9A-Za-z]*)\\s*(:))|\\)))|\\s*(,)",
@@ -402,8 +432,9 @@
402432
"3": { "name": "punctuation.comma.graphql" }
403433
},
404434
"patterns": [
405-
{ "include": "#graphql-value" },
406435
{ "include": "#graphql-comment" },
436+
{ "include": "#graphql-description" },
437+
{ "include": "#graphql-value" },
407438
{ "include": "#graphql-skip-newlines" }
408439
]
409440
},
@@ -485,6 +516,7 @@
485516
{ "include": "#graphql-object-type" },
486517

487518
{ "include": "#graphql-comment" },
519+
{ "include": "#graphql-description" },
488520
{ "include": "#graphql-enum-value" },
489521
{ "include": "#literal-quasi-embedded" }
490522
]
@@ -497,6 +529,8 @@
497529
},
498530
"graphql-value":{
499531
"patterns": [
532+
{ "include": "#graphql-comment" },
533+
{ "include": "#graphql-description" },
500534
{ "include": "#graphql-variable-name" },
501535
{ "include": "#graphql-float-value" },
502536
{ "include": "#graphql-string-value" },
@@ -505,7 +539,6 @@
505539
{ "include": "#graphql-enum-value" },
506540
{ "include": "#graphql-list-value" },
507541
{ "include": "#graphql-object-value" },
508-
{ "include": "#graphql-comment" },
509542
{ "include": "#literal-quasi-embedded" }
510543
]
511544
},
@@ -572,8 +605,9 @@
572605
"2": { "name": "support.type.graphql" }
573606
},
574607
"patterns": [
575-
{ "include": "#graphql-skip-newlines" },
576608
{ "include": "#graphql-comment" },
609+
{ "include": "#graphql-description" },
610+
{ "include": "#graphql-skip-newlines" },
577611
{ "include": "#literal-quasi-embedded" },
578612
{
579613
"match": "\\s*(\\|)\\s*([_A-Za-z][_0-9A-Za-z]*)",
@@ -584,8 +618,9 @@
584618
}
585619
]
586620
},
587-
{ "include": "#graphql-skip-newlines" },
588621
{ "include": "#graphql-comment" },
622+
{ "include": "#graphql-description" },
623+
{ "include": "#graphql-skip-newlines" },
589624
{ "include": "#literal-quasi-embedded" }
590625
]
591626
},

0 commit comments

Comments
 (0)