forked from microsoft/cppgraphqlgen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueryClient.h
More file actions
248 lines (208 loc) · 6 KB
/
QueryClient.h
File metadata and controls
248 lines (208 loc) · 6 KB
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// WARNING! Do not edit this file manually, your changes will be overwritten.
#pragma once
#ifndef QUERYCLIENT_H
#define QUERYCLIENT_H
#include "graphqlservice/GraphQLClient.h"
#include "graphqlservice/GraphQLParse.h"
#include "graphqlservice/GraphQLResponse.h"
#include "graphqlservice/internal/Version.h"
#include <optional>
#include <string>
#include <vector>
// Check if the library version is compatible with clientgen 5.0.0
static_assert(graphql::internal::MajorVersion == 5, "regenerate with clientgen: major version mismatch");
static_assert(graphql::internal::MinorVersion == 0, "regenerate with clientgen: minor version mismatch");
namespace graphql::query {
/// # Operation: query (unnamed)
/// ```graphql
/// # Copyright (c) Microsoft Corporation. All rights reserved.
/// # Licensed under the MIT License.
///
/// query {
/// appointments {
/// edges {
/// node {
/// id
/// subject
/// when
/// isNow
/// __typename
/// }
/// }
/// }
/// tasks {
/// edges {
/// node {
/// id
/// title
/// isComplete
/// __typename
/// }
/// }
/// }
/// unreadCounts {
/// edges {
/// node {
/// id
/// name
/// unreadCount
/// __typename
/// }
/// }
/// }
///
/// # Read a field with an enum type
/// testTaskState
///
/// # Try a field with a union type
/// anyType(ids: ["ZmFrZVRhc2tJZA=="]) {
/// __typename
/// ...on Node {
/// id
/// }
/// ...on Task {
/// id
/// title
/// isComplete
/// }
/// ...on Appointment {
/// id
/// subject
/// when
/// isNow
/// array
/// }
/// }
///
/// # Try a field with a C++ keyword
/// default
/// }
/// ```
namespace client {
// Return the original text of the request document.
[[nodiscard("unnecessary call")]] const std::string& GetRequestText() noexcept;
// Return a pre-parsed, pre-validated request object.
[[nodiscard("unnecessary call")]] const peg::ast& GetRequestObject() noexcept;
} // namespace client
enum class [[nodiscard("unnecessary conversion")]] TaskState
{
Unassigned,
New,
Started,
Complete,
};
namespace client {
namespace query::Query {
using graphql::query::client::GetRequestText;
using graphql::query::client::GetRequestObject;
// Return the name of this operation in the shared request document.
[[nodiscard("unnecessary call")]] const std::string& GetOperationName() noexcept;
using graphql::query::TaskState;
struct [[nodiscard("unnecessary construction")]] Response
{
struct [[nodiscard("unnecessary construction")]] appointments_AppointmentConnection
{
struct [[nodiscard("unnecessary construction")]] edges_AppointmentEdge
{
struct [[nodiscard("unnecessary construction")]] node_Appointment
{
response::IdType id {};
std::optional<std::string> subject {};
std::optional<response::Value> when {};
bool isNow {};
std::string _typename {};
};
std::optional<node_Appointment> node {};
};
std::optional<std::vector<std::optional<edges_AppointmentEdge>>> edges {};
};
struct [[nodiscard("unnecessary construction")]] tasks_TaskConnection
{
struct [[nodiscard("unnecessary construction")]] edges_TaskEdge
{
struct [[nodiscard("unnecessary construction")]] node_Task
{
response::IdType id {};
std::optional<std::string> title {};
bool isComplete {};
std::string _typename {};
};
std::optional<node_Task> node {};
};
std::optional<std::vector<std::optional<edges_TaskEdge>>> edges {};
};
struct [[nodiscard("unnecessary construction")]] unreadCounts_FolderConnection
{
struct [[nodiscard("unnecessary construction")]] edges_FolderEdge
{
struct [[nodiscard("unnecessary construction")]] node_Folder
{
response::IdType id {};
std::optional<std::string> name {};
int unreadCount {};
std::string _typename {};
};
std::optional<node_Folder> node {};
};
std::optional<std::vector<std::optional<edges_FolderEdge>>> edges {};
};
struct [[nodiscard("unnecessary construction")]] anyType_UnionType
{
std::string _typename {};
response::IdType id {};
std::optional<std::string> title {};
bool isComplete {};
std::optional<std::string> subject {};
std::optional<response::Value> when {};
bool isNow {};
std::vector<response::IdType> array {};
};
appointments_AppointmentConnection appointments {};
tasks_TaskConnection tasks {};
unreadCounts_FolderConnection unreadCounts {};
TaskState testTaskState {};
std::vector<std::optional<anyType_UnionType>> anyType {};
std::optional<std::string> default_ {};
};
class ResponseVisitor
: public std::enable_shared_from_this<ResponseVisitor>
{
public:
ResponseVisitor() noexcept;
~ResponseVisitor();
void add_value(std::shared_ptr<const response::Value>&&);
void reserve(std::size_t count);
void start_object();
void add_member(std::string&& key);
void end_object();
void start_array();
void end_array();
void add_null();
void add_string(std::string&& value);
void add_enum(std::string&& value);
void add_id(response::IdType&& value);
void add_bool(bool value);
void add_int(int value);
void add_float(double value);
void complete();
Response response();
private:
struct impl;
std::unique_ptr<impl> _pimpl;
};
[[nodiscard("unnecessary conversion")]] Response parseResponse(response::Value&& response);
struct Traits
{
[[nodiscard("unnecessary call")]] static const std::string& GetRequestText() noexcept;
[[nodiscard("unnecessary call")]] static const peg::ast& GetRequestObject() noexcept;
[[nodiscard("unnecessary call")]] static const std::string& GetOperationName() noexcept;
using Response = Query::Response;
using ResponseVisitor = Query::ResponseVisitor;
[[nodiscard("unnecessary conversion")]] static Response parseResponse(response::Value&& response);
};
} // namespace query::Query
} // namespace client
} // namespace graphql::query
#endif // QUERYCLIENT_H