diff --git a/.gitmodules b/.gitmodules index a5c92317..62e464dc 100644 --- a/.gitmodules +++ b/.gitmodules @@ -707,3 +707,6 @@ [submodule "vendor/grammars/language-apl"] path = vendor/grammars/language-apl url = https://github.com/Alhadis/language-apl.git +[submodule "vendor/grammars/language-graphql"] + path = vendor/grammars/language-graphql + url = https://github.com/rmosolgo/language-graphql diff --git a/grammars.yml b/grammars.yml index 7eef7495..dd44bfd4 100755 --- a/grammars.yml +++ b/grammars.yml @@ -340,6 +340,8 @@ vendor/grammars/language-csharp: - source.nant-build vendor/grammars/language-gfm: - source.gfm +vendor/grammars/language-graphql: +- source.graphql vendor/grammars/language-hy: - source.hy vendor/grammars/language-inform7: diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index b5650ede..b7a44b21 100755 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -1262,6 +1262,14 @@ Graph Modeling Language: tm_scope: none ace_mode: text +GraphQL: + type: data + extensions: + - .graphql + color: "#E535AB" + tm_scope: source.graphql + ace_mode: text + Graphviz (DOT): type: data tm_scope: source.dot diff --git a/samples/GraphQL/kitchen-sink.graphql b/samples/GraphQL/kitchen-sink.graphql new file mode 100644 index 00000000..0e04e2e4 --- /dev/null +++ b/samples/GraphQL/kitchen-sink.graphql @@ -0,0 +1,57 @@ +# Copyright (c) 2015, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. An additional grant +# of patent rights can be found in the PATENTS file in the same directory. + +query queryName($foo: ComplexType, $site: Site = MOBILE) { + whoever123is: node(id: [123, 456]) { + id , + ... on User @defer { + field2 { + id , + alias: field1(first:10, after:$foo,) @include(if: $foo) { + id, + ...frag + } + } + } + ... @skip(unless: $foo) { + id + } + ... { + id + } + } +} + +mutation likeStory { + like(story: 123) @defer { + story { + id + } + } +} + +subscription StoryLikeSubscription($input: StoryLikeSubscribeInput) { + storyLikeSubscribe(input: $input) { + story { + likers { + count + } + likeSentence { + text + } + } + } +} + +fragment frag on Friend { + foo(size: $size, bar: $b, obj: {key: "value"}) +} + +{ + unnamed(truthy: true, falsey: false), + query +} diff --git a/samples/GraphQL/schema-kitchen-sink.graphql b/samples/GraphQL/schema-kitchen-sink.graphql new file mode 100644 index 00000000..e623ec40 --- /dev/null +++ b/samples/GraphQL/schema-kitchen-sink.graphql @@ -0,0 +1,50 @@ +# Copyright (c) 2015, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. An additional grant +# of patent rights can be found in the PATENTS file in the same directory. + +schema { + query: QueryType + mutation: MutationType +} + +type Foo implements Bar { + one: Type + two(argument: InputType!): Type + three(argument: InputType, other: String): Int + four(argument: String = "string"): String + five(argument: [String] = ["string", "string"]): String + six(argument: InputType = {key: "value"}): Type +} + +interface Bar { + one: Type + four(argument: String = "string"): String +} + +union Feed = Story | Article | Advert + +scalar CustomScalar + +enum Site { + DESKTOP + MOBILE +} + +input InputType { + key: String! + answer: Int = 42 +} + +extend type Foo { + seven(argument: [String]): Type +} + +directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT + +directive @include(if: Boolean!) + on FIELD + | FRAGMENT_SPREAD + | INLINE_FRAGMENT diff --git a/vendor/grammars/language-graphql b/vendor/grammars/language-graphql new file mode 160000 index 00000000..037e5d46 --- /dev/null +++ b/vendor/grammars/language-graphql @@ -0,0 +1 @@ +Subproject commit 037e5d46ea7c5eeeac412192ab8a3cf72157be2d diff --git a/vendor/licenses/grammar/language-graphql.txt b/vendor/licenses/grammar/language-graphql.txt new file mode 100644 index 00000000..a9da1431 --- /dev/null +++ b/vendor/licenses/grammar/language-graphql.txt @@ -0,0 +1,7 @@ +--- +type: grammar +name: language-graphql +license: mit +curated: true +--- +MIT