Skip to content

Commit

Permalink
GraphQL: Added missing keywords (#2407)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed Jun 12, 2020
1 parent 7f341fc commit de8ed16
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 26 deletions.
6 changes: 3 additions & 3 deletions components/prism-graphql.js
Expand Up @@ -28,16 +28,16 @@ Prism.languages.graphql = {
greedy: true
},
'class-name': {
pattern: /(\b(?:enum|implements|interface|on|scalar|type|union)\s+)[a-zA-Z_]\w*/,
pattern: /(\b(?:enum|implements|interface|on|scalar|type|union)\s+|&\s*)[a-zA-Z_]\w*/,
lookbehind: true
},
'fragment': {
pattern: /(\bfragment\s+|\.{3}\s*(?!on\b))[a-zA-Z_]\w*/,
lookbehind: true,
alias: 'function'
},
'keyword': /\b(?:enum|fragment|implements|input|interface|mutation|on|query|scalar|schema|type|union)\b/,
'operator': /[!=|]|\.{3}/,
'keyword': /\b(?:directive|enum|extend|fragment|implements|input|interface|mutation|on|query|repeatable|scalar|schema|subscription|type|union)\b/,
'operator': /[!=|&]|\.{3}/,
'punctuation': /[!(){}\[\]:=,]/,
'constant': /\b(?!ID\b)[A-Z][A-Z_\d]*\b/
};
2 changes: 1 addition & 1 deletion components/prism-graphql.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion tests/languages/graphql/class-name_feature.test
@@ -1,6 +1,7 @@
interface Foo {}
type Foo {}
type Foo implements Bar {}
type Business implements NamedEntity & ValuedEntity {}
enum Foo {}
scalar Foo
union Foo
Expand All @@ -26,6 +27,15 @@ on Foo {}
["punctuation", "{"],
["punctuation", "}"],

["keyword", "type"],
["class-name", "Business"],
["keyword", "implements"],
["class-name", "NamedEntity"],
["operator", "&"],
["class-name", "ValuedEntity"],
["punctuation", "{"],
["punctuation", "}"],

["keyword", "enum"],
["class-name", "Foo"],
["punctuation", "{"],
Expand All @@ -45,4 +55,4 @@ on Foo {}

----------------------------------------------------

Checks for class names.
Checks for class names.
62 changes: 43 additions & 19 deletions tests/languages/graphql/keyword_feature.test
@@ -1,33 +1,57 @@
enum
fragment
implements
input
interface
mutation
on
query
scalar
schema
type
union
directive,
enum,
extend,
fragment,
implements,
input,
interface,
mutation,
on,
query,
repeatable,
scalar,
schema,
subscription,
type,
union,

----------------------------------------------------

[
["keyword", "directive"],
["punctuation", ","],
["keyword", "enum"],
["class-name", "fragment"],
["punctuation", ","],
["keyword", "extend"],
["punctuation", ","],
["keyword", "fragment"],
["punctuation", ","],
["keyword", "implements"],
["class-name", "input"],
["punctuation", ","],
["keyword", "input"],
["punctuation", ","],
["keyword", "interface"],
["class-name", "mutation"],
["punctuation", ","],
["keyword", "mutation"],
["punctuation", ","],
["keyword", "on"],
["class-name", "query"],
["punctuation", ","],
["keyword", "query"],
["punctuation", ","],
["keyword", "repeatable"],
["punctuation", ","],
["keyword", "scalar"],
["class-name", "schema"],
["punctuation", ","],
["keyword", "schema"],
["punctuation", ","],
["keyword", "subscription"],
["punctuation", ","],
["keyword", "type"],
["class-name", "union"]
["punctuation", ","],
["keyword", "union"],
["punctuation", ","]
]

----------------------------------------------------

Checks for keywords.
Checks for keywords.
5 changes: 3 additions & 2 deletions tests/languages/graphql/operator_feature.test
@@ -1,4 +1,4 @@
= ! |
= ! | &
...

----------------------------------------------------
Expand All @@ -7,9 +7,10 @@
["operator", "="],
["operator", "!"],
["operator", "|"],
["operator", "&"],
["operator", "..."]
]

----------------------------------------------------

Checks for operators.
Checks for operators.

0 comments on commit de8ed16

Please sign in to comment.