Add GraphQL support (#306)

* Add GraphQL support

* Fix line count on Graphql test file

* Add extra final new line to GraphQL test file

* Fix line counts on graphql test file

* Fix typo on graphql test file
This commit is contained in:
Stefan Maric 2019-03-04 09:08:15 +01:00 committed by Aaron Power
parent 41b120ad2d
commit d46d511cd8
2 changed files with 103 additions and 0 deletions

View File

@ -636,6 +636,20 @@
"go"
]
},
"Graphql":{
"name":"GraphQL",
"quotes":[
["\\\"", "\\\""],
["\\\"\\\"\\\"", "\\\"\\\"\\\""]
],
"line_comment":[
"#"
],
"extensions":[
"gql",
"graphql"
]
},
"Groovy":{
"base":"c",
"extensions":[

89
tests/data/graphql.gql Normal file
View File

@ -0,0 +1,89 @@
# 89 lines 71 code 3 comments 15 blanks
"""
A simple GraphQL schema which is well described. This is not a comment.
See: https://facebook.github.io/graphql/June2018/#sec-Descriptions
"""
type Query {
"""
Translates a string from a given language into a different language.
"""
translate(
"The original language that `text` is provided in."
fromLanguage: Language
"The translated language to be returned."
toLanguage: Language
"The text to be translated."
text: String
): String
}
"""
The set of languages supported by `translate`.
"""
enum Language {
"English"
EN
"French"
FR
"Chinese"
CH
}
# Comment the query and use "quotes" inside the comment
query withFragments($expandedInfo: Boolean) {
user(id: "3bd5a1cbed10e") {
id # Insignificant comment
... @include(if: $expandedInfo) {
firstName
lastName
birthday
}
friends(first: 10) {
...friendFields
}
profiles(
handles: [
"zuck",
"cocacola",
"#hashed#hash#inside"
]
) {
handle
... on User {
friends {
count
}
}
... on Page {
likers {
count
}
}
}
}
}
fragment friendFields on User {
id
firstName
profilePic(size: 50)
}
# A simple GraphQL type definition
type User {
id: ID
firstName: String
lastName: String
birthday: Date
}