Skip to content

Commit

Permalink
Add support for GraphQL (github-linguist#2947)
Browse files Browse the repository at this point in the history
* Add GraphQL to languages.yml

* Add graphql submodule

* Add graphql to grammars.yml

* Add GraphQL samples

* Updating licensed information
  • Loading branch information
gjtorikian authored and arfon committed Apr 14, 2016
1 parent 7c9fd59 commit bce676e
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions grammars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
57 changes: 57 additions & 0 deletions samples/GraphQL/kitchen-sink.graphql
Original file line number Diff line number Diff line change
@@ -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
}
50 changes: 50 additions & 0 deletions samples/GraphQL/schema-kitchen-sink.graphql
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions vendor/grammars/language-graphql
Submodule language-graphql added at 037e5d
7 changes: 7 additions & 0 deletions vendor/licenses/grammar/language-graphql.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: grammar
name: language-graphql
license: mit
curated: true
---
MIT

0 comments on commit bce676e

Please sign in to comment.