Add support for GraphQL (#2947)

* Add GraphQL to languages.yml

* Add graphql submodule

* Add graphql to grammars.yml

* Add GraphQL samples

* Updating licensed information
This commit is contained in:
Garen Torikian
2016-04-13 21:03:02 -07:00
committed by Arfon Smith
parent 7c9fd59a99
commit bce676e902
7 changed files with 128 additions and 0 deletions

3
.gitmodules vendored
View File

@@ -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

View File

@@ -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:

View File

@@ -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

View File

@@ -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
}

View File

@@ -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

View File

@@ -0,0 +1,7 @@
---
type: grammar
name: language-graphql
license: mit
curated: true
---
MIT