FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cppgraphqlgen/test/PegtlSchemaTests.cpp at issues-334 · gitmodimo/cppgraphqlgen · GitHub
gitmodimo
/
cppgraphqlgen
Public
forked from
microsoft/cppgraphqlgen
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cppgraphqlgen
/
test
/
PegtlSchemaTests.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
226 lines (172 loc) · 4.52 KB
Breadcrumbs
cppgraphqlgen
/
test
/
PegtlSchemaTests.cpp
Copy path
File metadata and controls
226 lines (172 loc) · 4.52 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
//
Copyright (c) Microsoft Corporation. All rights reserved.
//
Licensed under the MIT License.
#
include
<
gtest/gtest.h
>
#
include
"
graphqlservice/internal/Grammar.h
"
#
include
<
tao/pegtl/contrib/analyze.hpp
>
#
include
<
cstddef
>
using
namespace
graphql
;
using
namespace
graphql
::peg
;
using
namespace
tao
::graphqlpeg
;
TEST
(PegtlSchemaCase, ParseKitchenSinkSchema)
{
memory_input<>
input
(
R"gql(
# Copyright (c) 2015-present, Facebook, Inc.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
# (this line is padding to maintain test line numbers)
schema {
query: QueryType
mutation: MutationType
}
type Foo implements Bar {
one: Type
two(argument: InputType!): Type
three(argument: InputType, other: String): Int
four(argument: String = "string"): String
five(argument: [String] = ["string", "string"]): String
six(argument: InputType = {key: "value"}): Type
seven(argument: Int = null): Type
}
type AnnotatedObject @onObject(arg: "value") {
annotatedField(arg: Type = "default" @onArg): Type @onField
}
interface Bar {
one: Type
four(argument: String = "string"): String
}
interface AnnotatedInterface @onInterface {
annotatedField(arg: Type @onArg): Type @onField
}
union Feed = Story | Article | Advert
union AnnotatedUnion @onUnion = A | B
scalar CustomScalar
scalar AnnotatedScalar @onScalar
enum Site {
DESKTOP
MOBILE
}
enum AnnotatedEnum @onEnum {
ANNOTATED_VALUE @onEnumValue
OTHER_VALUE
}
input InputType {
key: String!
answer: Int = 42
}
input AnnotatedInput @onInputObjectType {
annotatedField: Type @onField
}
extend type Foo {
seven(argument: [String]): Type
}
# NOTE: out-of-spec test cases commented out until the spec is clarified; see
# https://github.com/graphql/graphql-js/issues/650 .
# extend type Foo @onType {}
#type NoFields {}
directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
directive @include(if: Boolean!)
on FIELD
| FRAGMENT_SPREAD
| INLINE_FRAGMENT
)gql"
,
"
ParseKitchenSinkSchema
"
);
const
bool
result = parse<schema_document>(input);
ASSERT_TRUE
(result) <<
"
we should be able to parse the doc
"
;
}
TEST
(PegtlSchemaCase, ParseTodaySchema)
{
memory_input<>
input
(
R"gql(
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
schema {
query: Query
mutation: Mutation
subscription: Subscription
}
scalar ItemCursor
type Query {
node(id: ID!) : Node
appointments(first: Int, after: ItemCursor, last: Int, before: ItemCursor): AppointmentConnection!
tasks(first: Int, after: ItemCursor, last: Int, before: ItemCursor): TaskConnection!
unreadCounts(first: Int, after: ItemCursor, last: Int, before: ItemCursor): FolderConnection!
appointmentsById(ids: [ID!]!) : [Appointment]!
tasksById(ids: [ID!]!): [Task]!
unreadCountsById(ids: [ID!]!): [Folder]!
}
interface Node {
id: ID!
}
type PageInfo {
hasNextPage: Boolean!
hasPreviousPage: Boolean!
}
type AppointmentEdge {
node: Appointment
cursor: ItemCursor!
}
type AppointmentConnection {
pageInfo: PageInfo!
edges: [AppointmentEdge]
}
type TaskEdge {
node: Task
cursor: ItemCursor!
}
type TaskConnection {
pageInfo: PageInfo!
edges: [TaskEdge]
}
type FolderEdge {
node: Folder
cursor: ItemCursor!
}
type FolderConnection {
pageInfo: PageInfo!
edges: [FolderEdge]
}
input CompleteTaskInput {
id: ID!
isComplete: Boolean = true
clientMutationId: String
}
type CompleteTaskPayload {
task: Task
clientMutationId: String
}
type Mutation {
completeTask(input: CompleteTaskInput!) : CompleteTaskPayload!
}
type Subscription {
nextAppointmentChange : Appointment
}
scalar DateTime
enum TaskState {
New
Started
Complete
}
type Appointment implements Node {
id: ID!
when: DateTime
subject: String
isNow: Boolean!
}
type Task implements Node {
id: ID!
title: String
isComplete: Boolean!
}
type Folder implements Node {
id: ID!
name: String
unreadCount: Int!
}
)gql"
,
"
ParseTodaySchema
"
);
const
bool
result = parse<schema_document>(input);
ASSERT_TRUE
(result) <<
"
we should be able to parse the doc
"
;
}
TEST
(PegtlSchemaCase, AnalyzeSchemaGrammar)
{
ASSERT_EQ
(std::
size_t
{
0
}, analyze<schema_document>(
true
))
<<
"
there shouldn't be any infinite loops in the PEG version of the grammar
"
;
}
Back
|
FazBrowse Home
|
New Git URL