-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #971 from Golmote/prism-graphql
Add support for GraphQL
- Loading branch information
Showing
14 changed files
with
206 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Prism.languages.graphql = { | ||
'comment': /#.*/, | ||
'string': { | ||
pattern: /"(?:\\.|[^\\"])*"/, | ||
greedy: true | ||
}, | ||
'number': /(?:\B-|\b)\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b/, | ||
'boolean': /\b(?:true|false)\b/, | ||
'variable': /\$[a-z_]\w*/i, | ||
'directive': { | ||
pattern: /@[a-z_]\w*/i, | ||
alias: 'function' | ||
}, | ||
'attr-name': /[a-z_]\w*(?=\s*:)/i, | ||
'keyword': [ | ||
{ | ||
pattern: /(fragment\s+(?!on)[a-z_]\w*\s+|\.\.\.\s*)on\b/, | ||
lookbehind: true | ||
}, | ||
/\b(?:query|fragment|mutation)\b/ | ||
], | ||
'operator': /!|=|\.{3}/, | ||
'punctuation': /[!(){}\[\]:=,]/ | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<h1>GraphQL</h1> | ||
<p>To use this language, use the class "language-graphql".</p> | ||
|
||
<h2>Comments</h2> | ||
<pre><code># This is a comment</code></pre> | ||
|
||
<h2>Strings</h2> | ||
<pre><code>"" | ||
"foo \"bar\" baz"</code></pre> | ||
|
||
<h2>Numbers</h2> | ||
<pre><code>0 | ||
42 | ||
3.14159 | ||
-9e-5 | ||
0.9E+7</code></pre> | ||
|
||
<h2>Keywords</h2> | ||
<pre><code>query withFragments { | ||
user(id: 4) { | ||
friends(first: 10) { | ||
...friendFields | ||
} | ||
mutualFriends(first: 10) { | ||
...friendFields | ||
} | ||
} | ||
} | ||
|
||
fragment friendFields on User { | ||
id | ||
name | ||
profilePic(size: 50) | ||
}</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
zuck: user(id: 4) { | ||
name | ||
} | ||
} | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["punctuation", "{"], | ||
["attr-name", "zuck"], | ||
["punctuation", ":"], | ||
" user", | ||
["punctuation", "("], | ||
["attr-name", "id"], | ||
["punctuation", ":"], | ||
["number", "4"], | ||
["punctuation", ")"], | ||
["punctuation", "{"], | ||
"\r\n\t\tname\r\n\t", | ||
["punctuation", "}"], | ||
["punctuation", "}"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for aliases, parameter names, etc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
true | ||
false | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["boolean", "true"], | ||
["boolean", "false"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for booleans. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# | ||
# foobar | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["comment", "#"], | ||
["comment", "# foobar"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for comments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
@skip | ||
@include | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["directive", "@skip"], | ||
["directive", "@include"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for directives |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
query | ||
fragment | ||
mutation | ||
fragment foo on Bar | ||
... on Foo | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["keyword", "query"], | ||
["keyword", "fragment"], | ||
["keyword", "mutation"], | ||
["keyword", "fragment"], | ||
" foo ", | ||
["keyword", "on"], | ||
" Bar\r\n", | ||
["operator", "..."], | ||
["keyword", "on"], | ||
" Foo" | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for keywords. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
0 | ||
42 | ||
-5 | ||
3.14159 | ||
5e4 | ||
6E-78 | ||
0.3e+1 | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["number", "0"], | ||
["number", "42"], | ||
["number", "-5"], | ||
["number", "3.14159"], | ||
["number", "5e4"], | ||
["number", "6E-78"], | ||
["number", "0.3e+1"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for numbers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"" | ||
"foo bar" | ||
"foo\"bar\\baz" | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["string", "\"\""], | ||
["string", "\"foo bar\""], | ||
["string", "\"foo\\\"bar\\\\baz\""] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for strings. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
$foo | ||
$Foo_bar42 | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["variable", "$foo"], | ||
["variable", "$Foo_bar42"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for variables. |