on master help sign in
Add GraphQl syntax test sample
commitf10c8ce25ea6ee40c587a4d0e1527f4846880058 authorZachary J. Rollyson <me@zjr.io> dateSat 10 Oct 2020, 14:41 (6 years ago) parentacc370d
2 files changed+290
tests/syntax-tests/highlighted/GraphQL/test.graphql+145 tests/syntax-tests/source/GraphQL/test.graphql+145
tests/syntax-tests/highlighted/GraphQL/test.graphqlnew file+145
@@ -0,0 +1,145 @@
1+# Token::
2+# Punctuator
3+# Name
4+# IntValue
5+# FloatValue
6+# StringValue
7+
8+# Punctuator:: one of
9+# ! $ ( ) ... : = @ [ ] { | }
10+
11+# Name::
12+# /[_A-Za-z][_0-9A-Za-z]*/
13+
14+# Document :
15+# Definition (list)
16+
17+# Definition :
18+# ExecutableDefinition
19+# TypeSystemDefinition
20+# TypeSystemExtension
21+
22+# ExecutableDefinition :
23+# FragmentDefinition
24+# OperationDefintion
25+
26+# FragmentDefinition
27+
28+type someType {
29+ id: ID
30+}
31+
32+fragment subsriberFields on someType {
33+ id
34+ name
35+ fooInt(int: 1234, negInt: -56789, zero: 0)
36+ fooFloat(
37+ float: 1.1
38+ floatExp: 1.4e10
39+ floatExpSign1: 1.4e+10
40+ floatExpSign2: 1.5e-40
41+ floatExpBigE: 1.5E10
42+ )
43+ fooBool(x: true, y: false)
44+ fooString(str: "hello", strUni: "\u2116", strEscWs: "\t")
45+ fooLongStr(
46+ lStr: """
47+ Hello Reader,
48+ This is a long string block.
49+ Best,
50+ Writer
51+ """
52+ )
53+ fooNull(nullThing: null)
54+ fooList(numList: [1, 2, 3], strList: ["a", "b", "c"])
55+ fooObj(someObj: { str: "hi", int: 2 })
56+}
57+
58+# OperationDefintion
59+
60+query _A1 {
61+ getThings(strArg: "string") {
62+ id # commas here are ignored but valid
63+ name
64+ }
65+}
66+
67+query _A2($x: String) {
68+ someFn(episode: $x) {
69+ name
70+ }
71+}
72+
73+mutation B1 {
74+ changeThings(intArg: 123) {
75+ parent {
76+ nestedField1
77+ nestedField2
78+ }
79+ }
80+}
81+
82+subscription C1_Hello {
83+ subsribePlease(floatArg: 1.4) {
84+ id
85+ ...subsriberFields
86+ }
87+}
88+
89+# TypeSystemDefinition :
90+# SchemaDefinition
91+# TypeDefinition
92+
93+schema {
94+ query: Query
95+ mutation: Mutation
96+}
97+
98+type Query {
99+ """
100+ Can provide documentation this way.
101+ """
102+ scalars: Scalars
103+ someList: SomeLists
104+ fooBar: FooBar
105+}
106+
107+interface Thing {
108+ id: ID!
109+}
110+
111+type Scalars implements Thing {
112+ id: ID!
113+ int: Int!
114+ float: Float!
115+ str: String! @deprecated(reason: "Need to test a directive")
116+ bool: Boolean
117+ type: StringTypes
118+}
119+
120+type SomeLists {
121+ ints: [Int!]!
122+}
123+
124+type Foo {
125+ fooVal: String
126+}
127+
128+type Bar {
129+ barVal: String
130+}
131+
132+union FooBar = Foo | Bar
133+
134+enum StringTypes {
135+ ONE
136+ TWO
137+}
138+
139+input Xyz {
140+ id: ID!
141+}
142+
143+type Mutation {
144+ createXyz(input: xyz!): Xyz!
145+}
tests/syntax-tests/source/GraphQL/test.graphqlnew file+145
@@ -0,0 +1,145 @@
1+# Token::
2+# Punctuator
3+# Name
4+# IntValue
5+# FloatValue
6+# StringValue
7+
8+# Punctuator:: one of
9+# ! $ ( ) ... : = @ [ ] { | }
10+
11+# Name::
12+# /[_A-Za-z][_0-9A-Za-z]*/
13+
14+# Document :
15+# Definition (list)
16+
17+# Definition :
18+# ExecutableDefinition
19+# TypeSystemDefinition
20+# TypeSystemExtension
21+
22+# ExecutableDefinition :
23+# FragmentDefinition
24+# OperationDefintion
25+
26+# FragmentDefinition
27+
28+type someType {
29+ id: ID
30+}
31+
32+fragment subsriberFields on someType {
33+ id
34+ name
35+ fooInt(int: 1234, negInt: -56789, zero: 0)
36+ fooFloat(
37+ float: 1.1
38+ floatExp: 1.4e10
39+ floatExpSign1: 1.4e+10
40+ floatExpSign2: 1.5e-40
41+ floatExpBigE: 1.5E10
42+ )
43+ fooBool(x: true, y: false)
44+ fooString(str: "hello", strUni: "\u2116", strEscWs: "\t")
45+ fooLongStr(
46+ lStr: """
47+ Hello Reader,
48+ This is a long string block.
49+ Best,
50+ Writer
51+ """
52+ )
53+ fooNull(nullThing: null)
54+ fooList(numList: [1, 2, 3], strList: ["a", "b", "c"])
55+ fooObj(someObj: { str: "hi", int: 2 })
56+}
57+
58+# OperationDefintion
59+
60+query _A1 {
61+ getThings(strArg: "string") {
62+ id # commas here are ignored but valid
63+ name
64+ }
65+}
66+
67+query _A2($x: String) {
68+ someFn(episode: $x) {
69+ name
70+ }
71+}
72+
73+mutation B1 {
74+ changeThings(intArg: 123) {
75+ parent {
76+ nestedField1
77+ nestedField2
78+ }
79+ }
80+}
81+
82+subscription C1_Hello {
83+ subsribePlease(floatArg: 1.4) {
84+ id
85+ ...subsriberFields
86+ }
87+}
88+
89+# TypeSystemDefinition :
90+# SchemaDefinition
91+# TypeDefinition
92+
93+schema {
94+ query: Query
95+ mutation: Mutation
96+}
97+
98+type Query {
99+ """
100+ Can provide documentation this way.
101+ """
102+ scalars: Scalars
103+ someList: SomeLists
104+ fooBar: FooBar
105+}
106+
107+interface Thing {
108+ id: ID!
109+}
110+
111+type Scalars implements Thing {
112+ id: ID!
113+ int: Int!
114+ float: Float!
115+ str: String! @deprecated(reason: "Need to test a directive")
116+ bool: Boolean
117+ type: StringTypes
118+}
119+
120+type SomeLists {
121+ ints: [Int!]!
122+}
123+
124+type Foo {
125+ fooVal: String
126+}
127+
128+type Bar {
129+ barVal: String
130+}
131+
132+union FooBar = Foo | Bar
133+
134+enum StringTypes {
135+ ONE
136+ TWO
137+}
138+
139+input Xyz {
140+ id: ID!
141+}
142+
143+type Mutation {
144+ createXyz(input: xyz!): Xyz!
145+}