Skip to content

Commit

Permalink
feat(syntax): add support for field descriptions. Closes #63
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
Kumar Harsh committed Jan 6, 2018
1 parent 51bff20 commit 2420a8a
Showing 1 changed file with 52 additions and 17 deletions.
69 changes: 52 additions & 17 deletions syntaxes/graphql.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
"repository": {
"graphql": {
"patterns": [
{ "include": "#graphql-comment" },
{ "include": "#graphql-description" },
{ "include": "#graphql-fragment-definition" },
{ "include": "#graphql-type-interface" },
{ "include": "#graphql-enum" },
{ "include": "#graphql-scalar" },
{ "include": "#graphql-union" },
{ "include": "#graphql-schema" },
{ "include": "#graphql-operation-def" },
{ "include": "#graphql-comment" },
{ "include": "#literal-quasi-embedded" }
]
},
Expand All @@ -45,6 +46,7 @@
},
"patterns": [
{ "include": "#graphql-comment" },
{ "include": "#graphql-description" },
{ "include": "#graphql-selection-set" },
{ "include": "#graphql-directive" },
{ "include": "#graphql-skip-newlines" },
Expand Down Expand Up @@ -85,8 +87,9 @@
{ "include": "#graphql-comma" }
]
},
{ "include": "#graphql-directive" },
{ "include": "#graphql-comment" },
{ "include": "#graphql-description" },
{ "include": "#graphql-directive" },
{ "include": "#graphql-type-object" },
{ "include": "#literal-quasi-embedded" }
]
Expand All @@ -102,9 +105,9 @@
"1": { "name": "punctuation.operation.graphql"}
},
"patterns": [
{ "include": "#graphql-object-type" },

{ "include": "#graphql-comment" },
{ "include": "#graphql-description" },
{ "include": "#graphql-object-type" },
{ "include": "#graphql-type-definition" },
{ "include": "#literal-quasi-embedded" }
]
Expand All @@ -121,6 +124,7 @@
},
"patterns": [
{ "include": "#graphql-comment" },
{ "include": "#graphql-description" },
{ "include": "#graphql-variable-definitions" },
{ "include": "#graphql-type-object" },
{ "include": "#graphql-colon"},
Expand Down Expand Up @@ -161,26 +165,44 @@
"1": { "name": "support.type.graphql" }
}
},
{ "include": "#graphql-colon" },
{ "include": "#graphql-comment" },
{ "include": "#graphql-description" },
{ "include": "#graphql-colon" },
{ "include": "#graphql-skip-newlines" }
]
},
{ "include": "#graphql-comment" },
{ "include": "#graphql-description" },
{ "include": "#graphql-skip-newlines" }
]
},
{ "include": "#graphql-comment" },
{ "include": "#graphql-description" },
{ "include": "#graphql-skip-newlines" }
]
},
"graphql-comment": {
"comment": "need to prefix comment space with a scope else Atom's reflow cmd doesn't work",
"name": "comment.line.graphql.js",
"match": "(\\s*)(#).*",
"captures": {
"1": { "name": "punctuation.whitespace.comment.leading.graphql" }
}
"name": "comment.line.graphql",
"match": "\\s*#.*"
},
"graphql-description": {
"comment": "In new graphql spec 0.12.0, the description has to enclosed in two lines of triple quotes",
"name": "graphql.description",
"begin": "^\\s*(\"\"\")$",
"beginCaptures": {
"1": { "name": "comment.quoted.double.graphql.begin" }
},
"end": "^\\s*(\"\"\")$",
"endCaptures": {
"1": { "name": "comment.quoted.double.graphql.end" }
},
"patterns": [
{
"name": "comment.line.graphql",
"match": "^\\s*.*$"
}
]
},
"graphql-variable-definitions": {
"begin": "\\s*(\\()",
Expand All @@ -190,6 +212,7 @@
},
"patterns": [
{ "include": "#graphql-comment" },
{ "include": "#graphql-description" },
{ "include": "#graphql-variable-definition"},
{ "include": "#literal-quasi-embedded" }
]
Expand All @@ -207,6 +230,7 @@
},
"patterns": [
{ "include": "#graphql-comment" },
{ "include": "#graphql-description" },
{ "include": "#graphql-colon" },
{ "include": "#graphql-input-types"},
{ "include": "#graphql-variable-assignment"},
Expand All @@ -233,8 +257,9 @@
"2": { "name": "keyword.operator.nulltype.graphql" }
},
"patterns": [
{ "include": "#graphql-input-types" },
{ "include": "#graphql-comment" },
{ "include": "#graphql-description" },
{ "include": "#graphql-input-types" },
{ "include": "#graphql-comma" },
{ "include": "#literal-quasi-embedded" }
]
Expand Down Expand Up @@ -298,8 +323,9 @@
"1": { "name": "entity.name.function.directive.graphql" }
},
"patterns": [
{ "include": "#graphql-arguments"},
{ "include": "#graphql-comment" },
{ "include": "#graphql-description" },
{ "include": "#graphql-arguments"},
{ "include": "#literal-quasi-embedded" },
{ "include": "#graphql-skip-newlines" }
]
Expand All @@ -315,11 +341,12 @@
"1": { "name": "punctuation.operation.graphql"}
},
"patterns": [
{ "include": "#graphql-comment" },
{ "include": "#graphql-description" },
{ "include": "#graphql-field" },
{ "include": "#graphql-fragment-spread" },
{ "include": "#graphql-inline-fragment" },
{ "include": "#graphql-comma" },
{ "include": "#graphql-comment" },
{ "include": "#native-interpolation" },
{ "include": "#literal-quasi-embedded" }
]
Expand Down Expand Up @@ -356,6 +383,7 @@
},
"patterns": [
{ "include": "#graphql-comment" },
{ "include": "#graphql-description" },
{ "include": "#graphql-selection-set" },
{ "include": "#graphql-directive" },
{ "include": "#literal-quasi-embedded" },
Expand All @@ -373,6 +401,7 @@
},
"patterns": [
{ "include": "#graphql-comment" },
{ "include": "#graphql-description" },
{ "include": "#graphql-selection-set" },
{ "include": "#graphql-directive" },
{ "include": "#graphql-skip-newlines" },
Expand All @@ -391,6 +420,7 @@
},
"patterns": [
{ "include": "#graphql-comment" },
{ "include": "#graphql-description" },
{
"begin": "\\s*([_A-Za-z][_0-9A-Za-z]*)(?:\\s*(:))",
"end": "(?=\\s*(?:(?:([_A-Za-z][_0-9A-Za-z]*)\\s*(:))|\\)))|\\s*(,)",
Expand All @@ -402,8 +432,9 @@
"3": { "name": "punctuation.comma.graphql" }
},
"patterns": [
{ "include": "#graphql-value" },
{ "include": "#graphql-comment" },
{ "include": "#graphql-description" },
{ "include": "#graphql-value" },
{ "include": "#graphql-skip-newlines" }
]
},
Expand Down Expand Up @@ -485,6 +516,7 @@
{ "include": "#graphql-object-type" },

{ "include": "#graphql-comment" },
{ "include": "#graphql-description" },
{ "include": "#graphql-enum-value" },
{ "include": "#literal-quasi-embedded" }
]
Expand All @@ -497,6 +529,8 @@
},
"graphql-value":{
"patterns": [
{ "include": "#graphql-comment" },
{ "include": "#graphql-description" },
{ "include": "#graphql-variable-name" },
{ "include": "#graphql-float-value" },
{ "include": "#graphql-string-value" },
Expand All @@ -505,7 +539,6 @@
{ "include": "#graphql-enum-value" },
{ "include": "#graphql-list-value" },
{ "include": "#graphql-object-value" },
{ "include": "#graphql-comment" },
{ "include": "#literal-quasi-embedded" }
]
},
Expand Down Expand Up @@ -572,8 +605,9 @@
"2": { "name": "support.type.graphql" }
},
"patterns": [
{ "include": "#graphql-skip-newlines" },
{ "include": "#graphql-comment" },
{ "include": "#graphql-description" },
{ "include": "#graphql-skip-newlines" },
{ "include": "#literal-quasi-embedded" },
{
"match": "\\s*(\\|)\\s*([_A-Za-z][_0-9A-Za-z]*)",
Expand All @@ -584,8 +618,9 @@
}
]
},
{ "include": "#graphql-skip-newlines" },
{ "include": "#graphql-comment" },
{ "include": "#graphql-description" },
{ "include": "#graphql-skip-newlines" },
{ "include": "#literal-quasi-embedded" }
]
},
Expand Down

0 comments on commit 2420a8a

Please sign in to comment.