├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── grammars └── graphql.json ├── package.json ├── settings └── language-graphql.json ├── snippets └── language-graphql.cson └── spec ├── fixtures └── example.graphql └── grammars └── graphql-spec.coffee /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | scratch*.graphql 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | ### Project specific config ### 2 | language: generic 3 | 4 | env: 5 | global: 6 | - APM_TEST_PACKAGES="" 7 | - ATOM_LINT_WITH_BUNDLED_NODE="true" 8 | 9 | matrix: 10 | - ATOM_CHANNEL=stable 11 | - ATOM_CHANNEL=beta 12 | 13 | os: 14 | - linux 15 | 16 | ### Generic setup follows ### 17 | script: 18 | - curl -s -O https://raw.githubusercontent.com/atom/ci/master/build-package.sh 19 | - chmod u+x build-package.sh 20 | - ./build-package.sh 21 | 22 | notifications: 23 | email: 24 | on_success: never 25 | on_failure: change 26 | 27 | branches: 28 | only: 29 | - master 30 | 31 | git: 32 | depth: 10 33 | 34 | sudo: false 35 | 36 | addons: 37 | apt: 38 | packages: 39 | - build-essential 40 | - git 41 | - libgnome-keyring-dev 42 | - fakeroot 43 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 1.0.0 4 | 5 | * Support SDL descriptions as strings or block strings 6 | 7 | ## 0.11.0 8 | 9 | * Support `.prisma` files 10 | 11 | ## 0.10.1 12 | 13 | * Re-release with proper changelog 14 | 15 | ## 0.10.0 16 | 17 | * Support leading strings and block strings 18 | * Support directives in SDL 19 | * Support `implements ... & ...` 20 | 21 | ## 0.9.0 22 | 23 | * Support `.graphqls` extension 24 | 25 | ## 0.8.0 26 | 27 | * Extract grammar from `language-babel` 28 | 29 | ## 0.6.0, 0.7.0 30 | 31 | * Fix publishing on APM 32 | 33 | ## 0.5.0 34 | 35 | * Add LICENSE to repo 36 | 37 | ## 0.4.0 38 | 39 | * Fix `cmd + /` comments to use `#` 40 | 41 | ## 0.3.0 42 | 43 | * Improve support for schema language 44 | * Improve directive highlights 45 | 46 | ## 0.2.0 47 | 48 | * Fix escaped characters in strings 49 | * Highlight aliases 50 | 51 | ## 0.1.0 - First Release 52 | * Simple GraphQL grammar 53 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Robert Mosolgo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # language-graphql [![Build Status](https://travis-ci.org/rmosolgo/language-graphql.svg?branch=master)](https://travis-ci.org/rmosolgo/language-graphql) [![Version](https://img.shields.io/apm/v/language-graphql.svg)](https://atom.io/packages/language-graphql) 2 | 3 | Atom syntax highlighting for GraphQL, ported from [language-babel](https://github.com/gandm/language-babel). 4 | 5 | ![image](https://cloud.githubusercontent.com/assets/2231765/21265892/9ed466cc-c371-11e6-934f-1579baf24309.png) 6 | 7 | ## Todo 8 | 9 | - Autocompletion based on a JSON or pretty-printed schema. 10 | 11 | ## Development 12 | 13 | - Run tests: `apm test` 14 | - Open with grammar reloading: 15 | - Add the project to Atom's packages `apm link .` 16 | - Open the project in development mode `atom --dev .` 17 | - Create a `scratch.graphql` file to check highlighting 18 | 19 | ## License 20 | 21 | MIT 22 | -------------------------------------------------------------------------------- /grammars/graphql.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "GraphQL", 3 | "scopeName": "source.graphql", 4 | "foldingStartMarker": "(/\\*|{|\\()", 5 | "foldingEndMarker": "(\\*/|\\}|\\))", 6 | "fileTypes": [ 7 | "prisma", 8 | "graphqls", 9 | "graphql", 10 | "gql" 11 | ], 12 | "patterns": [ 13 | { "include": "#graphql" } 14 | ], 15 | "repository": { 16 | "graphql": { 17 | "patterns": [ 18 | { "include": "#graphql-fragment-definition" }, 19 | { "include": "#graphql-type-interface" }, 20 | { "include": "#graphql-enum" }, 21 | { "include": "#graphql-scalar" }, 22 | { "include": "#graphql-union" }, 23 | { "include": "#graphql-schema" }, 24 | { "include": "#graphql-operation-def" }, 25 | { "include": "#graphql-comment" }, 26 | { "include": "#graphql-directive" }, 27 | { "include": "#graphql-blockstring-value"}, 28 | { "include": "#graphql-string-value"} 29 | ] 30 | }, 31 | "graphql-operation-def": { 32 | "patterns": [ 33 | { "include": "#graphql-query-mutation" }, 34 | { "include": "#graphql-name" }, 35 | { "include": "#graphql-variable-definitions" }, 36 | { "include": "#graphql-directive" }, 37 | { "include": "#graphql-selection-set" } 38 | ] 39 | }, 40 | "graphql-fragment-definition": { 41 | "name": "meta.fragment.graphql", 42 | "begin": "\\s*(?:(\\bfragment\\b)\\s*(?!\\bon\\b)([_A-Za-z][_0-9A-Za-z]*)\\s*(?:(\\bon\\b)\\s*([_A-Za-z][_0-9A-Za-z]*)))", 43 | "end": "(?<=})", 44 | "captures": { 45 | "1": { "name": "keyword.fragment.graphql" }, 46 | "2": { "name": "entity.name.fragment.graphql" }, 47 | "3": { "name": "keyword.on.graphql" }, 48 | "4": { "name": "support.type.graphql" } 49 | }, 50 | "patterns": [ 51 | { "include": "#graphql-comment" }, 52 | { "include": "#graphql-selection-set" }, 53 | { "include": "#graphql-directive" }, 54 | { "include": "#graphql-skip-newlines" } 55 | ] 56 | }, 57 | "graphql-query-mutation": { 58 | "match": "\\s*\\b(query|mutation)\\b", 59 | "captures": { 60 | "1": { "name": "keyword.operation.graphql" } 61 | } 62 | }, 63 | "graphql-type-interface": { 64 | "name": "meta.type.interface.graphql", 65 | "begin": "\\s*\\b(?:(extends)?\\b\\s*\\b(type)|(interface)|(input))\\b\\s*([_A-Za-z][_0-9A-Za-z]*)?", 66 | "end": "(?<=})", 67 | "captures": { 68 | "1": { "name": "keyword.type.graphql"}, 69 | "2": { "name": "keyword.type.graphql"}, 70 | "3": { "name": "keyword.interface.graphql"}, 71 | "4": { "name": "keyword.input.graphql"}, 72 | "5": { "name": "support.type.graphql"} 73 | }, 74 | "patterns": [ 75 | { 76 | "match": "\\s*(?:\\b(implements)\\b|(&))\\s*([_A-Za-z][_0-9A-Za-z]*)", 77 | "captures": { 78 | "1": { "name": "keyword.implements.graphql" }, 79 | "2": { "name": "keyword.implements.graphql" }, 80 | "3": { "name": "support.type.graphql" } 81 | } 82 | }, 83 | { "include": "#graphql-comment" }, 84 | { "include": "#graphql-directive" }, 85 | { "include": "#graphql-type-object" } 86 | ] 87 | }, 88 | "graphql-type-object": { 89 | "name": "meta.type.object.graphql", 90 | "begin": "\\s*({)", 91 | "end": "\\s*(})", 92 | "beginCaptures": { 93 | "1": { "name": "punctuation.operation.graphql"} 94 | }, 95 | "endCaptures": { 96 | "1": { "name": "punctuation.operation.graphql"} 97 | }, 98 | "patterns": [ 99 | { "include": "#graphql-object-type" }, 100 | { "include": "#graphql-comment" }, 101 | { "include": "#graphql-type-definition" }, 102 | { "include": "#graphql-blockstring-value"}, 103 | { "include": "#graphql-string-value"} 104 | ] 105 | }, 106 | "graphql-type-definition": { 107 | "comment": "key (optionalArgs): Type", 108 | "begin": "\\s*([_A-Za-z][_0-9A-Za-z]*)(?=\\s*\\(|:)", 109 | "end": "(?=\\s*(([_A-Za-z][_0-9A-Za-z]*)\\s*(\\(|:)|(})))|\\s*(,)", 110 | "beginCaptures": { 111 | "1": { "name": "variable.graphql" } 112 | }, 113 | "endCaptures": { 114 | "5": { "name": "punctuation.comma.graphql" } 115 | }, 116 | "patterns": [ 117 | { "include": "#graphql-directive" }, 118 | { "include": "#graphql-comment" }, 119 | { "include": "#graphql-variable-definitions" }, 120 | { "include": "#graphql-type-object" }, 121 | { "include": "#graphql-colon"}, 122 | { "include": "#graphql-input-types"} 123 | ] 124 | }, 125 | "graphql-schema": { 126 | "begin": "\\s*\\b(schema)\\b", 127 | "end": "(?<=})", 128 | "beginCaptures": { 129 | "1": { "name": "keyword.schema.graphql" } 130 | }, 131 | "patterns": [ 132 | { 133 | "begin": "\\s*({)", 134 | "end": "\\s*(})", 135 | "beginCaptures": { 136 | "1": { "name": "punctuation.operation.graphql"} 137 | }, 138 | "endCaptures": { 139 | "1": { "name": "punctuation.operation.graphql"} 140 | }, 141 | "patterns": [ 142 | { 143 | "begin": "\\s*([_A-Za-z][_0-9A-Za-z]*)(?=\\s*\\(|:)", 144 | "end": "(?=\\s*(([_A-Za-z][_0-9A-Za-z]*)\\s*(\\(|:)|(})))|\\s*(,)", 145 | "beginCaptures": { 146 | "1": { "name": "variable.arguments.graphql" } 147 | }, 148 | "endCaptures": { 149 | "5": { "name": "punctuation.comma.graphql" } 150 | }, 151 | "patterns": [ 152 | { 153 | "match": "\\s*([_A-Za-z][_0-9A-Za-z]*)", 154 | "captures": { 155 | "1": { "name": "support.type.graphql" } 156 | } 157 | }, 158 | { "include": "#graphql-colon" }, 159 | { "include": "#graphql-comment" }, 160 | { "include": "#graphql-directive" }, 161 | { "include": "#graphql-skip-newlines" } 162 | ] 163 | }, 164 | { "include": "#graphql-comment" }, 165 | { "include": "#graphql-skip-newlines" } 166 | ] 167 | }, 168 | { "include": "#graphql-directive" }, 169 | { "include": "#graphql-comment" }, 170 | { "include": "#graphql-skip-newlines" } 171 | ] 172 | }, 173 | "graphql-comment": { 174 | "comment": "need to prefix comment space with a scope else Atom's reflow cmd doesn't work", 175 | "name": "comment.line.graphql.js", 176 | "match": "(\\s*)(#).*", 177 | "captures": { 178 | "1": { "name": "punctuation.whitespace.comment.leading.graphql" } 179 | } 180 | }, 181 | "graphql-variable-definitions": { 182 | "begin": "\\s*(\\()", 183 | "end": "\\s*(\\))", 184 | "captures": { 185 | "1": { "name": "meta.brace.round.graphql"} 186 | }, 187 | "patterns": [ 188 | { "include": "#graphql-comment" }, 189 | { "include": "#graphql-variable-definition"}, 190 | { "include": "#graphql-blockstring-value"}, 191 | { "include": "#graphql-string-value"} 192 | ] 193 | }, 194 | "graphql-variable-definition": { 195 | "comment": "variable: type = value,.... which may be a list", 196 | "name": "meta.variables.graphql", 197 | "begin": "\\s*(\\$?[_A-Za-z][_0-9A-Za-z]*)(?=\\s*\\(|:)", 198 | "end": "(?=\\s*((\\$?[_A-Za-z][_0-9A-Za-z]*)\\s*(\\(|:)|(}|\\))))|\\s*(,)", 199 | "beginCaptures": { 200 | "1": { "name": "variable.graphql" } 201 | }, 202 | "endCaptures": { 203 | "5": { "name": "punctuation.comma.graphql" } 204 | }, 205 | "patterns": [ 206 | { "include": "#graphql-comment" }, 207 | { "include": "#graphql-colon" }, 208 | { "include": "#graphql-input-types"}, 209 | { "include": "#graphql-variable-assignment"}, 210 | { "include": "#graphql-skip-newlines" } 211 | ] 212 | }, 213 | "graphql-input-types": { 214 | "patterns": [ 215 | { "include": "#graphql-scalar-type" }, 216 | { 217 | "match": "\\s*([_A-Za-z][_0-9A-Za-z]*)(?:\\s*(!))?", 218 | "captures": { 219 | "1": { "name": "support.type.graphql" }, 220 | "2": { "name": "keyword.operator.nulltype.graphql" } 221 | } 222 | }, 223 | { 224 | "name": "meta.type.list.graphql", 225 | "begin": "\\s*(\\[)", 226 | "end": "\\s*(\\])(?:\\s*(!))?", 227 | "captures": { 228 | "1": { "name": "meta.brace.squart.graphql" }, 229 | "2": { "name": "keyword.operator.nulltype.graphql" } 230 | }, 231 | "patterns": [ 232 | { "include": "#graphql-input-types" }, 233 | { "include": "#graphql-comment" }, 234 | { "include": "#graphql-comma" } 235 | ] 236 | } 237 | ] 238 | }, 239 | "graphql-scalar": { 240 | "match": "\\s*\\b(scalar)\\b\\s*([_A-Za-z][_0-9A-Za-z]*)", 241 | "captures": { 242 | "1": { "name": "keyword.scalar.graphql" }, 243 | "2": { "name": "entity.scalar.graphql" } 244 | } 245 | }, 246 | "graphql-scalar-type": { 247 | "match": "\\s*\\b(Int|Float|String|Boolean|ID)\\b(?:\\s*(!))?", 248 | "captures": { 249 | "1": { "name": "support.type.builtin.graphql" }, 250 | "2": { "name": "keyword.operator.nulltype.graphql" } 251 | } 252 | }, 253 | "graphql-variable-assignment": { 254 | "begin": "\\s(=)", 255 | "end": "(?=.)", 256 | "applyEndPatternLast": 1, 257 | "beginCaptures": { 258 | "1": { "name": "punctuation.assignment.graphql" } 259 | }, 260 | "patterns": [ 261 | { "include": "#graphql-value" } 262 | ] 263 | }, 264 | "graphql-comma": { 265 | "match": "\\s*(,)", 266 | "captures": { 267 | "1": { "name": "punctuation.comma.graphql" } 268 | } 269 | }, 270 | "graphql-colon": { 271 | "match": "\\s*(:)", 272 | "captures": { 273 | "1": { "name": "punctuation.colon.graphql" } 274 | } 275 | }, 276 | "graphql-union-mark": { 277 | "match": "\\s*(\\|)", 278 | "captures": { 279 | "1": { "name": "punctuation.union.graphql" } 280 | } 281 | }, 282 | "graphql-name": { 283 | "match": "\\s*([_A-Za-z][_0-9A-Za-z]*)", 284 | "captures": { 285 | "1": { "name": "entity.name.function.graphql" } 286 | } 287 | }, 288 | "graphql-directive": { 289 | "begin": "\\s*((@)\\s*([_A-Za-z][_0-9A-Za-z]*))", 290 | "end": "(?=.)", 291 | "applyEndPatternLast": 1, 292 | "beginCaptures": { 293 | "1": { "name": "entity.name.function.directive.graphql" } 294 | }, 295 | "patterns": [ 296 | { "include": "#graphql-arguments"}, 297 | { "include": "#graphql-comment" }, 298 | { "include": "#graphql-skip-newlines" } 299 | ] 300 | }, 301 | "graphql-selection-set": { 302 | "name": "meta.selectionset.graphql", 303 | "begin": "\\s*({)", 304 | "end": "\\s*(})", 305 | "beginCaptures": { 306 | "1": { "name": "punctuation.operation.graphql"} 307 | }, 308 | "endCaptures": { 309 | "1": { "name": "punctuation.operation.graphql"} 310 | }, 311 | "patterns": [ 312 | { "include": "#graphql-field" }, 313 | { "include": "#graphql-fragment-spread" }, 314 | { "include": "#graphql-inline-fragment" }, 315 | { "include": "#graphql-comma" }, 316 | { "include": "#graphql-comment" } 317 | ] 318 | }, 319 | "graphql-field": { 320 | "patterns": [ 321 | { 322 | "match": "\\s*([_A-Za-z][_0-9A-Za-z]*)\\s*(:)", 323 | "captures": { 324 | "1": { "name": "string.unquoted.alias.graphql" }, 325 | "2": { "name": "punctuation.colon.graphql" } 326 | } 327 | }, 328 | { 329 | "match": "\\s*([_A-Za-z][_0-9A-Za-z]*)", 330 | "captures": { 331 | "1": { "name": "variable.graphql" } 332 | } 333 | }, 334 | { "include": "#graphql-arguments" }, 335 | { "include": "#graphql-directive" }, 336 | { "include": "#graphql-selection-set" }, 337 | { "include": "#graphql-skip-newlines" } 338 | ] 339 | }, 340 | "graphql-fragment-spread": { 341 | "begin": "\\s*(\\.\\.\\.)\\s*(?!\\bon\\b)([_A-Za-z][_0-9A-Za-z]*)", 342 | "end": "(?=.)", 343 | "applyEndPatternLast": 1, 344 | "captures": { 345 | "1": { "name": "keyword.operator.spread.graphql" }, 346 | "2": { "name": "variable.fragment.graphql" } 347 | }, 348 | "patterns": [ 349 | { "include": "#graphql-comment" }, 350 | { "include": "#graphql-selection-set" }, 351 | { "include": "#graphql-directive" }, 352 | { "include": "#graphql-skip-newlines" } 353 | ] 354 | }, 355 | "graphql-inline-fragment": { 356 | "begin": "\\s*(\\.\\.\\.)\\s*(?:(\\bon\\b)\\s*([_A-Za-z][_0-9A-Za-z]*))?", 357 | "end": "(?=.)", 358 | "applyEndPatternLast": 1, 359 | "captures": { 360 | "1": { "name": "keyword.operator.spread.graphql" }, 361 | "2": { "name": "keyword.on.graphql" }, 362 | "3": { "name": "support.type.graphql" } 363 | }, 364 | "patterns": [ 365 | { "include": "#graphql-comment" }, 366 | { "include": "#graphql-selection-set" }, 367 | { "include": "#graphql-directive" }, 368 | { "include": "#graphql-skip-newlines" } 369 | ] 370 | }, 371 | "graphql-arguments": { 372 | "name": "meta.arguments.graphql", 373 | "begin": "\\s*(\\()", 374 | "end": "\\s*(\\))", 375 | "beginCaptures": { 376 | "1": { "name": "meta.brace.round.directive.graphql" } 377 | }, 378 | "endCaptures": { 379 | "1": { "name": "meta.brace.round.directive.graphql" } 380 | }, 381 | "patterns": [ 382 | { "include": "#graphql-comment" }, 383 | { 384 | "begin": "\\s*([_A-Za-z][_0-9A-Za-z]*)(?:\\s*(:))?", 385 | "end": "(?=\\s*(?:(?:([_A-Za-z][_0-9A-Za-z]*)\\s*(:))|\\)))|\\s*(,)", 386 | "beginCaptures": { 387 | "1": { "name": "variable.arguments.graphql" }, 388 | "2": { "name": "punctuation.colon.graphql" } 389 | }, 390 | "endCaptures": { 391 | "3": { "name": "punctuation.comma.graphql" } 392 | }, 393 | "patterns": [ 394 | { "include": "#graphql-value" }, 395 | { "include": "#graphql-comment" }, 396 | { "include": "#graphql-skip-newlines" } 397 | ] 398 | } 399 | ] 400 | }, 401 | "graphql-variable-name": { 402 | "match": "\\s*(\\$[_A-Za-z][_0-9A-Za-z]*)", 403 | "captures": { 404 | "1": { "name": "variable.graphql" } 405 | } 406 | }, 407 | "graphql-int-value": { 408 | "match": "\\s*((-)?(0|[1-9][0-9]*))", 409 | "captures": { 410 | "1": { "name": "constant.int.graphql" } 411 | } 412 | }, 413 | "graphql-float-value": { 414 | "match": "\\s*((-)?(0|([1-9]\\d*)(\\.\\d*)?((e|E)(\\+|-)?\\d*)?))", 415 | "captures": { 416 | "1": { "name": "constant.float.graphql" } 417 | } 418 | }, 419 | "graphql-boolean-value": { 420 | "match": "\\s*\\b(true|false)\\b", 421 | "captures": { 422 | "1": { "name": "constant.boolean.graphql" } 423 | } 424 | }, 425 | "graphql-blockstring-value": { 426 | "contentName": "string.quoted.block.graphql", 427 | "begin": "\\s*+((\"\"\"))", 428 | "end": "\\s*+(?:((\"\"\")))", 429 | "beginCaptures": { 430 | "1": { "name": "string.quoted.block.graphql" }, 431 | "2": { "name": "punctuation.definition.string.begin.graphql" } 432 | }, 433 | "endCaptures": { 434 | "1": { "name": "string.quoted.block.graphql" }, 435 | "2": { "name": "punctuation.definition.string.end.graphql" } 436 | }, 437 | "patterns": [ 438 | { "include": "#graphql-string-content" } 439 | ] 440 | }, 441 | "graphql-string-value": { 442 | "contentName": "string.quoted.double.graphql", 443 | "begin": "\\s*+((\"))", 444 | "end": "\\s*+(?:((\"))|(\n))", 445 | "beginCaptures": { 446 | "1": { "name": "string.quoted.double.graphql" }, 447 | "2": { "name": "punctuation.definition.string.begin.graphql" } 448 | }, 449 | "endCaptures": { 450 | "1": { "name": "string.quoted.double.graphql" }, 451 | "2": { "name": "punctuation.definition.string.end.graphql" }, 452 | "3": { "name": "invalid.illegal.newline.graphql" } 453 | }, 454 | "patterns": [ 455 | { "include": "#graphql-string-content" } 456 | ] 457 | }, 458 | "graphql-string-content": { 459 | "patterns": [ 460 | { "name": "constant.character.escape.graphql", 461 | "match": "\\\\[/'\"\\\\nrtbf]" 462 | }, 463 | { "name": "constant.character.escape.graphql", 464 | "match": "\\\\u([0-9a-fA-F]{4})" 465 | } 466 | ] 467 | }, 468 | "graphql-enum": { 469 | "name": "meta.enum.graphql", 470 | "begin": "\\s*+\\b(enum)\\b\\s*([_A-Za-z][_0-9A-Za-z]*)", 471 | "end": "(?<=})", 472 | "beginCaptures": { 473 | "1": { "name": "keyword.enum.graphql" }, 474 | "2": { "name": "support.type.enum.graphql" } 475 | }, 476 | "patterns": [ 477 | { 478 | "name": "meta.type.object.graphql", 479 | "begin": "\\s*({)", 480 | "end": "\\s*(})", 481 | "beginCaptures": { 482 | "1": { "name": "punctuation.operation.graphql"} 483 | }, 484 | "endCaptures": { 485 | "1": { "name": "punctuation.operation.graphql"} 486 | }, 487 | "patterns": [ 488 | { "include": "#graphql-object-type" }, 489 | { "include": "#graphql-comment" }, 490 | { "include": "#graphql-enum-value" }, 491 | { "include": "#graphql-blockstring-value"}, 492 | { "include": "#graphql-string-value"} 493 | ] 494 | } 495 | ] 496 | }, 497 | "graphql-enum-value": { 498 | "name": "constant.character.enum.graphql", 499 | "match":"\\s*(?!=\\b(true|false|null)\\b)([_A-Za-z][_0-9A-Za-z]*)" 500 | }, 501 | "graphql-value":{ 502 | "patterns": [ 503 | { "include": "#graphql-variable-name" }, 504 | { "include": "#graphql-float-value" }, 505 | { "include": "#graphql-int-value" }, 506 | { "include": "#graphql-blockstring-value" }, 507 | { "include": "#graphql-string-value" }, 508 | { "include": "#graphql-boolean-value" }, 509 | { "include": "#graphql-enum-value" }, 510 | { "include": "#graphql-list-value" }, 511 | { "include": "#graphql-object-value" }, 512 | { "include": "#graphql-comment" }, 513 | { "include": "#literal-quasi-embedded" } 514 | ] 515 | }, 516 | "graphql-list-value": { 517 | "patterns": [ 518 | { 519 | "name": "meta.listvalues.graphql", 520 | "begin": "\\s*+(\\[)", 521 | "end": "\\s*(\\])", 522 | "endCaptures": { 523 | "1": { "name": "meta.brace.square.graphql" } 524 | }, 525 | "beginCaptures": { 526 | "1": { "name": "meta.brace.square.graphql" } 527 | }, 528 | "patterns": [ 529 | { "include": "#graphql-value" } 530 | ] 531 | } 532 | ] 533 | }, 534 | "graphql-object-value": { 535 | "patterns": [ 536 | { 537 | "name": "meta.objectvalues.graphql", 538 | "begin": "\\s*+({)", 539 | "end": "\\s*(})", 540 | "endCaptures": { 541 | "1": { "name": "meta.brace.curly.graphql" } 542 | }, 543 | "beginCaptures": { 544 | "1": { "name": "meta.brace.curly.graphql" } 545 | }, 546 | "patterns": [ 547 | { "include": "#graphql-object-field" }, 548 | { "include": "#graphql-value" } 549 | ] 550 | } 551 | ] 552 | }, 553 | "graphql-object-field": { 554 | "match": "\\s*(([_A-Za-z][_0-9A-Za-z]*))\\s*(:)", 555 | "captures": { 556 | "1": { "name": "constant.object.key.graphql" }, 557 | "2": { "name": "string.unquoted.graphql" }, 558 | "3": { "name": "punctuation.graphql" } 559 | } 560 | }, 561 | "graphql-union": { 562 | "begin": "\\s*\\b(union)\\b\\s*([_A-Za-z][_0-9A-Za-z]*)", 563 | "end": "(?=.)", 564 | "applyEndPatternLast": 1, 565 | "captures": { 566 | "1": { "name": "keyword.union.graphql" }, 567 | "2": { "name": "support.type.graphql" } 568 | }, 569 | "patterns": [ 570 | { 571 | "begin": "\\s*(=)\\s*([_A-Za-z][_0-9A-Za-z]*)", 572 | "end": "(?=.)", 573 | "applyEndPatternLast": 1, 574 | "captures": { 575 | "1": { "name": "punctuation.assignment.graphql" }, 576 | "2": { "name": "support.type.graphql" } 577 | }, 578 | "patterns": [ 579 | { "include": "#graphql-skip-newlines" }, 580 | { "include": "#graphql-comment" }, 581 | { 582 | "match": "\\s*(\\|)\\s*([_A-Za-z][_0-9A-Za-z]*)", 583 | "captures": { 584 | "1": { "name": "punctuation.or.graphql" }, 585 | "2": { "name": "support.type.graphql" } 586 | } 587 | } 588 | ] 589 | }, 590 | { "include": "#graphql-skip-newlines" }, 591 | { "include": "#graphql-comment" }, 592 | { "include": "#literal-quasi-embedded" } 593 | ] 594 | }, 595 | "graphql-skip-newlines": { 596 | "match": "\\s*\n" 597 | } 598 | } 599 | } 600 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "language-graphql", 3 | "version": "1.0.0", 4 | "description": "Syntax highlighting for GraphQL queries", 5 | "keywords": [ 6 | "language", 7 | "grammar", 8 | "graphql", 9 | "atom" 10 | ], 11 | "repository": "https://github.com/rmosolgo/language-graphql", 12 | "license": "MIT", 13 | "engines": { 14 | "atom": ">=1.0.0 <2.0.0" 15 | }, 16 | "devDependencies": { 17 | "atom-grammar-test": "^0.6.3" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /settings/language-graphql.json: -------------------------------------------------------------------------------- 1 | { 2 | ".source.graphql": { 3 | "editor": { 4 | "commentStart": "# " 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /snippets/language-graphql.cson: -------------------------------------------------------------------------------- 1 | # If you want some example snippets, check out: 2 | # https://github.com/atom/language-gfm/blob/master/snippets/gfm.cson 3 | 4 | '.source.graphql': 5 | 'Method documentation': 6 | 'prefix': 'doc' 7 | 'body': '@@ ${1:method} - ${2:description}' 8 | -------------------------------------------------------------------------------- /spec/fixtures/example.graphql: -------------------------------------------------------------------------------- 1 | ## SYNTAX TEST "source.graphql" 2 | 3 | fragment on AnalysisImage @relay(plural: true) { 4 | ## ^^^^^^^^ ^^ ^^^^^^^^^^^^^ entity.name.function.graphql 5 | ## ^^^^^^ entity.name.function.directive.graphql 6 | ## ^^^^^^^^ ^^^^^ meta.arguments.graphql 7 | ## ^ ^ meta.brace.round.directive.graphql 8 | ## ^^^^^^ variable.arguments.graphql 9 | ## ^ punctuation.colon.graphql 10 | ## ^^^^ constant.boolean.graphql 11 | ## ^ meta.selectionset.graphql 12 | ## ^ punctuation.operation.graphql 13 | extension 14 | ## ^^^^^^^^^ meta.selectionset.graphql 15 | ## ^^^^^^^^^ variable.graphql 16 | href 17 | ## ^^^^ meta.selectionset.graphql 18 | ## ^^^^ variable.graphql 19 | } 20 | ## ^ meta.selectionset.graphql 21 | ## ^ punctuation.operation.graphql 22 | 23 | # this is a comment 24 | ##^ ^^^^ ^^ ^ ^^^^^^^ comment.line.graphql.js 25 | interface Character { 26 | ##^^^^^^^^^ ^^^^^^^^^ ^ meta.type.interface.graphql 27 | ##^^^^^^^^^ keyword.interface.graphql 28 | ## ^^^^^^^^^ support.type.graphql 29 | ## ^ meta.type.object.graphql 30 | ## ^ punctuation.operation.graphql 31 | id: ID! 32 | ## ^^^ ^^^ meta.type.interface.graphql 33 | ## ^^^ ^^^ meta.type.object.graphql 34 | ## ^^ variable.graphql 35 | ## ^ punctuation.colon.graphql 36 | ## ^^ support.type.builtin.graphql 37 | ## ^ keyword.operator.nulltype.graphql 38 | name: String! 39 | ## ^^^^^ ^^^^^^^ meta.type.interface.graphql 40 | ## ^^^^^ ^^^^^^^ meta.type.object.graphql 41 | ## ^^^^ variable.graphql 42 | ## ^ punctuation.colon.graphql 43 | ## ^^^^^^ support.type.builtin.graphql 44 | ## ^ keyword.operator.nulltype.graphql 45 | friends: [Character] 46 | ## ^^^^^^^^ ^^^^^^^^^^^ meta.type.interface.graphql 47 | ## ^^^^^^^^ ^^^^^^^^^^^ meta.type.object.graphql 48 | ## ^^^^^^^ variable.graphql 49 | ## ^ punctuation.colon.graphql 50 | ## ^^^^^^^^^^^ meta.type.list.graphql 51 | ## ^ ^ meta.brace.squart.graphql 52 | ## ^^^^^^^^^ support.type.graphql 53 | appearsIn: [Episode]! 54 | ## ^^^^^^^^^^ ^^^^^^^^^^ meta.type.interface.graphql 55 | ## ^^^^^^^^^^ ^^^^^^^^^^ meta.type.object.graphql 56 | ## ^^^^^^^^^ variable.graphql 57 | ## ^ punctuation.colon.graphql 58 | ## ^^^^^^^^^^ meta.type.list.graphql 59 | ## ^ ^ meta.brace.squart.graphql 60 | ## ^^^^^^^ support.type.graphql 61 | ## ^ keyword.operator.nulltype.graphql 62 | } 63 | ##^ meta.type.interface.graphql 64 | ##^ meta.type.object.graphql 65 | ##^ punctuation.operation.graphql 66 | 67 | schema { 68 | ##^^^^^^ keyword.schema.graphql 69 | ## ^ punctuation.operation.graphql 70 | widget: Widget @dir(x: Y) 71 | ## ^^^ entity.name.function.directive.graphql 72 | ## ^ ^ meta.arguments.graphql 73 | ## ^^^^^^ variable.arguments.graphql 74 | ## ^ punctuation.colon.graphql 75 | ## ^^^^^^ support.type.graphql 76 | } 77 | ## ^ punctuation.operation.graphql 78 | schema @dir(ok: true) { 79 | ##^^^^^^ keyword.schema.graphql 80 | ## ^^^ entity.name.function.directive.graphql 81 | ## ^^^ ^^^^ meta.arguments.graphql 82 | ## ^ ^ meta.brace.round.directive.graphql 83 | ## ^ punctuation.operation.graphql 84 | } 85 | 86 | type Starship implements Character & Other @dir(x: Y){ 87 | ##^^^^ ^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^^ ^ meta.type.interface.graphql 88 | ##^^^^ keyword.type.graphql 89 | ## ^^^^^^^^ ^^^^^^^^^ ^^^^^ support.type.graphql 90 | ## ^^^^^^^^^^ ^ keyword.implements.graphql 91 | ## ^ meta.type.object.graphql 92 | ## ^ punctuation.operation.graphql 93 | ## ^^^ entity.name.function.directive.graphql 94 | ## ^ ^ meta.arguments.graphql 95 | id: ID! 96 | ## ^^^ ^^^ meta.type.interface.graphql 97 | ## ^^^ ^^^ meta.type.object.graphql 98 | ## ^^ variable.graphql 99 | ## ^ punctuation.colon.graphql 100 | ## ^^ support.type.builtin.graphql 101 | ## ^ keyword.operator.nulltype.graphql 102 | name: String! @dir(ok: true) 103 | ## ^^^^^ ^^^^^^^ meta.type.interface.graphql 104 | ## ^^^^^ ^^^^^^^ meta.type.object.graphql 105 | ## ^^^^ variable.graphql 106 | ## ^ punctuation.colon.graphql 107 | ## ^^^^^^ support.type.builtin.graphql 108 | ## ^ keyword.operator.nulltype.graphql 109 | ## ^^^ entity.name.function.directive.graphql 110 | ## ^^^ ^^^^ meta.arguments.graphql 111 | length(unit: LengthUnit = METER): Float 112 | ## ^^^^^^^^^^^^ ^^^^^^^^^^ ^ ^^^^^^^ ^^^^^ meta.type.interface.graphql 113 | ## ^^^^^^^^^^^^ ^^^^^^^^^^ ^ ^^^^^^^ ^^^^^ meta.type.object.graphql 114 | ## ^^^^^^ ^^^^ variable.graphql 115 | ## ^ ^ meta.brace.round.graphql 116 | ## ^^^^^ ^^^^^^^^^^ ^ ^^^^^ meta.variables.graphql 117 | ## ^ ^ punctuation.colon.graphql 118 | ## ^^^^^^^^^^ support.type.graphql 119 | ## ^ punctuation.assignment.graphql 120 | ## ^^^^^ constant.character.enum.graphql 121 | ## ^^^^^ support.type.builtin.graphql 122 | } 123 | ## ^ meta.type.interface.graphql 124 | ## ^ meta.type.object.graphql 125 | ## ^ punctuation.operation.graphql 126 | input Starship { 127 | ## ^^^^^ ^^^^^^^^ ^ meta.type.interface.graphql 128 | ## ^^^^^ keyword.input.graphql 129 | ## ^^^^^^^^ support.type.graphql 130 | ## ^ meta.type.object.graphql 131 | ## ^ punctuation.operation.graphql 132 | id: ID! 133 | ## ^^^ ^^^ meta.type.interface.graphql 134 | ## ^^^ ^^^ meta.type.object.graphql 135 | ## ^^ variable.graphql 136 | ## ^ punctuation.colon.graphql 137 | ## ^^ support.type.builtin.graphql 138 | ## ^ keyword.operator.nulltype.graphql 139 | name: String! 140 | ## ^^^^^ ^^^^^^^ meta.type.interface.graphql 141 | ## ^^^^^ ^^^^^^^ meta.type.object.graphql 142 | ## ^^^^ variable.graphql 143 | ## ^ punctuation.colon.graphql 144 | ## ^^^^^^ support.type.builtin.graphql 145 | ## ^ keyword.operator.nulltype.graphql 146 | length(unit: LengthUnit = METER): Float 147 | ## ^^^^^^^^^^^^ ^^^^^^^^^^ ^ ^^^^^^^ ^^^^^ meta.type.interface.graphql 148 | ## ^^^^^^^^^^^^ ^^^^^^^^^^ ^ ^^^^^^^ ^^^^^ meta.type.object.graphql 149 | ## ^^^^^^ ^^^^ variable.graphql 150 | ## ^ ^ meta.brace.round.graphql 151 | ## ^^^^^ ^^^^^^^^^^ ^ ^^^^^ meta.variables.graphql 152 | ## ^ ^ punctuation.colon.graphql 153 | ## ^^^^^^^^^^ support.type.graphql 154 | ## ^ punctuation.assignment.graphql 155 | ## ^^^^^ constant.character.enum.graphql 156 | ## ^^^^^ support.type.builtin.graphql 157 | } 158 | ##^ meta.type.interface.graphql 159 | ##^ meta.type.object.graphql 160 | ##^ punctuation.operation.graphql 161 | enum Episode { 162 | ## ^^^^ ^^^^^^^ ^ meta.enum.graphql 163 | ## ^^^^ keyword.enum.graphql 164 | ## ^^^^^^^ support.type.enum.graphql 165 | ## ^ meta.type.object.graphql 166 | ## ^ punctuation.operation.graphql 167 | NEWHOPE 168 | ## ^^^^^^^ meta.enum.graphql 169 | ## ^^^^^^^ meta.type.object.graphql 170 | ## ^^^^^^^ constant.character.enum.graphql 171 | """ 172 | ## ^^^ punctuation.definition.string.begin.graphql 173 | Enum value description 174 | ## ^^^^ ^^^^^ ^^^^^^^^^^^ string.quoted.block.graphql 175 | """ 176 | ## ^^^ punctuation.definition.string.end.graphql 177 | 178 | EMPIRE 179 | ## ^^^^^^ meta.enum.graphql 180 | ## ^^^^^^ meta.type.object.graphql 181 | ## ^^^^^^ constant.character.enum.graphql 182 | JEDI 183 | ## ^^^^ meta.enum.graphql 184 | ## ^^^^ meta.type.object.graphql 185 | ## ^^^^ constant.character.enum.graphql 186 | } 187 | ## ^ meta.enum.graphql 188 | ## ^ meta.type.object.graphql 189 | ## ^ punctuation.operation.graphql 190 | 191 | type Thing { 192 | "Field documentation" 193 | ## ^ punctuation.definition.string.begin.graphql 194 | ## ^^^^^ ^^^^^^^^^^^^^ string.quoted.double.graphql 195 | ## ^ punctuation.definition.string.end.graphql 196 | someField: SomeReturnType 197 | anotherField( 198 | """ 199 | ## ^^^ punctuation.definition.string.begin.graphql 200 | ## ^^^ string.quoted.block.graphql 201 | Argument documentation 202 | ## ^^^^^^^^ ^^^^^^^^^^^^^ string.quoted.block.graphql 203 | """ 204 | ## ^^^ punctuation.definition.string.end.graphql 205 | ## ^^^ string.quoted.block.graphql 206 | argument: Int 207 | ): SomeReturnType 208 | } 209 | scalar Date @dir(x: Y) 210 | ##^^^^^^ keyword.scalar.graphql 211 | ## ^^^^ entity.scalar.graphql 212 | ## ^^^ entity.name.function.directive.graphql 213 | ## ^ ^ meta.arguments.graphql 214 | """ 215 | ##^^^ punctuation.definition.string.begin.graphql 216 | ##^^^ string.quoted.block.graphql 217 | Type Description 218 | ##^^^^ ^^^^^^^^^^^ string.quoted.block.graphql 219 | """ 220 | ##^^^ punctuation.definition.string.end.graphql 221 | ##^^^ string.quoted.block.graphql 222 | 223 | "Inline type description" 224 | ##^ punctuation.definition.string.begin.graphql 225 | ## ^^^^^^ ^^^^ ^^^^^^^^^^^ string.quoted.double.graphql 226 | ## ^ punctuation.definition.string.end.graphql 227 | union SearchResult = Human # maybe spans 228 | ##^^^^^ keyword.union.graphql 229 | ## ^^^^^^^^^^^^ ^^^^^ support.type.graphql 230 | ## ^ punctuation.assignment.graphql 231 | ## ^ ^^^^^ ^^^^^ comment.line.graphql.js 232 | | Droid # more 233 | ## ^ punctuation.or.graphql 234 | ## ^^^^^ support.type.graphql 235 | ## ^ ^^^^ comment.line.graphql.js 236 | | Starship #than one line 237 | ## ^ punctuation.or.graphql 238 | ## ^^^^^^^^ support.type.graphql 239 | ## ^^^^^ ^^^ ^^^^ comment.line.graphql.js 240 | 241 | mutation {} 242 | ##^^^^^^^^ keyword.operation.graphql 243 | ## ^^ meta.selectionset.graphql 244 | ## ^^ punctuation.operation.graphql 245 | fragment FragmentName on Type @directives() { 246 | ##^^^^^^^^ ^^^^^^^^^^^^ ^^ ^^^^ ^^^^^^^^^^^^^ ^ meta.fragment.graphql 247 | ##^^^^^^^^ keyword.fragment.graphql 248 | ## ^^^^^^^^^^^^ entity.name.fragment.graphql 249 | ## ^^ keyword.on.graphql 250 | ## ^^^^ support.type.graphql 251 | ## ^^^^^^^^^^^ entity.name.function.directive.graphql 252 | ## ^^ meta.arguments.graphql 253 | ## ^^ meta.brace.round.directive.graphql 254 | ## ^ meta.selectionset.graphql 255 | ## ^ punctuation.operation.graphql 256 | 257 | } 258 | ##^ meta.fragment.graphql 259 | ##^ meta.selectionset.graphql 260 | ##^ punctuation.operation.graphql 261 | 262 | query 263 | ##^^^^^ keyword.operation.graphql 264 | queryName( 265 | ## ^^^^^^^^^ entity.name.function.graphql 266 | ## ^ meta.brace.round.graphql 267 | # comment 268 | ## ^ ^^^^^^^ comment.line.graphql.js 269 | $int: = 0 270 | ## ^^^^^ ^ ^ meta.variables.graphql 271 | ## ^^^^ variable.graphql 272 | ## ^ punctuation.colon.graphql 273 | ## ^ punctuation.assignment.graphql 274 | ## ^ constant.float.graphql 275 | $float: f = 123.011e-1, $float: f = 123.00, $float: f = 123e+20 276 | ## ^^^^^^^ ^ ^ ^^^^^^^^^^^ ^^^^^^^ ^ ^ ^^^^^^^ ^^^^^^^ ^ ^ ^^^^^^^ meta.variables.graphql 277 | ## ^^^^^^ ^^^^^^ ^^^^^^ variable.graphql 278 | ## ^ ^ ^ punctuation.colon.graphql 279 | ## ^ ^ ^ support.type.graphql 280 | ## ^ ^ ^ punctuation.assignment.graphql 281 | ## ^^^^^^^^^^ ^^^^^^ ^^^^^^^ constant.float.graphql 282 | ## ^ ^ punctuation.comma.graphql 283 | $boolean: b ! = true, $boolean: b = false 284 | ## ^^^^^^^^^ ^ ^ ^ ^^^^^ ^^^^^^^^^ ^ ^ ^^^^^ meta.variables.graphql 285 | ## ^^^^^^^^ ^^^^^^^^ variable.graphql 286 | ## ^ ^ punctuation.colon.graphql 287 | ## ^ ^ support.type.graphql 288 | ## ^ keyword.operator.nulltype.graphql 289 | ## ^ ^ punctuation.assignment.graphql 290 | ## ^^^^ ^^^^^ constant.boolean.graphql 291 | ## ^ punctuation.comma.graphql 292 | $String: s = "Some string \" \\ \/ \b \f \r \r and the rest" 293 | ## ^^^^^^^^ ^ ^ ^^^^^ ^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^^^^ meta.variables.graphql 294 | ## ^^^^^^^ variable.graphql 295 | ## ^ punctuation.colon.graphql 296 | ## ^ support.type.graphql 297 | ## ^ punctuation.assignment.graphql 298 | ## ^^^^^ ^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^^^^ string.quoted.double.graphql 299 | ## ^ punctuation.definition.string.begin.graphql 300 | ## ^^ ^^ ^^ ^^ ^^ ^^ ^^ constant.character.escape.graphql 301 | ## ^ punctuation.definition.string.end.graphql 302 | $enum: e = aaaa, $enum: e = AAAA_AA 303 | ## ^^^^^^ ^ ^ ^^^^^ ^^^^^^ ^ ^ ^^^^^^^ meta.variables.graphql 304 | ## ^^^^^ ^^^^^ variable.graphql 305 | ## ^ ^ punctuation.colon.graphql 306 | ## ^ ^ support.type.graphql 307 | ## ^ ^ punctuation.assignment.graphql 308 | ## ^^^^ ^^^^^^^ constant.character.enum.graphql 309 | ## ^ punctuation.comma.graphql 310 | $list : [ String!, Boolean!, ID, Int, Float ] ! = ["aaa", 1 , aFlag] 311 | ## ^^^^^ ^ ^ ^^^^^^^^ ^^^^^^^^^ ^^^ ^^^^ ^^^^^ ^ ^ ^ ^^^^^^^ ^ ^ ^^^^^^ meta.variables.graphql 312 | ## ^^^^^ variable.graphql 313 | ## ^ punctuation.colon.graphql 314 | ## ^ ^^^^^^^^ ^^^^^^^^^ ^^^ ^^^^ ^^^^^ ^ ^ meta.type.list.graphql 315 | ## ^ ^ meta.brace.squart.graphql 316 | ## ^^^^^^ ^^^^^^^ ^^ ^^^ ^^^^^ support.type.builtin.graphql 317 | ## ^ ^ ^ keyword.operator.nulltype.graphql 318 | ## ^ ^ ^ ^ punctuation.comma.graphql 319 | ## ^ punctuation.assignment.graphql 320 | ## ^^^^^^^ ^ ^ ^^^^^^ meta.listvalues.graphql 321 | ## ^ ^ meta.brace.square.graphql 322 | ## ^^^^^ string.quoted.double.graphql 323 | ## ^ punctuation.definition.string.begin.graphql 324 | ## ^ punctuation.definition.string.end.graphql 325 | ## ^ constant.float.graphql 326 | ## ^^^^^ constant.character.enum.graphql 327 | $object: o = { 328 | ## ^^^^^^^^ ^ ^ ^ meta.variables.graphql 329 | ## ^^^^^^^ variable.graphql 330 | ## ^ punctuation.colon.graphql 331 | ## ^ support.type.graphql 332 | ## ^ punctuation.assignment.graphql 333 | ## ^ meta.objectvalues.graphql 334 | ## ^ meta.brace.curly.graphql 335 | lon: 12.43, lat: -53.211 336 | ## ^^^^ ^^^^^^ ^^^^ ^^^^^^^ meta.variables.graphql 337 | ## ^^^^ ^^^^^^ ^^^^ ^^^^^^^ meta.objectvalues.graphql 338 | ## ^^^ ^^^ constant.object.key.graphql 339 | ## ^^^ ^^^ string.unquoted.graphql 340 | ## ^ ^ punctuation.graphql 341 | ## ^^^^^ ^^^^^^^ constant.float.graphql 342 | } 343 | ## ^ meta.variables.graphql 344 | ## ^ meta.objectvalues.graphql 345 | ## ^ meta.brace.curly.graphql 346 | ) 347 | ## ^ meta.brace.round.graphql 348 | @directives ( 349 | ## ^^^^^^^^^^^ entity.name.function.directive.graphql 350 | ## ^ meta.arguments.graphql 351 | ## ^ meta.brace.round.directive.graphql 352 | blockString: """ 353 | ## ^^^^^^^^^^^ variable.arguments.graphql 354 | ## ^ punctuation.colon.graphql 355 | ## ^^^ string.quoted.block.graphql 356 | ## ^^^ punctuation.definition.string.begin.graphql 357 | String stuff goes here 358 | ## ^^^^^^ ^^^^^ ^^^^ ^^^^ string.quoted.block.graphql 359 | """ 360 | ## ^^^ string.quoted.block.graphql 361 | ## ^^^ punctuation.definition.string.end.graphql 362 | 363 | number: 1 364 | ## ^^^^^^^ ^ meta.arguments.graphql 365 | ## ^^^^^^ variable.arguments.graphql 366 | ## ^ punctuation.colon.graphql 367 | ## ^ constant.float.graphql 368 | float: 123.011e-1, float:123.00, float: 123e+20 369 | ## ^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^ ^^^^^^^ meta.arguments.graphql 370 | ## ^^^^^ ^^^^^ ^^^^^ variable.arguments.graphql 371 | ## ^ ^ ^ punctuation.colon.graphql 372 | ## ^^^^^^^^^^ ^^^^^^ ^^^^^^^ constant.float.graphql 373 | ## ^ ^ punctuation.comma.graphql 374 | boolean: true, boolean: false 375 | ## ^^^^^^^^ ^^^^^ ^^^^^^^^ ^^^^^ meta.arguments.graphql 376 | ## ^^^^^^^ ^^^^^^^ variable.arguments.graphql 377 | ## ^ ^ punctuation.colon.graphql 378 | ## ^^^^ ^^^^^ constant.boolean.graphql 379 | ## ^ punctuation.comma.graphql 380 | String: "Some string \" \\ \/ \b \f \r \r and the rest", 381 | ## ^^^^^^^ ^^^^^ ^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^^^^^ meta.arguments.graphql 382 | ## ^^^^^^ variable.arguments.graphql 383 | ## ^ punctuation.colon.graphql 384 | ## ^^^^^ ^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^^^^ string.quoted.double.graphql 385 | ## ^ punctuation.definition.string.begin.graphql 386 | ## ^^ ^^ ^^ ^^ ^^ ^^ ^^ constant.character.escape.graphql 387 | ## ^ punctuation.definition.string.end.graphql 388 | ## ^ punctuation.comma.graphql 389 | enum: aaaa, enum: AAAA_AA, 390 | ## ^^^^^ ^^^^^ ^^^^^ ^^^^^^^^ meta.arguments.graphql 391 | ## ^^^^ ^^^^ variable.arguments.graphql 392 | ## ^ ^ punctuation.colon.graphql 393 | ## ^^^^ ^^^^^^^ constant.character.enum.graphql 394 | ## ^ ^ punctuation.comma.graphql 395 | list : ["aaa", 1 , aFlag], 396 | ## ^^^^ ^ ^^^^^^^ ^ ^ ^^^^^^^ meta.arguments.graphql 397 | ## ^^^^ variable.arguments.graphql 398 | ## ^ punctuation.colon.graphql 399 | ## ^^^^^^^ ^ ^ ^^^^^^ meta.listvalues.graphql 400 | ## ^ ^ meta.brace.square.graphql 401 | ## ^^^^^ string.quoted.double.graphql 402 | ## ^ punctuation.definition.string.begin.graphql 403 | ## ^ punctuation.definition.string.end.graphql 404 | ## ^ constant.float.graphql 405 | ## ^^^^^ constant.character.enum.graphql 406 | ## ^ punctuation.comma.graphql 407 | object: { 408 | ## ^^^^^^^ ^ meta.arguments.graphql 409 | ## ^^^^^^ variable.arguments.graphql 410 | ## ^ punctuation.colon.graphql 411 | ## ^ meta.objectvalues.graphql 412 | ## ^ meta.brace.curly.graphql 413 | lon: 12.43, lat: -53.211 414 | ## ^^^^ ^^^^^^ ^^^^ ^^^^^^^ meta.arguments.graphql 415 | ## ^^^^ ^^^^^^ ^^^^ ^^^^^^^ meta.objectvalues.graphql 416 | ## ^^^ ^^^ constant.object.key.graphql 417 | ## ^^^ ^^^ string.unquoted.graphql 418 | ## ^ ^ punctuation.graphql 419 | ## ^^^^^ ^^^^^^^ constant.float.graphql 420 | } 421 | ## ^ meta.arguments.graphql 422 | ## ^ meta.objectvalues.graphql 423 | ## ^ meta.brace.curly.graphql 424 | ) 425 | ## ^ meta.arguments.graphql 426 | ## ^ meta.brace.round.directive.graphql 427 | { 428 | ##^ meta.selectionset.graphql 429 | ##^ punctuation.operation.graphql 430 | # Selection Set 431 | ## ^ ^^^^^^^^^ ^^^ meta.selectionset.graphql 432 | ## ^ ^^^^^^^^^ ^^^ comment.line.graphql.js 433 | me { 434 | ## ^^ ^ meta.selectionset.graphql 435 | ## ^^ variable.graphql 436 | ## ^ punctuation.operation.graphql 437 | # nested Selection Set 438 | ## ^ ^^^^^^ ^^^^^^^^^ ^^^ meta.selectionset.graphql 439 | ## ^ ^^^^^^ ^^^^^^^^^ ^^^ comment.line.graphql.js 440 | idAlias: id(id: 1) @directive() # fields 441 | ## ^^^^^^^^ ^^^^^^ ^^ ^^^^^^^^^^^^ ^ ^^^^^^ meta.selectionset.graphql 442 | ## ^^^^^^^ string.unquoted.alias.graphql 443 | ## ^ ^ punctuation.colon.graphql 444 | ## ^^ variable.graphql 445 | ## ^^^^ ^^ ^^ meta.arguments.graphql 446 | ## ^ ^ ^^ meta.brace.round.directive.graphql 447 | ## ^^ variable.arguments.graphql 448 | ## ^ constant.float.graphql 449 | ## ^^^^^^^^^^ entity.name.function.directive.graphql 450 | ## ^ ^^^^^^ comment.line.graphql.js 451 | name, 452 | ## ^^^^^ meta.selectionset.graphql 453 | ## ^^^^ variable.graphql 454 | ## ^ punctuation.comma.graphql 455 | small: profilePic( size: $devicePicSize ) # field alias 456 | ## ^^^^^^ ^^^^^^^^^^^ ^^^^^ ^^^^^^^^^^^^^^ ^ ^ ^^^^^ ^^^^^ meta.selectionset.graphql 457 | ## ^^^^^ string.unquoted.alias.graphql 458 | ## ^ ^ punctuation.colon.graphql 459 | ## ^^^^^^^^^^ ^^^^^^^^^^^^^^ variable.graphql 460 | ## ^ ^^^^^ ^^^^^^^^^^^^^^ ^ meta.arguments.graphql 461 | ## ^ ^ meta.brace.round.directive.graphql 462 | ## ^^^^ variable.arguments.graphql 463 | ## ^ ^^^^^ ^^^^^ comment.line.graphql.js 464 | ...Ignored 465 | ## ^^^^^^^^^^ meta.selectionset.graphql 466 | ## ^^^ keyword.operator.spread.graphql 467 | ## ^^^^^^^ variable.fragment.graphql 468 | ...A @directives(if: true), # fragment spread 469 | ## ^^^^ ^^^^^^^^^^^^^^^ ^^^^^^ ^ ^^^^^^^^ ^^^^^^ meta.selectionset.graphql 470 | ## ^^^ keyword.operator.spread.graphql 471 | ## ^ variable.fragment.graphql 472 | ## ^^^^^^^^^^^ entity.name.function.directive.graphql 473 | ## ^^^^ ^^^^^ meta.arguments.graphql 474 | ## ^ ^ meta.brace.round.directive.graphql 475 | ## ^^ variable.arguments.graphql 476 | ## ^ punctuation.colon.graphql 477 | ## ^^^^ constant.boolean.graphql 478 | ## ^ punctuation.comma.graphql 479 | ## ^ ^^^^^^^^ ^^^^^^ comment.line.graphql.js 480 | ... on Type @directives() { # inline fragment 481 | ## ^^^ ^^ ^^^^ ^^^^^^^^^^^^^ ^ ^ ^^^^^^ ^^^^^^^^ meta.selectionset.graphql 482 | ## ^^^ keyword.operator.spread.graphql 483 | ## ^^ keyword.on.graphql 484 | ## ^^^^ support.type.graphql 485 | ## ^^^^^^^^^^^ entity.name.function.directive.graphql 486 | ## ^^ meta.arguments.graphql 487 | ## ^^ meta.brace.round.directive.graphql 488 | ## ^ punctuation.operation.graphql 489 | ## ^ ^^^^^^ ^^^^^^^^ comment.line.graphql.js 490 | ...{ # inline fragment 491 | ## ^^^^ ^ ^^^^^^ ^^^^^^^^ meta.selectionset.graphql 492 | ## ^^^ keyword.operator.spread.graphql 493 | ## ^ punctuation.operation.graphql 494 | ## ^ ^^^^^^ ^^^^^^^^ comment.line.graphql.js 495 | } 496 | ## ^ meta.selectionset.graphql 497 | ## ^ punctuation.operation.graphql 498 | } 499 | ## ^ meta.selectionset.graphql 500 | ## ^ punctuation.operation.graphql 501 | } 502 | ## ^ meta.selectionset.graphql 503 | ## ^ punctuation.operation.graphql 504 | } 505 | ##^ meta.selectionset.graphql 506 | ##^ punctuation.operation.graphql 507 | -------------------------------------------------------------------------------- /spec/grammars/graphql-spec.coffee: -------------------------------------------------------------------------------- 1 | path = require 'path' 2 | grammarTest = require 'atom-grammar-test' 3 | 4 | describe 'Grammar', -> 5 | beforeEach -> 6 | waitsForPromise -> 7 | atom.packages.activatePackage('language-graphql') 8 | 9 | grammarTest path.join(__dirname, '../fixtures/example.graphql') 10 | --------------------------------------------------------------------------------