forked from highlightjs/highlight.js
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for GraphQL (resolves highlightjs#1471)
- Loading branch information
Showing
5 changed files
with
112 additions
and
0 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
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,41 @@ | ||
/* | ||
Language: GraphQL | ||
Author: David Peek <mail@dpeek.com> | ||
Description: GraphQL schema, query, mutation and subscription | ||
*/ | ||
|
||
function(hljs) { | ||
return { | ||
aliases: ['gql'], | ||
keywords: { | ||
keyword: 'query mutation subscription type interface union scalar fragment enum on ...', | ||
literal: 'true false null' | ||
}, | ||
contains: [ | ||
hljs.HASH_COMMENT_MODE, | ||
hljs.QUOTE_STRING_MODE, | ||
hljs.NUMBER_MODE, | ||
{ className: 'type', | ||
begin: '[^\\w][A-Z][a-z]', end: '\\W', | ||
excludeEnd: true | ||
}, | ||
{ className: 'literal', | ||
begin: '[^\\w][A-Z][A-Z]', end: '\\W', | ||
excludeEnd: true | ||
}, | ||
{ className: 'variable', | ||
begin: '\\$', end: '\\W', | ||
excludeEnd: true | ||
}, | ||
{ | ||
className: 'keyword', | ||
begin: '[.]{2}', end: '\\.', | ||
}, | ||
{ | ||
className: 'meta', | ||
begin: '@', end: '\\W', | ||
excludeEnd: true | ||
} | ||
] | ||
} | ||
} |
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,63 @@ | ||
# Comment | ||
|
||
type ComplexType { | ||
name: String! | ||
} | ||
|
||
enum EnumType { | ||
MOBILE | ||
DESKTOP | ||
} | ||
|
||
union UnionType = ComplexType | EnumType | ||
|
||
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, nullish: null), | ||
query | ||
} |