-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathsyntax.vader
167 lines (142 loc) · 4.94 KB
/
syntax.vader
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# https://graphql.github.io/graphql-spec/June2018/#sec-Int
Given graphql (Integers):
0
-1
Execute (Integer assertions):
AssertEqual 'graphqlNumber', SyntaxOf('0')
AssertEqual 'graphqlNumber', SyntaxOf('-1')
# https://graphql.github.io/graphql-spec/June2018/#sec-Float
Given graphql (Floats):
1.0
-1.0
1e10
1E10
1e-10
1e+10
1.0e10
Execute (Float assertions):
AssertEqual 'graphqlNumber', SyntaxOf('1.0')
AssertEqual 'graphqlNumber', SyntaxOf('-1.0')
AssertEqual 'graphqlNumber', SyntaxOf('1e10')
AssertEqual 'graphqlNumber', SyntaxOf('1E10')
AssertEqual 'graphqlNumber', SyntaxOf('1e-10')
AssertEqual 'graphqlNumber', SyntaxOf('1e+10')
AssertEqual 'graphqlNumber', SyntaxOf('1.0e10')
# https://graphql.github.io/graphql-spec/June2018/#sec-Boolean
Given graphql (Booleans):
true
false
Execute (Boolean assertions):
AssertEqual 'graphqlBoolean', SyntaxOf('true')
AssertEqual 'graphqlBoolean', SyntaxOf('false')
# https://graphql.github.io/graphql-spec/June2018/#sec-String
Given graphql (Strings):
""
"Hello World"
"""Block
string"""
"""Block
\"""
string"""
Execute (String assertions):
AssertEqual 'graphqlString', SyntaxOf('""')
AssertEqual 'graphqlString', SyntaxOf('"Hello World"')
AssertEqual 'graphqlString', SyntaxOf('"""Block\nstring"""')
AssertEqual 'graphqlString', SyntaxOf('"""Block\n\\"""\nstring"""')
# https://graphql.github.io/graphql-spec/June2018/#sec-Field-Arguments
Given graphql (Arguments):
query queryName($site: Site = MOBILE) {
user(id: 4) {
profilePic(size: 100)
}
}
Execute (Argument assertions):
AssertEqual 'graphqlName', SyntaxOf('queryName')
AssertEqual 'graphqlVariable', SyntaxOf('$site')
AssertEqual 'graphqlType', SyntaxOf('Site')
AssertEqual 'graphqlType', SyntaxOf('MOBILE')
AssertEqual 'graphqlName', SyntaxOf('id')
AssertEqual 'graphqlNumber', SyntaxOf('4')
AssertEqual 'graphqlName', SyntaxOf('size')
AssertEqual 'graphqlNumber', SyntaxOf('100')
# https://graphql.github.io/graphql-spec/June2018/#sec-Type-Conditions
Given graphql (Type Conditions):
query FragmentTyping {
profiles(handles: ["zuck", "cocacola"]) {
id
...userFragment
}
}
fragment userFragment on User {
friends {
count
}
}
Execute (Type Condition assertions):
AssertEqual 'graphqlOperator', SyntaxOf('\M...')
AssertEqual 'graphqlName', SyntaxOf('userFragment')
AssertEqual 'graphqlStructure', SyntaxOf('fragment')
AssertEqual 'graphqlKeyword', SyntaxOf('on')
AssertEqual 'graphqlType', SyntaxOf('User')
# https://graphql.github.io/graphql-spec/June2018/#sec-Inline-Fragments
Given graphql (Inline Framents):
query inlineFragmentTyping {
profiles(handles: ["zuck", "cocacola"]) {
id
... on User {
name
}
}
}
Execute (Inline Fragment assertions):
AssertEqual 'graphqlOperator', SyntaxOf('\M...')
AssertEqual 'graphqlKeyword', SyntaxOf('on')
AssertEqual 'graphqlType', SyntaxOf('User')
Given graphql (Schema):
schema {
query: QueryType
mutation: MutationType
}
Execute (Schema assertions):
AssertEqual 'graphql', b:current_syntax
AssertEqual 'graphqlStructure', SyntaxOf('schema')
AssertEqual 'graphqlName', SyntaxOf('query')
AssertEqual 'graphqlType', SyntaxOf('QueryType')
# https://spec.graphql.org/October2021/#sec-Type-System.Directives
Given graphql (Directives):
directive @include(if: Boolean!)
on FIELD
| FRAGMENT_SPREAD
| INLINE_FRAGMENT
directive @delegateField(name: String!) repeatable on OBJECT | INTERFACE
Execute (Directive assertions):
AssertEqual 'graphqlStructure', SyntaxOf('directive')
AssertEqual 'graphqlDirective', SyntaxOf('@include')
AssertEqual 'graphqlKeyword', SyntaxOf('on')
AssertEqual 'graphqlKeyword', SyntaxOf('repeatable')
AssertEqual 'graphqlDirectiveLocation', SyntaxOf('FIELD')
AssertEqual 'graphqlDirectiveLocation', SyntaxOf('FRAGMENT_SPREAD')
AssertEqual 'graphqlDirectiveLocation', SyntaxOf('INLINE_FRAGMENT')
AssertEqual 'graphqlOperator', SyntaxOf('|')
# https://spec.graphql.org/October2021/#sec-Objects
Given graphql (Objects):
type Type implements Interface1 & Interface2 {
name: Thing
}
Execute (Object assertions):
AssertEqual 'graphqlStructure', SyntaxOf('type')
AssertEqual 'graphqlType', SyntaxOf('Type')
AssertEqual 'graphqlStructure', SyntaxOf('implements')
AssertEqual 'graphqlType', SyntaxOf('Interface1')
AssertEqual 'graphqlOperator', SyntaxOf('&')
AssertEqual 'graphqlType', SyntaxOf('Interface2')
AssertEqual 'graphqlName', SyntaxOf('name')
AssertEqual 'graphqlType', SyntaxOf('Thing')
Given graphql (Custom Scalars):
scalar UUID @specifiedBy(url: "https://tools.ietf.org/html/rfc4122")
Execute (Custom Scalar assertions):
AssertEqual 'graphqlStructure', SyntaxOf('scalar')
AssertEqual 'graphqlType', SyntaxOf('UUID')
AssertEqual 'graphqlDirective', SyntaxOf('@specifiedBy')
AssertEqual 'graphqlName', SyntaxOf('url')
AssertEqual 'graphqlString', SyntaxOf('https://tools.ietf.org')