Generated-output differences

quicktype output changed between the PR base and tested PR merge revisions.
← Back to the pull request
3test cases
111files differ
43modified
62new
6deleted
8,423changed lines
+7,830 −593insertions / deletions
Base a49b94e8f6f1b319a4da9fb15d57ef13ba316ddc · PR merge 1c1fddbe695e9457466be20dd36e2c7364b6b5a1 · Head 96abf331b6ecc162cbb8ba4daafe3d9f1e5f9f45 · raw patch
Test case

test/inputs/graphql/github7.graphql

47 generated files · +2,326 −550
Mgraphql-cjsondefault / TopLevel.c+252 −40
@@ -5,23 +5,23 @@
55
66 #include "TopLevel.h"
77
8-struct Connection * cJSON_ParseConnection(const char * s) {
9- struct Connection * x = NULL;
8+struct RepositoryRepositoryConnection * cJSON_ParseRepositoryRepositoryConnection(const char * s) {
9+ struct RepositoryRepositoryConnection * x = NULL;
1010 if (NULL != s) {
1111 cJSON * j = cJSON_Parse(s);
1212 if (NULL != j) {
13- x = cJSON_GetConnectionValue(j);
13+ x = cJSON_GetRepositoryRepositoryConnectionValue(j);
1414 cJSON_Delete(j);
1515 }
1616 }
1717 return x;
1818 }
1919
20-struct Connection * cJSON_GetConnectionValue(const cJSON * j) {
21- struct Connection * x = NULL;
20+struct RepositoryRepositoryConnection * cJSON_GetRepositoryRepositoryConnectionValue(const cJSON * j) {
21+ struct RepositoryRepositoryConnection * x = NULL;
2222 if (NULL != j) {
23- if (NULL != (x = cJSON_malloc(sizeof(struct Connection)))) {
24- memset(x, 0, sizeof(struct Connection));
23+ if (NULL != (x = cJSON_malloc(sizeof(struct RepositoryRepositoryConnection)))) {
24+ memset(x, 0, sizeof(struct RepositoryRepositoryConnection));
2525 if (cJSON_HasObjectItem(j, "totalCount")) {
2626 x->total_count = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "totalCount"));
2727 }
@@ -30,7 +30,7 @@ struct Connection * cJSON_GetConnectionValue(const cJSON * j) {
3030 return x;
3131 }
3232
33-cJSON * cJSON_CreateConnection(const struct Connection * x) {
33+cJSON * cJSON_CreateRepositoryRepositoryConnection(const struct RepositoryRepositoryConnection * x) {
3434 cJSON * j = NULL;
3535 if (NULL != x) {
3636 if (NULL != (j = cJSON_CreateObject())) {
@@ -40,10 +40,10 @@ cJSON * cJSON_CreateConnection(const struct Connection * x) {
4040 return j;
4141 }
4242
43-char * cJSON_PrintConnection(const struct Connection * x) {
43+char * cJSON_PrintRepositoryRepositoryConnection(const struct RepositoryRepositoryConnection * x) {
4444 char * s = NULL;
4545 if (NULL != x) {
46- cJSON * j = cJSON_CreateConnection(x);
46+ cJSON * j = cJSON_CreateRepositoryRepositoryConnection(x);
4747 if (NULL != j) {
4848 s = cJSON_Print(j);
4949 cJSON_Delete(j);
@@ -52,7 +52,166 @@ char * cJSON_PrintConnection(const struct Connection * x) {
5252 return s;
5353 }
5454
55-void cJSON_DeleteConnection(struct Connection * x) {
55+void cJSON_DeleteRepositoryRepositoryConnection(struct RepositoryRepositoryConnection * x) {
56+ if (NULL != x) {
57+ cJSON_free(x);
58+ }
59+}
60+
61+struct IssueConnection * cJSON_ParseIssueConnection(const char * s) {
62+ struct IssueConnection * x = NULL;
63+ if (NULL != s) {
64+ cJSON * j = cJSON_Parse(s);
65+ if (NULL != j) {
66+ x = cJSON_GetIssueConnectionValue(j);
67+ cJSON_Delete(j);
68+ }
69+ }
70+ return x;
71+}
72+
73+struct IssueConnection * cJSON_GetIssueConnectionValue(const cJSON * j) {
74+ struct IssueConnection * x = NULL;
75+ if (NULL != j) {
76+ if (NULL != (x = cJSON_malloc(sizeof(struct IssueConnection)))) {
77+ memset(x, 0, sizeof(struct IssueConnection));
78+ if (cJSON_HasObjectItem(j, "totalCount")) {
79+ x->total_count = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "totalCount"));
80+ }
81+ }
82+ }
83+ return x;
84+}
85+
86+cJSON * cJSON_CreateIssueConnection(const struct IssueConnection * x) {
87+ cJSON * j = NULL;
88+ if (NULL != x) {
89+ if (NULL != (j = cJSON_CreateObject())) {
90+ cJSON_AddNumberToObject(j, "totalCount", x->total_count);
91+ }
92+ }
93+ return j;
94+}
95+
96+char * cJSON_PrintIssueConnection(const struct IssueConnection * x) {
97+ char * s = NULL;
98+ if (NULL != x) {
99+ cJSON * j = cJSON_CreateIssueConnection(x);
100+ if (NULL != j) {
101+ s = cJSON_Print(j);
102+ cJSON_Delete(j);
103+ }
104+ }
105+ return s;
106+}
107+
108+void cJSON_DeleteIssueConnection(struct IssueConnection * x) {
109+ if (NULL != x) {
110+ cJSON_free(x);
111+ }
112+}
113+
114+struct StargazerConnection * cJSON_ParseStargazerConnection(const char * s) {
115+ struct StargazerConnection * x = NULL;
116+ if (NULL != s) {
117+ cJSON * j = cJSON_Parse(s);
118+ if (NULL != j) {
119+ x = cJSON_GetStargazerConnectionValue(j);
120+ cJSON_Delete(j);
121+ }
122+ }
123+ return x;
124+}
125+
126+struct StargazerConnection * cJSON_GetStargazerConnectionValue(const cJSON * j) {
127+ struct StargazerConnection * x = NULL;
128+ if (NULL != j) {
129+ if (NULL != (x = cJSON_malloc(sizeof(struct StargazerConnection)))) {
130+ memset(x, 0, sizeof(struct StargazerConnection));
131+ if (cJSON_HasObjectItem(j, "totalCount")) {
132+ x->total_count = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "totalCount"));
133+ }
134+ }
135+ }
136+ return x;
137+}
138+
139+cJSON * cJSON_CreateStargazerConnection(const struct StargazerConnection * x) {
140+ cJSON * j = NULL;
141+ if (NULL != x) {
142+ if (NULL != (j = cJSON_CreateObject())) {
143+ cJSON_AddNumberToObject(j, "totalCount", x->total_count);
144+ }
145+ }
146+ return j;
147+}
148+
149+char * cJSON_PrintStargazerConnection(const struct StargazerConnection * x) {
150+ char * s = NULL;
151+ if (NULL != x) {
152+ cJSON * j = cJSON_CreateStargazerConnection(x);
153+ if (NULL != j) {
154+ s = cJSON_Print(j);
155+ cJSON_Delete(j);
156+ }
157+ }
158+ return s;
159+}
160+
161+void cJSON_DeleteStargazerConnection(struct StargazerConnection * x) {
162+ if (NULL != x) {
163+ cJSON_free(x);
164+ }
165+}
166+
167+struct UserConnection * cJSON_ParseUserConnection(const char * s) {
168+ struct UserConnection * x = NULL;
169+ if (NULL != s) {
170+ cJSON * j = cJSON_Parse(s);
171+ if (NULL != j) {
172+ x = cJSON_GetUserConnectionValue(j);
173+ cJSON_Delete(j);
174+ }
175+ }
176+ return x;
177+}
178+
179+struct UserConnection * cJSON_GetUserConnectionValue(const cJSON * j) {
180+ struct UserConnection * x = NULL;
181+ if (NULL != j) {
182+ if (NULL != (x = cJSON_malloc(sizeof(struct UserConnection)))) {
183+ memset(x, 0, sizeof(struct UserConnection));
184+ if (cJSON_HasObjectItem(j, "totalCount")) {
185+ x->total_count = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "totalCount"));
186+ }
187+ }
188+ }
189+ return x;
190+}
191+
192+cJSON * cJSON_CreateUserConnection(const struct UserConnection * x) {
193+ cJSON * j = NULL;
194+ if (NULL != x) {
195+ if (NULL != (j = cJSON_CreateObject())) {
196+ cJSON_AddNumberToObject(j, "totalCount", x->total_count);
197+ }
198+ }
199+ return j;
200+}
201+
202+char * cJSON_PrintUserConnection(const struct UserConnection * x) {
203+ char * s = NULL;
204+ if (NULL != x) {
205+ cJSON * j = cJSON_CreateUserConnection(x);
206+ if (NULL != j) {
207+ s = cJSON_Print(j);
208+ cJSON_Delete(j);
209+ }
210+ }
211+ return s;
212+}
213+
214+void cJSON_DeleteUserConnection(struct UserConnection * x) {
56215 if (NULL != x) {
57216 cJSON_free(x);
58217 }
@@ -84,16 +243,16 @@ struct Repository * cJSON_GetRepositoryValue(const cJSON * j) {
84243 }
85244 }
86245 if (cJSON_HasObjectItem(j, "stargazers")) {
87- x->stargazers = cJSON_GetConnectionValue(cJSON_GetObjectItemCaseSensitive(j, "stargazers"));
246+ x->stargazers = cJSON_GetStargazerConnectionValue(cJSON_GetObjectItemCaseSensitive(j, "stargazers"));
88247 }
89248 if (cJSON_HasObjectItem(j, "forks")) {
90- x->forks = cJSON_GetConnectionValue(cJSON_GetObjectItemCaseSensitive(j, "forks"));
249+ x->forks = cJSON_GetRepositoryRepositoryConnectionValue(cJSON_GetObjectItemCaseSensitive(j, "forks"));
91250 }
92251 if (cJSON_HasObjectItem(j, "watchers")) {
93- x->watchers = cJSON_GetConnectionValue(cJSON_GetObjectItemCaseSensitive(j, "watchers"));
252+ x->watchers = cJSON_GetUserConnectionValue(cJSON_GetObjectItemCaseSensitive(j, "watchers"));
94253 }
95254 if (cJSON_HasObjectItem(j, "issues")) {
96- x->issues = cJSON_GetConnectionValue(cJSON_GetObjectItemCaseSensitive(j, "issues"));
255+ x->issues = cJSON_GetIssueConnectionValue(cJSON_GetObjectItemCaseSensitive(j, "issues"));
97256 }
98257 }
99258 }
@@ -110,10 +269,10 @@ cJSON * cJSON_CreateRepository(const struct Repository * x) {
110269 else {
111270 cJSON_AddStringToObject(j, "name", "");
112271 }
113- cJSON_AddItemToObject(j, "stargazers", cJSON_CreateConnection(x->stargazers));
114- cJSON_AddItemToObject(j, "forks", cJSON_CreateConnection(x->forks));
115- cJSON_AddItemToObject(j, "watchers", cJSON_CreateConnection(x->watchers));
116- cJSON_AddItemToObject(j, "issues", cJSON_CreateConnection(x->issues));
272+ cJSON_AddItemToObject(j, "stargazers", cJSON_CreateStargazerConnection(x->stargazers));
273+ cJSON_AddItemToObject(j, "forks", cJSON_CreateRepositoryRepositoryConnection(x->forks));
274+ cJSON_AddItemToObject(j, "watchers", cJSON_CreateUserConnection(x->watchers));
275+ cJSON_AddItemToObject(j, "issues", cJSON_CreateIssueConnection(x->issues));
117276 }
118277 }
119278 return j;
@@ -137,16 +296,16 @@ void cJSON_DeleteRepository(struct Repository * x) {
137296 cJSON_free(x->name);
138297 }
139298 if (NULL != x->stargazers) {
140- cJSON_DeleteConnection(x->stargazers);
299+ cJSON_DeleteStargazerConnection(x->stargazers);
141300 }
142301 if (NULL != x->forks) {
143- cJSON_DeleteConnection(x->forks);
302+ cJSON_DeleteRepositoryRepositoryConnection(x->forks);
144303 }
145304 if (NULL != x->watchers) {
146- cJSON_DeleteConnection(x->watchers);
305+ cJSON_DeleteUserConnection(x->watchers);
147306 }
148307 if (NULL != x->issues) {
149- cJSON_DeleteConnection(x->issues);
308+ cJSON_DeleteIssueConnection(x->issues);
150309 }
151310 cJSON_free(x);
152311 }
@@ -213,23 +372,23 @@ void cJSON_DeleteRepositoryEdge(struct RepositoryEdge * x) {
213372 }
214373 }
215374
216-struct RepositoryConnection * cJSON_ParseRepositoryConnection(const char * s) {
217- struct RepositoryConnection * x = NULL;
375+struct UserRepositoryConnection * cJSON_ParseUserRepositoryConnection(const char * s) {
376+ struct UserRepositoryConnection * x = NULL;
218377 if (NULL != s) {
219378 cJSON * j = cJSON_Parse(s);
220379 if (NULL != j) {
221- x = cJSON_GetRepositoryConnectionValue(j);
380+ x = cJSON_GetUserRepositoryConnectionValue(j);
222381 cJSON_Delete(j);
223382 }
224383 }
225384 return x;
226385 }
227386
228-struct RepositoryConnection * cJSON_GetRepositoryConnectionValue(const cJSON * j) {
229- struct RepositoryConnection * x = NULL;
387+struct UserRepositoryConnection * cJSON_GetUserRepositoryConnectionValue(const cJSON * j) {
388+ struct UserRepositoryConnection * x = NULL;
230389 if (NULL != j) {
231- if (NULL != (x = cJSON_malloc(sizeof(struct RepositoryConnection)))) {
232- memset(x, 0, sizeof(struct RepositoryConnection));
390+ if (NULL != (x = cJSON_malloc(sizeof(struct UserRepositoryConnection)))) {
391+ memset(x, 0, sizeof(struct UserRepositoryConnection));
233392 if ((cJSON_HasObjectItem(j, "edges")) && (!cJSON_IsNull(cJSON_GetObjectItemCaseSensitive(j, "edges")))) {
234393 list_t * x1 = list_create(false, NULL);
235394 if (NULL != x1) {
@@ -251,7 +410,7 @@ struct RepositoryConnection * cJSON_GetRepositoryConnectionValue(const cJSON * j
251410 return x;
252411 }
253412
254-cJSON * cJSON_CreateRepositoryConnection(const struct RepositoryConnection * x) {
413+cJSON * cJSON_CreateUserRepositoryConnection(const struct UserRepositoryConnection * x) {
255414 cJSON * j = NULL;
256415 if (NULL != x) {
257416 if (NULL != (j = cJSON_CreateObject())) {
@@ -278,10 +437,10 @@ cJSON * cJSON_CreateRepositoryConnection(const struct RepositoryConnection * x)
278437 return j;
279438 }
280439
281-char * cJSON_PrintRepositoryConnection(const struct RepositoryConnection * x) {
440+char * cJSON_PrintUserRepositoryConnection(const struct UserRepositoryConnection * x) {
282441 char * s = NULL;
283442 if (NULL != x) {
284- cJSON * j = cJSON_CreateRepositoryConnection(x);
443+ cJSON * j = cJSON_CreateUserRepositoryConnection(x);
285444 if (NULL != j) {
286445 s = cJSON_Print(j);
287446 cJSON_Delete(j);
@@ -290,7 +449,7 @@ char * cJSON_PrintRepositoryConnection(const struct RepositoryConnection * x) {
290449 return s;
291450 }
292451
293-void cJSON_DeleteRepositoryConnection(struct RepositoryConnection * x) {
452+void cJSON_DeleteUserRepositoryConnection(struct UserRepositoryConnection * x) {
294453 if (NULL != x) {
295454 if (NULL != x->edges) {
296455 struct RepositoryEdge * x1 = list_get_head(x->edges);
@@ -306,6 +465,59 @@ void cJSON_DeleteRepositoryConnection(struct RepositoryConnection * x) {
306465 }
307466 }
308467
468+struct StarredRepositoryConnection * cJSON_ParseStarredRepositoryConnection(const char * s) {
469+ struct StarredRepositoryConnection * x = NULL;
470+ if (NULL != s) {
471+ cJSON * j = cJSON_Parse(s);
472+ if (NULL != j) {
473+ x = cJSON_GetStarredRepositoryConnectionValue(j);
474+ cJSON_Delete(j);
475+ }
476+ }
477+ return x;
478+}
479+
480+struct StarredRepositoryConnection * cJSON_GetStarredRepositoryConnectionValue(const cJSON * j) {
481+ struct StarredRepositoryConnection * x = NULL;
482+ if (NULL != j) {
483+ if (NULL != (x = cJSON_malloc(sizeof(struct StarredRepositoryConnection)))) {
484+ memset(x, 0, sizeof(struct StarredRepositoryConnection));
485+ if (cJSON_HasObjectItem(j, "totalCount")) {
486+ x->total_count = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "totalCount"));
487+ }
488+ }
489+ }
490+ return x;
491+}
492+
493+cJSON * cJSON_CreateStarredRepositoryConnection(const struct StarredRepositoryConnection * x) {
494+ cJSON * j = NULL;
495+ if (NULL != x) {
496+ if (NULL != (j = cJSON_CreateObject())) {
497+ cJSON_AddNumberToObject(j, "totalCount", x->total_count);
498+ }
499+ }
500+ return j;
501+}
502+
503+char * cJSON_PrintStarredRepositoryConnection(const struct StarredRepositoryConnection * x) {
504+ char * s = NULL;
505+ if (NULL != x) {
506+ cJSON * j = cJSON_CreateStarredRepositoryConnection(x);
507+ if (NULL != j) {
508+ s = cJSON_Print(j);
509+ cJSON_Delete(j);
510+ }
511+ }
512+ return s;
513+}
514+
515+void cJSON_DeleteStarredRepositoryConnection(struct StarredRepositoryConnection * x) {
516+ if (NULL != x) {
517+ cJSON_free(x);
518+ }
519+}
520+
309521 struct User * cJSON_ParseUser(const char * s) {
310522 struct User * x = NULL;
311523 if (NULL != s) {
@@ -332,10 +544,10 @@ struct User * cJSON_GetUserValue(const cJSON * j) {
332544 }
333545 }
334546 if (cJSON_HasObjectItem(j, "starredRepositories")) {
335- x->starred_repositories = cJSON_GetConnectionValue(cJSON_GetObjectItemCaseSensitive(j, "starredRepositories"));
547+ x->starred_repositories = cJSON_GetStarredRepositoryConnectionValue(cJSON_GetObjectItemCaseSensitive(j, "starredRepositories"));
336548 }
337549 if (cJSON_HasObjectItem(j, "repositories")) {
338- x->repositories = cJSON_GetRepositoryConnectionValue(cJSON_GetObjectItemCaseSensitive(j, "repositories"));
550+ x->repositories = cJSON_GetUserRepositoryConnectionValue(cJSON_GetObjectItemCaseSensitive(j, "repositories"));
339551 }
340552 }
341553 }
@@ -352,8 +564,8 @@ cJSON * cJSON_CreateUser(const struct User * x) {
352564 else {
353565 cJSON_AddStringToObject(j, "login", "");
354566 }
355- cJSON_AddItemToObject(j, "starredRepositories", cJSON_CreateConnection(x->starred_repositories));
356- cJSON_AddItemToObject(j, "repositories", cJSON_CreateRepositoryConnection(x->repositories));
567+ cJSON_AddItemToObject(j, "starredRepositories", cJSON_CreateStarredRepositoryConnection(x->starred_repositories));
568+ cJSON_AddItemToObject(j, "repositories", cJSON_CreateUserRepositoryConnection(x->repositories));
357569 }
358570 }
359571 return j;
@@ -377,10 +589,10 @@ void cJSON_DeleteUser(struct User * x) {
377589 cJSON_free(x->login);
378590 }
379591 if (NULL != x->starred_repositories) {
380- cJSON_DeleteConnection(x->starred_repositories);
592+ cJSON_DeleteStarredRepositoryConnection(x->starred_repositories);
381593 }
382594 if (NULL != x->repositories) {
383- cJSON_DeleteRepositoryConnection(x->repositories);
595+ cJSON_DeleteUserRepositoryConnection(x->repositories);
384596 }
385597 cJSON_free(x);
386598 }
Mgraphql-cjsondefault / TopLevel.h+58 −18
@@ -34,30 +34,46 @@ extern "C" {
3434 #define cJSON_Enum (1 << 17)
3535 #endif
3636
37-struct Connection {
37+struct RepositoryRepositoryConnection {
38+ int64_t total_count;
39+};
40+
41+struct IssueConnection {
42+ int64_t total_count;
43+};
44+
45+struct StargazerConnection {
46+ int64_t total_count;
47+};
48+
49+struct UserConnection {
3850 int64_t total_count;
3951 };
4052
4153 struct Repository {
4254 char * name;
43- struct Connection * stargazers;
44- struct Connection * forks;
45- struct Connection * watchers;
46- struct Connection * issues;
55+ struct StargazerConnection * stargazers;
56+ struct RepositoryRepositoryConnection * forks;
57+ struct UserConnection * watchers;
58+ struct IssueConnection * issues;
4759 };
4860
4961 struct RepositoryEdge {
5062 struct Repository * node;
5163 };
5264
53-struct RepositoryConnection {
65+struct UserRepositoryConnection {
5466 list_t * edges;
5567 };
5668
69+struct StarredRepositoryConnection {
70+ int64_t total_count;
71+};
72+
5773 struct User {
5874 char * login;
59- struct Connection * starred_repositories;
60- struct RepositoryConnection * repositories;
75+ struct StarredRepositoryConnection * starred_repositories;
76+ struct UserRepositoryConnection * repositories;
6177 };
6278
6379 struct Data {
@@ -73,11 +89,29 @@ struct TopLevel {
7389 list_t * errors;
7490 };
7591
76-struct Connection * cJSON_ParseConnection(const char * s);
77-struct Connection * cJSON_GetConnectionValue(const cJSON * j);
78-cJSON * cJSON_CreateConnection(const struct Connection * x);
79-char * cJSON_PrintConnection(const struct Connection * x);
80-void cJSON_DeleteConnection(struct Connection * x);
92+struct RepositoryRepositoryConnection * cJSON_ParseRepositoryRepositoryConnection(const char * s);
93+struct RepositoryRepositoryConnection * cJSON_GetRepositoryRepositoryConnectionValue(const cJSON * j);
94+cJSON * cJSON_CreateRepositoryRepositoryConnection(const struct RepositoryRepositoryConnection * x);
95+char * cJSON_PrintRepositoryRepositoryConnection(const struct RepositoryRepositoryConnection * x);
96+void cJSON_DeleteRepositoryRepositoryConnection(struct RepositoryRepositoryConnection * x);
97+
98+struct IssueConnection * cJSON_ParseIssueConnection(const char * s);
99+struct IssueConnection * cJSON_GetIssueConnectionValue(const cJSON * j);
100+cJSON * cJSON_CreateIssueConnection(const struct IssueConnection * x);
101+char * cJSON_PrintIssueConnection(const struct IssueConnection * x);
102+void cJSON_DeleteIssueConnection(struct IssueConnection * x);
103+
104+struct StargazerConnection * cJSON_ParseStargazerConnection(const char * s);
105+struct StargazerConnection * cJSON_GetStargazerConnectionValue(const cJSON * j);
106+cJSON * cJSON_CreateStargazerConnection(const struct StargazerConnection * x);
107+char * cJSON_PrintStargazerConnection(const struct StargazerConnection * x);
108+void cJSON_DeleteStargazerConnection(struct StargazerConnection * x);
109+
110+struct UserConnection * cJSON_ParseUserConnection(const char * s);
111+struct UserConnection * cJSON_GetUserConnectionValue(const cJSON * j);
112+cJSON * cJSON_CreateUserConnection(const struct UserConnection * x);
113+char * cJSON_PrintUserConnection(const struct UserConnection * x);
114+void cJSON_DeleteUserConnection(struct UserConnection * x);
81115
82116 struct Repository * cJSON_ParseRepository(const char * s);
83117 struct Repository * cJSON_GetRepositoryValue(const cJSON * j);
@@ -91,11 +125,17 @@ cJSON * cJSON_CreateRepositoryEdge(const struct RepositoryEdge * x);
91125 char * cJSON_PrintRepositoryEdge(const struct RepositoryEdge * x);
92126 void cJSON_DeleteRepositoryEdge(struct RepositoryEdge * x);
93127
94-struct RepositoryConnection * cJSON_ParseRepositoryConnection(const char * s);
95-struct RepositoryConnection * cJSON_GetRepositoryConnectionValue(const cJSON * j);
96-cJSON * cJSON_CreateRepositoryConnection(const struct RepositoryConnection * x);
97-char * cJSON_PrintRepositoryConnection(const struct RepositoryConnection * x);
98-void cJSON_DeleteRepositoryConnection(struct RepositoryConnection * x);
128+struct UserRepositoryConnection * cJSON_ParseUserRepositoryConnection(const char * s);
129+struct UserRepositoryConnection * cJSON_GetUserRepositoryConnectionValue(const cJSON * j);
130+cJSON * cJSON_CreateUserRepositoryConnection(const struct UserRepositoryConnection * x);
131+char * cJSON_PrintUserRepositoryConnection(const struct UserRepositoryConnection * x);
132+void cJSON_DeleteUserRepositoryConnection(struct UserRepositoryConnection * x);
133+
134+struct StarredRepositoryConnection * cJSON_ParseStarredRepositoryConnection(const char * s);
135+struct StarredRepositoryConnection * cJSON_GetStarredRepositoryConnectionValue(const cJSON * j);
136+cJSON * cJSON_CreateStarredRepositoryConnection(const struct StarredRepositoryConnection * x);
137+char * cJSON_PrintStarredRepositoryConnection(const struct StarredRepositoryConnection * x);
138+void cJSON_DeleteStarredRepositoryConnection(struct StarredRepositoryConnection * x);
99139
100140 struct User * cJSON_ParseUser(const char * s);
101141 struct User * cJSON_GetUserValue(const cJSON * j);
Mgraphql-cplusplusdefault / quicktype.hpp+148 −44
@@ -88,10 +88,52 @@ namespace quicktype {
8888 }
8989 #endif
9090
91- class Connection {
91+ class RepositoryRepositoryConnection {
9292 public:
93- Connection() = default;
94- virtual ~Connection() = default;
93+ RepositoryRepositoryConnection() = default;
94+ virtual ~RepositoryRepositoryConnection() = default;
95+
96+ private:
97+ int64_t total_count;
98+
99+ public:
100+ const int64_t & get_total_count() const { return total_count; }
101+ int64_t & get_mutable_total_count() { return total_count; }
102+ void set_total_count(const int64_t & value) { this->total_count = value; }
103+ };
104+
105+ class IssueConnection {
106+ public:
107+ IssueConnection() = default;
108+ virtual ~IssueConnection() = default;
109+
110+ private:
111+ int64_t total_count;
112+
113+ public:
114+ const int64_t & get_total_count() const { return total_count; }
115+ int64_t & get_mutable_total_count() { return total_count; }
116+ void set_total_count(const int64_t & value) { this->total_count = value; }
117+ };
118+
119+ class StargazerConnection {
120+ public:
121+ StargazerConnection() = default;
122+ virtual ~StargazerConnection() = default;
123+
124+ private:
125+ int64_t total_count;
126+
127+ public:
128+ const int64_t & get_total_count() const { return total_count; }
129+ int64_t & get_mutable_total_count() { return total_count; }
130+ void set_total_count(const int64_t & value) { this->total_count = value; }
131+ };
132+
133+ class UserConnection {
134+ public:
135+ UserConnection() = default;
136+ virtual ~UserConnection() = default;
95137
96138 private:
97139 int64_t total_count;
@@ -109,31 +151,31 @@ namespace quicktype {
109151
110152 private:
111153 std::string name;
112- Connection stargazers;
113- Connection forks;
114- Connection watchers;
115- Connection issues;
154+ StargazerConnection stargazers;
155+ RepositoryRepositoryConnection forks;
156+ UserConnection watchers;
157+ IssueConnection issues;
116158
117159 public:
118160 const std::string & get_name() const { return name; }
119161 std::string & get_mutable_name() { return name; }
120162 void set_name(const std::string & value) { this->name = value; }
121163
122- const Connection & get_stargazers() const { return stargazers; }
123- Connection & get_mutable_stargazers() { return stargazers; }
124- void set_stargazers(const Connection & value) { this->stargazers = value; }
164+ const StargazerConnection & get_stargazers() const { return stargazers; }
165+ StargazerConnection & get_mutable_stargazers() { return stargazers; }
166+ void set_stargazers(const StargazerConnection & value) { this->stargazers = value; }
125167
126- const Connection & get_forks() const { return forks; }
127- Connection & get_mutable_forks() { return forks; }
128- void set_forks(const Connection & value) { this->forks = value; }
168+ const RepositoryRepositoryConnection & get_forks() const { return forks; }
169+ RepositoryRepositoryConnection & get_mutable_forks() { return forks; }
170+ void set_forks(const RepositoryRepositoryConnection & value) { this->forks = value; }
129171
130- const Connection & get_watchers() const { return watchers; }
131- Connection & get_mutable_watchers() { return watchers; }
132- void set_watchers(const Connection & value) { this->watchers = value; }
172+ const UserConnection & get_watchers() const { return watchers; }
173+ UserConnection & get_mutable_watchers() { return watchers; }
174+ void set_watchers(const UserConnection & value) { this->watchers = value; }
133175
134- const Connection & get_issues() const { return issues; }
135- Connection & get_mutable_issues() { return issues; }
136- void set_issues(const Connection & value) { this->issues = value; }
176+ const IssueConnection & get_issues() const { return issues; }
177+ IssueConnection & get_mutable_issues() { return issues; }
178+ void set_issues(const IssueConnection & value) { this->issues = value; }
137179 };
138180
139181 class RepositoryEdge {
@@ -149,10 +191,10 @@ namespace quicktype {
149191 void set_node(std::optional<Repository> value) { this->node = value; }
150192 };
151193
152- class RepositoryConnection {
194+ class UserRepositoryConnection {
153195 public:
154- RepositoryConnection() = default;
155- virtual ~RepositoryConnection() = default;
196+ UserRepositoryConnection() = default;
197+ virtual ~UserRepositoryConnection() = default;
156198
157199 private:
158200 std::optional<std::vector<std::optional<RepositoryEdge>>> edges;
@@ -162,6 +204,20 @@ namespace quicktype {
162204 void set_edges(std::optional<std::vector<std::optional<RepositoryEdge>>> value) { this->edges = value; }
163205 };
164206
207+ class StarredRepositoryConnection {
208+ public:
209+ StarredRepositoryConnection() = default;
210+ virtual ~StarredRepositoryConnection() = default;
211+
212+ private:
213+ int64_t total_count;
214+
215+ public:
216+ const int64_t & get_total_count() const { return total_count; }
217+ int64_t & get_mutable_total_count() { return total_count; }
218+ void set_total_count(const int64_t & value) { this->total_count = value; }
219+ };
220+
165221 class User {
166222 public:
167223 User() = default;
@@ -169,21 +225,21 @@ namespace quicktype {
169225
170226 private:
171227 std::string login;
172- Connection starred_repositories;
173- RepositoryConnection repositories;
228+ StarredRepositoryConnection starred_repositories;
229+ UserRepositoryConnection repositories;
174230
175231 public:
176232 const std::string & get_login() const { return login; }
177233 std::string & get_mutable_login() { return login; }
178234 void set_login(const std::string & value) { this->login = value; }
179235
180- const Connection & get_starred_repositories() const { return starred_repositories; }
181- Connection & get_mutable_starred_repositories() { return starred_repositories; }
182- void set_starred_repositories(const Connection & value) { this->starred_repositories = value; }
236+ const StarredRepositoryConnection & get_starred_repositories() const { return starred_repositories; }
237+ StarredRepositoryConnection & get_mutable_starred_repositories() { return starred_repositories; }
238+ void set_starred_repositories(const StarredRepositoryConnection & value) { this->starred_repositories = value; }
183239
184- const RepositoryConnection & get_repositories() const { return repositories; }
185- RepositoryConnection & get_mutable_repositories() { return repositories; }
186- void set_repositories(const RepositoryConnection & value) { this->repositories = value; }
240+ const UserRepositoryConnection & get_repositories() const { return repositories; }
241+ UserRepositoryConnection & get_mutable_repositories() { return repositories; }
242+ void set_repositories(const UserRepositoryConnection & value) { this->repositories = value; }
187243 };
188244
189245 class Data {
@@ -234,8 +290,17 @@ namespace quicktype {
234290 }
235291
236292 namespace quicktype {
237- void from_json(const json & j, Connection & x);
238- void to_json(json & j, const Connection & x);
293+ void from_json(const json & j, RepositoryRepositoryConnection & x);
294+ void to_json(json & j, const RepositoryRepositoryConnection & x);
295+
296+ void from_json(const json & j, IssueConnection & x);
297+ void to_json(json & j, const IssueConnection & x);
298+
299+ void from_json(const json & j, StargazerConnection & x);
300+ void to_json(json & j, const StargazerConnection & x);
301+
302+ void from_json(const json & j, UserConnection & x);
303+ void to_json(json & j, const UserConnection & x);
239304
240305 void from_json(const json & j, Repository & x);
241306 void to_json(json & j, const Repository & x);
@@ -243,8 +308,11 @@ namespace quicktype {
243308 void from_json(const json & j, RepositoryEdge & x);
244309 void to_json(json & j, const RepositoryEdge & x);
245310
246- void from_json(const json & j, RepositoryConnection & x);
247- void to_json(json & j, const RepositoryConnection & x);
311+ void from_json(const json & j, UserRepositoryConnection & x);
312+ void to_json(json & j, const UserRepositoryConnection & x);
313+
314+ void from_json(const json & j, StarredRepositoryConnection & x);
315+ void to_json(json & j, const StarredRepositoryConnection & x);
248316
249317 void from_json(const json & j, User & x);
250318 void to_json(json & j, const User & x);
@@ -258,21 +326,48 @@ namespace quicktype {
258326 void from_json(const json & j, TopLevel & x);
259327 void to_json(json & j, const TopLevel & x);
260328
261- inline void from_json(const json & j, Connection& x) {
329+ inline void from_json(const json & j, RepositoryRepositoryConnection& x) {
330+ x.set_total_count(j.at("totalCount").get<int64_t>());
331+ }
332+
333+ inline void to_json(json & j, const RepositoryRepositoryConnection & x) {
334+ j = json::object();
335+ j["totalCount"] = x.get_total_count();
336+ }
337+
338+ inline void from_json(const json & j, IssueConnection& x) {
339+ x.set_total_count(j.at("totalCount").get<int64_t>());
340+ }
341+
342+ inline void to_json(json & j, const IssueConnection & x) {
343+ j = json::object();
344+ j["totalCount"] = x.get_total_count();
345+ }
346+
347+ inline void from_json(const json & j, StargazerConnection& x) {
262348 x.set_total_count(j.at("totalCount").get<int64_t>());
263349 }
264350
265- inline void to_json(json & j, const Connection & x) {
351+ inline void to_json(json & j, const StargazerConnection & x) {
352+ j = json::object();
353+ j["totalCount"] = x.get_total_count();
354+ }
355+
356+ inline void from_json(const json & j, UserConnection& x) {
357+ x.set_total_count(j.at("totalCount").get<int64_t>());
358+ }
359+
360+ inline void to_json(json & j, const UserConnection & x) {
266361 j = json::object();
267362 j["totalCount"] = x.get_total_count();
268363 }
269364
270365 inline void from_json(const json & j, Repository& x) {
271366 x.set_name(j.at("name").get<std::string>());
272- x.set_stargazers(j.at("stargazers").get<Connection>());
273- x.set_forks(j.at("forks").get<Connection>());
274- x.set_watchers(j.at("watchers").get<Connection>());
275- x.set_issues(j.at("issues").get<Connection>());
367+ x.set_stargazers(j.at("stargazers").get<StargazerConnection>());
368+ x.set_forks(j.at("forks").get<RepositoryRepositoryConnection>());
369+ x.set_watchers(j.at("watchers").get<UserConnection>());
370+ x.set_issues(j.at("issues").get<IssueConnection>());
276371 }
277372
278373 inline void to_json(json & j, const Repository & x) {
@@ -293,19 +388,28 @@ namespace quicktype {
293388 j["node"] = x.get_node();
294389 }
295390
296- inline void from_json(const json & j, RepositoryConnection& x) {
391+ inline void from_json(const json & j, UserRepositoryConnection& x) {
297392 x.set_edges(get_stack_optional<std::vector<std::optional<RepositoryEdge>>>(j, "edges"));
298393 }
299394
300- inline void to_json(json & j, const RepositoryConnection & x) {
395+ inline void to_json(json & j, const UserRepositoryConnection & x) {
301396 j = json::object();
302397 j["edges"] = x.get_edges();
303398 }
304399
400+ inline void from_json(const json & j, StarredRepositoryConnection& x) {
401+ x.set_total_count(j.at("totalCount").get<int64_t>());
402+ }
403+
404+ inline void to_json(json & j, const StarredRepositoryConnection & x) {
405+ j = json::object();
406+ j["totalCount"] = x.get_total_count();
407+ }
408+
305409 inline void from_json(const json & j, User& x) {
306410 x.set_login(j.at("login").get<std::string>());
307- x.set_starred_repositories(j.at("starredRepositories").get<Connection>());
308- x.set_repositories(j.at("repositories").get<RepositoryConnection>());
411+ x.set_starred_repositories(j.at("starredRepositories").get<StarredRepositoryConnection>());
412+ x.set_repositories(j.at("repositories").get<UserRepositoryConnection>());
309413 }
310414
311415 inline void to_json(json & j, const User & x) {
Mgraphql-csharpdefault / QuickType.cs+32 −8
@@ -44,13 +44,13 @@ namespace QuickType
4444 public string Login { get; set; }
4545
4646 [JsonProperty("starredRepositories", Required = Required.Always)]
47- public Connection StarredRepositories { get; set; }
47+ public StarredRepositoryConnection StarredRepositories { get; set; }
4848
4949 [JsonProperty("repositories", Required = Required.Always)]
50- public RepositoryConnection Repositories { get; set; }
50+ public UserRepositoryConnection Repositories { get; set; }
5151 }
5252
53- public partial class RepositoryConnection
53+ public partial class UserRepositoryConnection
5454 {
5555 [JsonProperty("edges", Required = Required.AllowNull)]
5656 public RepositoryEdge?[]? Edges { get; set; }
@@ -68,19 +68,43 @@ namespace QuickType
6868 public string Name { get; set; }
6969
7070 [JsonProperty("stargazers", Required = Required.Always)]
71- public Connection Stargazers { get; set; }
71+ public StargazerConnection Stargazers { get; set; }
7272
7373 [JsonProperty("forks", Required = Required.Always)]
74- public Connection Forks { get; set; }
74+ public RepositoryRepositoryConnection Forks { get; set; }
7575
7676 [JsonProperty("watchers", Required = Required.Always)]
77- public Connection Watchers { get; set; }
77+ public UserConnection Watchers { get; set; }
7878
7979 [JsonProperty("issues", Required = Required.Always)]
80- public Connection Issues { get; set; }
80+ public IssueConnection Issues { get; set; }
8181 }
8282
83- public partial class Connection
83+ public partial class RepositoryRepositoryConnection
84+ {
85+ [JsonProperty("totalCount", Required = Required.Always)]
86+ public long TotalCount { get; set; }
87+ }
88+
89+ public partial class IssueConnection
90+ {
91+ [JsonProperty("totalCount", Required = Required.Always)]
92+ public long TotalCount { get; set; }
93+ }
94+
95+ public partial class StargazerConnection
96+ {
97+ [JsonProperty("totalCount", Required = Required.Always)]
98+ public long TotalCount { get; set; }
99+ }
100+
101+ public partial class UserConnection
102+ {
103+ [JsonProperty("totalCount", Required = Required.Always)]
104+ public long TotalCount { get; set; }
105+ }
106+
107+ public partial class StarredRepositoryConnection
84108 {
85109 [JsonProperty("totalCount", Required = Required.Always)]
86110 public long TotalCount { get; set; }
Mgraphql-dartdefault / TopLevel.dart+82 −18
@@ -46,8 +46,8 @@ class Data {
4646
4747 class User {
4848 final String login;
49- final Connection starredRepositories;
50- final RepositoryConnection repositories;
49+ final StarredRepositoryConnection starredRepositories;
50+ final UserRepositoryConnection repositories;
5151
5252 User({
5353 required this.login,
@@ -57,8 +57,8 @@ class User {
5757
5858 factory User.fromJson(Map<String, dynamic> json) => User(
5959 login: json["login"],
60- starredRepositories: Connection.fromJson(json["starredRepositories"]),
61- repositories: RepositoryConnection.fromJson(json["repositories"]),
60+ starredRepositories: StarredRepositoryConnection.fromJson(json["starredRepositories"]),
61+ repositories: UserRepositoryConnection.fromJson(json["repositories"]),
6262 );
6363
6464 Map<String, dynamic> toJson() => {
@@ -68,14 +68,14 @@ class User {
6868 };
6969 }
7070
71-class RepositoryConnection {
71+class UserRepositoryConnection {
7272 final List<RepositoryEdge?>? edges;
7373
74- RepositoryConnection({
74+ UserRepositoryConnection({
7575 required this.edges,
7676 });
7777
78- factory RepositoryConnection.fromJson(Map<String, dynamic> json) => RepositoryConnection(
78+ factory UserRepositoryConnection.fromJson(Map<String, dynamic> json) => UserRepositoryConnection(
7979 edges: json["edges"] == null ? null : List<RepositoryEdge?>.from(json["edges"]!.map((x) => x == null ? null : RepositoryEdge.fromJson(x))),
8080 );
8181
@@ -102,10 +102,10 @@ class RepositoryEdge {
102102
103103 class Repository {
104104 final String name;
105- final Connection stargazers;
106- final Connection forks;
107- final Connection watchers;
108- final Connection issues;
105+ final StargazerConnection stargazers;
106+ final RepositoryRepositoryConnection forks;
107+ final UserConnection watchers;
108+ final IssueConnection issues;
109109
110110 Repository({
111111 required this.name,
@@ -117,10 +117,10 @@ class Repository {
117117
118118 factory Repository.fromJson(Map<String, dynamic> json) => Repository(
119119 name: json["name"],
120- stargazers: Connection.fromJson(json["stargazers"]),
121- forks: Connection.fromJson(json["forks"]),
122- watchers: Connection.fromJson(json["watchers"]),
123- issues: Connection.fromJson(json["issues"]),
120+ stargazers: StargazerConnection.fromJson(json["stargazers"]),
121+ forks: RepositoryRepositoryConnection.fromJson(json["forks"]),
122+ watchers: UserConnection.fromJson(json["watchers"]),
123+ issues: IssueConnection.fromJson(json["issues"]),
124124 );
125125
126126 Map<String, dynamic> toJson() => {
@@ -132,14 +132,78 @@ class Repository {
132132 };
133133 }
134134
135-class Connection {
135+class RepositoryRepositoryConnection {
136136 final int totalCount;
137137
138- Connection({
138+ RepositoryRepositoryConnection({
139139 required this.totalCount,
140140 });
141141
142- factory Connection.fromJson(Map<String, dynamic> json) => Connection(
142+ factory RepositoryRepositoryConnection.fromJson(Map<String, dynamic> json) => RepositoryRepositoryConnection(
143+ totalCount: json["totalCount"],
144+ );
145+
146+ Map<String, dynamic> toJson() => {
147+ "totalCount": totalCount,
148+ };
149+}
150+
151+class IssueConnection {
152+ final int totalCount;
153+
154+ IssueConnection({
155+ required this.totalCount,
156+ });
157+
158+ factory IssueConnection.fromJson(Map<String, dynamic> json) => IssueConnection(
159+ totalCount: json["totalCount"],
160+ );
161+
162+ Map<String, dynamic> toJson() => {
163+ "totalCount": totalCount,
164+ };
165+}
166+
167+class StargazerConnection {
168+ final int totalCount;
169+
170+ StargazerConnection({
171+ required this.totalCount,
172+ });
173+
174+ factory StargazerConnection.fromJson(Map<String, dynamic> json) => StargazerConnection(
175+ totalCount: json["totalCount"],
176+ );
177+
178+ Map<String, dynamic> toJson() => {
179+ "totalCount": totalCount,
180+ };
181+}
182+
183+class UserConnection {
184+ final int totalCount;
185+
186+ UserConnection({
187+ required this.totalCount,
188+ });
189+
190+ factory UserConnection.fromJson(Map<String, dynamic> json) => UserConnection(
191+ totalCount: json["totalCount"],
192+ );
193+
194+ Map<String, dynamic> toJson() => {
195+ "totalCount": totalCount,
196+ };
197+}
198+
199+class StarredRepositoryConnection {
200+ final int totalCount;
201+
202+ StarredRepositoryConnection({
203+ required this.totalCount,
204+ });
205+
206+ factory StarredRepositoryConnection.fromJson(Map<String, dynamic> json) => StarredRepositoryConnection(
143207 totalCount: json["totalCount"],
144208 );
Mgraphql-elixirdefault / QuickType.ex+156 −24
@@ -5,7 +5,7 @@
55 # Decode a JSON string: TopLevel.from_json(data)
66 # Encode into a JSON string: TopLevel.to_json(struct)
77
8-defmodule Connection do
8+defmodule RepositoryRepositoryConnection do
99 @enforce_keys [:total_count]
1010 defstruct [:total_count]
1111
@@ -14,7 +14,106 @@ defmodule Connection do
1414 }
1515
1616 def from_map(m) do
17- %Connection{
17+ %RepositoryRepositoryConnection{
18+ total_count: m["totalCount"],
19+ }
20+ end
21+
22+ def from_json(json) do
23+ json
24+ |> Jason.decode!()
25+ |> from_map()
26+ end
27+
28+ def to_map(struct) do
29+ %{
30+ "totalCount" => struct.total_count,
31+ }
32+ end
33+
34+ def to_json(struct) do
35+ struct
36+ |> to_map()
37+ |> Jason.encode!()
38+ end
39+end
40+
41+defmodule IssueConnection do
42+ @enforce_keys [:total_count]
43+ defstruct [:total_count]
44+
45+ @type t :: %__MODULE__{
46+ total_count: integer()
47+ }
48+
49+ def from_map(m) do
50+ %IssueConnection{
51+ total_count: m["totalCount"],
52+ }
53+ end
54+
55+ def from_json(json) do
56+ json
57+ |> Jason.decode!()
58+ |> from_map()
59+ end
60+
61+ def to_map(struct) do
62+ %{
63+ "totalCount" => struct.total_count,
64+ }
65+ end
66+
67+ def to_json(struct) do
68+ struct
69+ |> to_map()
70+ |> Jason.encode!()
71+ end
72+end
73+
74+defmodule StargazerConnection do
75+ @enforce_keys [:total_count]
76+ defstruct [:total_count]
77+
78+ @type t :: %__MODULE__{
79+ total_count: integer()
80+ }
81+
82+ def from_map(m) do
83+ %StargazerConnection{
84+ total_count: m["totalCount"],
85+ }
86+ end
87+
88+ def from_json(json) do
89+ json
90+ |> Jason.decode!()
91+ |> from_map()
92+ end
93+
94+ def to_map(struct) do
95+ %{
96+ "totalCount" => struct.total_count,
97+ }
98+ end
99+
100+ def to_json(struct) do
101+ struct
102+ |> to_map()
103+ |> Jason.encode!()
104+ end
105+end
106+
107+defmodule UserConnection do
108+ @enforce_keys [:total_count]
109+ defstruct [:total_count]
110+
111+ @type t :: %__MODULE__{
112+ total_count: integer()
113+ }
114+
115+ def from_map(m) do
116+ %UserConnection{
18117 total_count: m["totalCount"],
19118 }
20119 end
@@ -44,19 +143,19 @@ defmodule Repository do
44143
45144 @type t :: %__MODULE__{
46145 name: String.t(),
47- stargazers: Connection.t(),
48- forks: Connection.t(),
49- watchers: Connection.t(),
50- issues: Connection.t()
146+ stargazers: StargazerConnection.t(),
147+ forks: RepositoryRepositoryConnection.t(),
148+ watchers: UserConnection.t(),
149+ issues: IssueConnection.t()
51150 }
52151
53152 def from_map(m) do
54153 %Repository{
55154 name: m["name"],
56- stargazers: Connection.from_map(m["stargazers"]),
57- forks: Connection.from_map(m["forks"]),
58- watchers: Connection.from_map(m["watchers"]),
59- issues: Connection.from_map(m["issues"]),
155+ stargazers: StargazerConnection.from_map(m["stargazers"]),
156+ forks: RepositoryRepositoryConnection.from_map(m["forks"]),
157+ watchers: UserConnection.from_map(m["watchers"]),
158+ issues: IssueConnection.from_map(m["issues"]),
60159 }
61160 end
62161
@@ -69,10 +168,10 @@ defmodule Repository do
69168 def to_map(struct) do
70169 %{
71170 "name" => struct.name,
72- "stargazers" => Connection.to_map(struct.stargazers),
73- "forks" => Connection.to_map(struct.forks),
74- "watchers" => Connection.to_map(struct.watchers),
75- "issues" => Connection.to_map(struct.issues),
171+ "stargazers" => StargazerConnection.to_map(struct.stargazers),
172+ "forks" => RepositoryRepositoryConnection.to_map(struct.forks),
173+ "watchers" => UserConnection.to_map(struct.watchers),
174+ "issues" => IssueConnection.to_map(struct.issues),
76175 }
77176 end
78177
@@ -116,7 +215,7 @@ defmodule RepositoryEdge do
116215 end
117216 end
118217
119-defmodule RepositoryConnection do
218+defmodule UserRepositoryConnection do
120219 @enforce_keys [:edges]
121220 defstruct [:edges]
122221
@@ -126,14 +225,14 @@ defmodule RepositoryConnection do
126225
127226 def decode_edges_element(%{"node" => _,} = value), do: RepositoryEdge.from_map(value)
128227 def decode_edges_element(value) when is_nil(value), do: value
129- def decode_edges_element(_), do: {:error, "Unexpected type when decoding RepositoryConnection.edges"}
228+ def decode_edges_element(_), do: {:error, "Unexpected type when decoding UserRepositoryConnection.edges"}
130229
131230 def encode_edges_element(%RepositoryEdge{} = value), do: RepositoryEdge.to_map(value)
132231 def encode_edges_element(value) when is_nil(value), do: value
133- def encode_edges_element(_), do: {:error, "Unexpected type when encoding RepositoryConnection.edges"}
232+ def encode_edges_element(_), do: {:error, "Unexpected type when encoding UserRepositoryConnection.edges"}
134233
135234 def from_map(m) do
136- %RepositoryConnection{
235+ %UserRepositoryConnection{
137236 edges: m["edges"] && Enum.map(m["edges"], &decode_edges_element/1),
138237 }
139238 end
@@ -157,21 +256,54 @@ defmodule RepositoryConnection do
157256 end
158257 end
159258
259+defmodule StarredRepositoryConnection do
260+ @enforce_keys [:total_count]
261+ defstruct [:total_count]
262+
263+ @type t :: %__MODULE__{
264+ total_count: integer()
265+ }
266+
267+ def from_map(m) do
268+ %StarredRepositoryConnection{
269+ total_count: m["totalCount"],
270+ }
271+ end
272+
273+ def from_json(json) do
274+ json
275+ |> Jason.decode!()
276+ |> from_map()
277+ end
278+
279+ def to_map(struct) do
280+ %{
281+ "totalCount" => struct.total_count,
282+ }
283+ end
284+
285+ def to_json(struct) do
286+ struct
287+ |> to_map()
288+ |> Jason.encode!()
289+ end
290+end
291+
160292 defmodule User do
161293 @enforce_keys [:login, :starred_repositories, :repositories]
162294 defstruct [:login, :starred_repositories, :repositories]
163295
164296 @type t :: %__MODULE__{
165297 login: String.t(),
166- starred_repositories: Connection.t(),
167- repositories: RepositoryConnection.t()
298+ starred_repositories: StarredRepositoryConnection.t(),
299+ repositories: UserRepositoryConnection.t()
168300 }
169301
170302 def from_map(m) do
171303 %User{
172304 login: m["login"],
173- starred_repositories: Connection.from_map(m["starredRepositories"]),
174- repositories: RepositoryConnection.from_map(m["repositories"]),
305+ starred_repositories: StarredRepositoryConnection.from_map(m["starredRepositories"]),
306+ repositories: UserRepositoryConnection.from_map(m["repositories"]),
175307 }
176308 end
177309
@@ -184,8 +316,8 @@ defmodule User do
184316 def to_map(struct) do
185317 %{
186318 "login" => struct.login,
187- "starredRepositories" => Connection.to_map(struct.starred_repositories),
188- "repositories" => RepositoryConnection.to_map(struct.repositories),
319+ "starredRepositories" => StarredRepositoryConnection.to_map(struct.starred_repositories),
320+ "repositories" => UserRepositoryConnection.to_map(struct.repositories),
189321 }
190322 end
Mgraphql-flowdefault / TopLevel.js+44 −16
@@ -20,11 +20,11 @@ export type Data = {
2020
2121 export type User = {
2222 login: string;
23- starredRepositories: Connection;
24- repositories: RepositoryConnection;
23+ starredRepositories: StarredRepositoryConnection;
24+ repositories: UserRepositoryConnection;
2525 };
2626
27-export type RepositoryConnection = {
27+export type UserRepositoryConnection = {
2828 edges: (RepositoryEdge | null)[] | null;
2929 };
3030
@@ -34,13 +34,29 @@ export type RepositoryEdge = {
3434
3535 export type Repository = {
3636 name: string;
37- stargazers: Connection;
38- forks: Connection;
39- watchers: Connection;
40- issues: Connection;
37+ stargazers: StargazerConnection;
38+ forks: RepositoryRepositoryConnection;
39+ watchers: UserConnection;
40+ issues: IssueConnection;
4141 };
4242
43-export type Connection = {
43+export type RepositoryRepositoryConnection = {
44+ totalCount: number;
45+};
46+
47+export type IssueConnection = {
48+ totalCount: number;
49+};
50+
51+export type StargazerConnection = {
52+ totalCount: number;
53+};
54+
55+export type UserConnection = {
56+ totalCount: number;
57+};
58+
59+export type StarredRepositoryConnection = {
4460 totalCount: number;
4561 };
4662
@@ -221,10 +237,10 @@ const typeMap: any = {
221237 ], false),
222238 "User": o([
223239 { json: "login", js: "login", typ: "" },
224- { json: "starredRepositories", js: "starredRepositories", typ: r("Connection") },
225- { json: "repositories", js: "repositories", typ: r("RepositoryConnection") },
240+ { json: "starredRepositories", js: "starredRepositories", typ: r("StarredRepositoryConnection") },
241+ { json: "repositories", js: "repositories", typ: r("UserRepositoryConnection") },
226242 ], false),
227- "RepositoryConnection": o([
243+ "UserRepositoryConnection": o([
228244 { json: "edges", js: "edges", typ: u(a(u(r("RepositoryEdge"), null)), null) },
229245 ], false),
230246 "RepositoryEdge": o([
@@ -232,12 +248,24 @@ const typeMap: any = {
232248 ], false),
233249 "Repository": o([
234250 { json: "name", js: "name", typ: "" },
235- { json: "stargazers", js: "stargazers", typ: r("Connection") },
236- { json: "forks", js: "forks", typ: r("Connection") },
237- { json: "watchers", js: "watchers", typ: r("Connection") },
238- { json: "issues", js: "issues", typ: r("Connection") },
251+ { json: "stargazers", js: "stargazers", typ: r("StargazerConnection") },
252+ { json: "forks", js: "forks", typ: r("RepositoryRepositoryConnection") },
253+ { json: "watchers", js: "watchers", typ: r("UserConnection") },
254+ { json: "issues", js: "issues", typ: r("IssueConnection") },
255+ ], false),
256+ "RepositoryRepositoryConnection": o([
257+ { json: "totalCount", js: "totalCount", typ: 0 },
258+ ], false),
259+ "IssueConnection": o([
260+ { json: "totalCount", js: "totalCount", typ: 0 },
261+ ], false),
262+ "StargazerConnection": o([
263+ { json: "totalCount", js: "totalCount", typ: 0 },
264+ ], false),
265+ "UserConnection": o([
266+ { json: "totalCount", js: "totalCount", typ: 0 },
239267 ], false),
240- "Connection": o([
268+ "StarredRepositoryConnection": o([
241269 { json: "totalCount", js: "totalCount", typ: 0 },
242270 ], false),
243271 "ErrorElement": o([
Mgraphql-golangdefault / quicktype.go+26 −10
@@ -28,12 +28,12 @@ type Data struct {
2828 }
2929
3030 type User struct {
31- Login string `json:"login"`
32- StarredRepositories Connection `json:"starredRepositories"`
33- Repositories RepositoryConnection `json:"repositories"`
31+ Login string `json:"login"`
32+ StarredRepositories StarredRepositoryConnection `json:"starredRepositories"`
33+ Repositories UserRepositoryConnection `json:"repositories"`
3434 }
3535
36-type RepositoryConnection struct {
36+type UserRepositoryConnection struct {
3737 Edges []*RepositoryEdge `json:"edges"`
3838 }
3939
@@ -42,14 +42,30 @@ type RepositoryEdge struct {
4242 }
4343
4444 type Repository struct {
45- Name string `json:"name"`
46- Stargazers Connection `json:"stargazers"`
47- Forks Connection `json:"forks"`
48- Watchers Connection `json:"watchers"`
49- Issues Connection `json:"issues"`
45+ Name string `json:"name"`
46+ Stargazers StargazerConnection `json:"stargazers"`
47+ Forks RepositoryRepositoryConnection `json:"forks"`
48+ Watchers UserConnection `json:"watchers"`
49+ Issues IssueConnection `json:"issues"`
5050 }
5151
52-type Connection struct {
52+type RepositoryRepositoryConnection struct {
53+ TotalCount int64 `json:"totalCount"`
54+}
55+
56+type IssueConnection struct {
57+ TotalCount int64 `json:"totalCount"`
58+}
59+
60+type StargazerConnection struct {
61+ TotalCount int64 `json:"totalCount"`
62+}
63+
64+type UserConnection struct {
65+ TotalCount int64 `json:"totalCount"`
66+}
67+
68+type StarredRepositoryConnection struct {
5369 TotalCount int64 `json:"totalCount"`
5470 }
Mgraphql-haskelldefault / QuickType.hs+82 −22
@@ -6,10 +6,14 @@ module QuickType
66 , ErrorElement (..)
77 , Data (..)
88 , User (..)
9- , RepositoryConnection (..)
9+ , UserRepositoryConnection (..)
1010 , RepositoryEdge (..)
1111 , Repository (..)
12- , Connection (..)
12+ , RepositoryRepositoryConnection (..)
13+ , IssueConnection (..)
14+ , StargazerConnection (..)
15+ , UserConnection (..)
16+ , StarredRepositoryConnection (..)
1317 , decodeTopLevel
1418 ) where
1519
@@ -34,12 +38,12 @@ data Data = Data
3438
3539 data User = User
3640 { loginUser :: Text
37- , starredRepositoriesUser :: Connection
38- , repositoriesUser :: RepositoryConnection
41+ , starredRepositoriesUser :: StarredRepositoryConnection
42+ , repositoriesUser :: UserRepositoryConnection
3943 } deriving (Show)
4044
41-data RepositoryConnection = RepositoryConnection
42- { edgesRepositoryConnection :: Maybe ([(Maybe RepositoryEdge)])
45+data UserRepositoryConnection = UserRepositoryConnection
46+ { edgesUserRepositoryConnection :: Maybe ([(Maybe RepositoryEdge)])
4347 } deriving (Show)
4448
4549 data RepositoryEdge = RepositoryEdge
@@ -48,14 +52,30 @@ data RepositoryEdge = RepositoryEdge
4852
4953 data Repository = Repository
5054 { nameRepository :: Text
51- , stargazersRepository :: Connection
52- , forksRepository :: Connection
53- , watchersRepository :: Connection
54- , issuesRepository :: Connection
55+ , stargazersRepository :: StargazerConnection
56+ , forksRepository :: RepositoryRepositoryConnection
57+ , watchersRepository :: UserConnection
58+ , issuesRepository :: IssueConnection
5559 } deriving (Show)
5660
57-data Connection = Connection
58- { totalCountConnection :: Int
61+data RepositoryRepositoryConnection = RepositoryRepositoryConnection
62+ { totalCountRepositoryRepositoryConnection :: Int
63+ } deriving (Show)
64+
65+data IssueConnection = IssueConnection
66+ { totalCountIssueConnection :: Int
67+ } deriving (Show)
68+
69+data StargazerConnection = StargazerConnection
70+ { totalCountStargazerConnection :: Int
71+ } deriving (Show)
72+
73+data UserConnection = UserConnection
74+ { totalCountUserConnection :: Int
75+ } deriving (Show)
76+
77+data StarredRepositoryConnection = StarredRepositoryConnection
78+ { totalCountStarredRepositoryConnection :: Int
5979 } deriving (Show)
6080
6181 decodeTopLevel :: ByteString -> Maybe QuickType
@@ -107,14 +127,14 @@ instance FromJSON User where
107127 <*> v .: "starredRepositories"
108128 <*> v .: "repositories"
109129
110-instance ToJSON RepositoryConnection where
111- toJSON (RepositoryConnection edgesRepositoryConnection) =
130+instance ToJSON UserRepositoryConnection where
131+ toJSON (UserRepositoryConnection edgesUserRepositoryConnection) =
112132 object
113- [ "edges" .= edgesRepositoryConnection
133+ [ "edges" .= edgesUserRepositoryConnection
114134 ]
115135
116-instance FromJSON RepositoryConnection where
117- parseJSON (Object v) = RepositoryConnection
136+instance FromJSON UserRepositoryConnection where
137+ parseJSON (Object v) = UserRepositoryConnection
118138 <$> v .: "edges"
119139
120140 instance ToJSON RepositoryEdge where
@@ -145,12 +165,52 @@ instance FromJSON Repository where
145165 <*> v .: "watchers"
146166 <*> v .: "issues"
147167
148-instance ToJSON Connection where
149- toJSON (Connection totalCountConnection) =
168+instance ToJSON RepositoryRepositoryConnection where
169+ toJSON (RepositoryRepositoryConnection totalCountRepositoryRepositoryConnection) =
170+ object
171+ [ "totalCount" .= totalCountRepositoryRepositoryConnection
172+ ]
173+
174+instance FromJSON RepositoryRepositoryConnection where
175+ parseJSON (Object v) = RepositoryRepositoryConnection
176+ <$> v .: "totalCount"
177+
178+instance ToJSON IssueConnection where
179+ toJSON (IssueConnection totalCountIssueConnection) =
180+ object
181+ [ "totalCount" .= totalCountIssueConnection
182+ ]
183+
184+instance FromJSON IssueConnection where
185+ parseJSON (Object v) = IssueConnection
186+ <$> v .: "totalCount"
187+
188+instance ToJSON StargazerConnection where
189+ toJSON (StargazerConnection totalCountStargazerConnection) =
190+ object
191+ [ "totalCount" .= totalCountStargazerConnection
192+ ]
193+
194+instance FromJSON StargazerConnection where
195+ parseJSON (Object v) = StargazerConnection
196+ <$> v .: "totalCount"
197+
198+instance ToJSON UserConnection where
199+ toJSON (UserConnection totalCountUserConnection) =
200+ object
201+ [ "totalCount" .= totalCountUserConnection
202+ ]
203+
204+instance FromJSON UserConnection where
205+ parseJSON (Object v) = UserConnection
206+ <$> v .: "totalCount"
207+
208+instance ToJSON StarredRepositoryConnection where
209+ toJSON (StarredRepositoryConnection totalCountStarredRepositoryConnection) =
150210 object
151- [ "totalCount" .= totalCountConnection
211+ [ "totalCount" .= totalCountStarredRepositoryConnection
152212 ]
153213
154-instance FromJSON Connection where
155- parseJSON (Object v) = Connection
214+instance FromJSON StarredRepositoryConnection where
215+ parseJSON (Object v) = StarredRepositoryConnection
156216 <$> v .: "totalCount"
Dgraphql-java-datetime-legacydefault / src / main / java / io / quicktype / Connection.java+0 −12
@@ -1,12 +0,0 @@
1-package io.quicktype;
2-
3-import com.fasterxml.jackson.annotation.*;
4-
5-public class Connection {
6- private long totalCount;
7-
8- @JsonProperty("totalCount")
9- public long getTotalCount() { return totalCount; }
10- @JsonProperty("totalCount")
11- public void setTotalCount(long value) { this.totalCount = value; }
12-}
Agraphql-java-datetime-legacydefault / src / main / java / io / quicktype / IssueConnection.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class IssueConnection {
6+ private long totalCount;
7+
8+ @JsonProperty("totalCount")
9+ public long getTotalCount() { return totalCount; }
10+ @JsonProperty("totalCount")
11+ public void setTotalCount(long value) { this.totalCount = value; }
12+}
Mgraphql-java-datetime-legacydefault / src / main / java / io / quicktype / Repository.java+12 −12
@@ -4,10 +4,10 @@ import com.fasterxml.jackson.annotation.*;
44
55 public class Repository {
66 private String name;
7- private Connection stargazers;
8- private Connection forks;
9- private Connection watchers;
10- private Connection issues;
7+ private StargazerConnection stargazers;
8+ private RepositoryRepositoryConnection forks;
9+ private UserConnection watchers;
10+ private IssueConnection issues;
1111
1212 @JsonProperty("name")
1313 public String getName() { return name; }
@@ -15,22 +15,22 @@ public class Repository {
1515 public void setName(String value) { this.name = value; }
1616
1717 @JsonProperty("stargazers")
18- public Connection getStargazers() { return stargazers; }
18+ public StargazerConnection getStargazers() { return stargazers; }
1919 @JsonProperty("stargazers")
20- public void setStargazers(Connection value) { this.stargazers = value; }
20+ public void setStargazers(StargazerConnection value) { this.stargazers = value; }
2121
2222 @JsonProperty("forks")
23- public Connection getForks() { return forks; }
23+ public RepositoryRepositoryConnection getForks() { return forks; }
2424 @JsonProperty("forks")
25- public void setForks(Connection value) { this.forks = value; }
25+ public void setForks(RepositoryRepositoryConnection value) { this.forks = value; }
2626
2727 @JsonProperty("watchers")
28- public Connection getWatchers() { return watchers; }
28+ public UserConnection getWatchers() { return watchers; }
2929 @JsonProperty("watchers")
30- public void setWatchers(Connection value) { this.watchers = value; }
30+ public void setWatchers(UserConnection value) { this.watchers = value; }
3131
3232 @JsonProperty("issues")
33- public Connection getIssues() { return issues; }
33+ public IssueConnection getIssues() { return issues; }
3434 @JsonProperty("issues")
35- public void setIssues(Connection value) { this.issues = value; }
35+ public void setIssues(IssueConnection value) { this.issues = value; }
3636 }
Dgraphql-java-datetime-legacydefault / src / main / java / io / quicktype / RepositoryConnection.java+0 −13
@@ -1,13 +0,0 @@
1-package io.quicktype;
2-
3-import com.fasterxml.jackson.annotation.*;
4-import java.util.List;
5-
6-public class RepositoryConnection {
7- private List<RepositoryEdge> edges;
8-
9- @JsonProperty("edges")
10- public List<RepositoryEdge> getEdges() { return edges; }
11- @JsonProperty("edges")
12- public void setEdges(List<RepositoryEdge> value) { this.edges = value; }
13-}
Agraphql-java-datetime-legacydefault / src / main / java / io / quicktype / RepositoryRepositoryConnection.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class RepositoryRepositoryConnection {
6+ private long totalCount;
7+
8+ @JsonProperty("totalCount")
9+ public long getTotalCount() { return totalCount; }
10+ @JsonProperty("totalCount")
11+ public void setTotalCount(long value) { this.totalCount = value; }
12+}
Agraphql-java-datetime-legacydefault / src / main / java / io / quicktype / StargazerConnection.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class StargazerConnection {
6+ private long totalCount;
7+
8+ @JsonProperty("totalCount")
9+ public long getTotalCount() { return totalCount; }
10+ @JsonProperty("totalCount")
11+ public void setTotalCount(long value) { this.totalCount = value; }
12+}
Agraphql-java-datetime-legacydefault / src / main / java / io / quicktype / StarredRepositoryConnection.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class StarredRepositoryConnection {
6+ private long totalCount;
7+
8+ @JsonProperty("totalCount")
9+ public long getTotalCount() { return totalCount; }
10+ @JsonProperty("totalCount")
11+ public void setTotalCount(long value) { this.totalCount = value; }
12+}
Mgraphql-java-datetime-legacydefault / src / main / java / io / quicktype / User.java+6 −6
@@ -4,8 +4,8 @@ import com.fasterxml.jackson.annotation.*;
44
55 public class User {
66 private String login;
7- private Connection starredRepositories;
8- private RepositoryConnection repositories;
7+ private StarredRepositoryConnection starredRepositories;
8+ private UserRepositoryConnection repositories;
99
1010 @JsonProperty("login")
1111 public String getLogin() { return login; }
@@ -13,12 +13,12 @@ public class User {
1313 public void setLogin(String value) { this.login = value; }
1414
1515 @JsonProperty("starredRepositories")
16- public Connection getStarredRepositories() { return starredRepositories; }
16+ public StarredRepositoryConnection getStarredRepositories() { return starredRepositories; }
1717 @JsonProperty("starredRepositories")
18- public void setStarredRepositories(Connection value) { this.starredRepositories = value; }
18+ public void setStarredRepositories(StarredRepositoryConnection value) { this.starredRepositories = value; }
1919
2020 @JsonProperty("repositories")
21- public RepositoryConnection getRepositories() { return repositories; }
21+ public UserRepositoryConnection getRepositories() { return repositories; }
2222 @JsonProperty("repositories")
23- public void setRepositories(RepositoryConnection value) { this.repositories = value; }
23+ public void setRepositories(UserRepositoryConnection value) { this.repositories = value; }
2424 }
Agraphql-java-datetime-legacydefault / src / main / java / io / quicktype / UserConnection.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class UserConnection {
6+ private long totalCount;
7+
8+ @JsonProperty("totalCount")
9+ public long getTotalCount() { return totalCount; }
10+ @JsonProperty("totalCount")
11+ public void setTotalCount(long value) { this.totalCount = value; }
12+}
Agraphql-java-datetime-legacydefault / src / main / java / io / quicktype / UserRepositoryConnection.java+13 −0
@@ -0,0 +1,13 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+import java.util.List;
5+
6+public class UserRepositoryConnection {
7+ private List<RepositoryEdge> edges;
8+
9+ @JsonProperty("edges")
10+ public List<RepositoryEdge> getEdges() { return edges; }
11+ @JsonProperty("edges")
12+ public void setEdges(List<RepositoryEdge> value) { this.edges = value; }
13+}
Dgraphql-java-lombokdefault / src / main / java / io / quicktype / Connection.java+0 −12
@@ -1,12 +0,0 @@
1-package io.quicktype;
2-
3-import com.fasterxml.jackson.annotation.*;
4-
5-public class Connection {
6- private long totalCount;
7-
8- @JsonProperty("totalCount")
9- public long getTotalCount() { return totalCount; }
10- @JsonProperty("totalCount")
11- public void setTotalCount(long value) { this.totalCount = value; }
12-}
Agraphql-java-lombokdefault / src / main / java / io / quicktype / IssueConnection.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class IssueConnection {
6+ private long totalCount;
7+
8+ @JsonProperty("totalCount")
9+ public long getTotalCount() { return totalCount; }
10+ @JsonProperty("totalCount")
11+ public void setTotalCount(long value) { this.totalCount = value; }
12+}
Mgraphql-java-lombokdefault / src / main / java / io / quicktype / Repository.java+12 −12
@@ -4,10 +4,10 @@ import com.fasterxml.jackson.annotation.*;
44
55 public class Repository {
66 private String name;
7- private Connection stargazers;
8- private Connection forks;
9- private Connection watchers;
10- private Connection issues;
7+ private StargazerConnection stargazers;
8+ private RepositoryRepositoryConnection forks;
9+ private UserConnection watchers;
10+ private IssueConnection issues;
1111
1212 @JsonProperty("name")
1313 public String getName() { return name; }
@@ -15,22 +15,22 @@ public class Repository {
1515 public void setName(String value) { this.name = value; }
1616
1717 @JsonProperty("stargazers")
18- public Connection getStargazers() { return stargazers; }
18+ public StargazerConnection getStargazers() { return stargazers; }
1919 @JsonProperty("stargazers")
20- public void setStargazers(Connection value) { this.stargazers = value; }
20+ public void setStargazers(StargazerConnection value) { this.stargazers = value; }
2121
2222 @JsonProperty("forks")
23- public Connection getForks() { return forks; }
23+ public RepositoryRepositoryConnection getForks() { return forks; }
2424 @JsonProperty("forks")
25- public void setForks(Connection value) { this.forks = value; }
25+ public void setForks(RepositoryRepositoryConnection value) { this.forks = value; }
2626
2727 @JsonProperty("watchers")
28- public Connection getWatchers() { return watchers; }
28+ public UserConnection getWatchers() { return watchers; }
2929 @JsonProperty("watchers")
30- public void setWatchers(Connection value) { this.watchers = value; }
30+ public void setWatchers(UserConnection value) { this.watchers = value; }
3131
3232 @JsonProperty("issues")
33- public Connection getIssues() { return issues; }
33+ public IssueConnection getIssues() { return issues; }
3434 @JsonProperty("issues")
35- public void setIssues(Connection value) { this.issues = value; }
35+ public void setIssues(IssueConnection value) { this.issues = value; }
3636 }
Dgraphql-java-lombokdefault / src / main / java / io / quicktype / RepositoryConnection.java+0 −13
@@ -1,13 +0,0 @@
1-package io.quicktype;
2-
3-import com.fasterxml.jackson.annotation.*;
4-import java.util.List;
5-
6-public class RepositoryConnection {
7- private List<RepositoryEdge> edges;
8-
9- @JsonProperty("edges")
10- public List<RepositoryEdge> getEdges() { return edges; }
11- @JsonProperty("edges")
12- public void setEdges(List<RepositoryEdge> value) { this.edges = value; }
13-}
Agraphql-java-lombokdefault / src / main / java / io / quicktype / RepositoryRepositoryConnection.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class RepositoryRepositoryConnection {
6+ private long totalCount;
7+
8+ @JsonProperty("totalCount")
9+ public long getTotalCount() { return totalCount; }
10+ @JsonProperty("totalCount")
11+ public void setTotalCount(long value) { this.totalCount = value; }
12+}
Agraphql-java-lombokdefault / src / main / java / io / quicktype / StargazerConnection.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class StargazerConnection {
6+ private long totalCount;
7+
8+ @JsonProperty("totalCount")
9+ public long getTotalCount() { return totalCount; }
10+ @JsonProperty("totalCount")
11+ public void setTotalCount(long value) { this.totalCount = value; }
12+}
Agraphql-java-lombokdefault / src / main / java / io / quicktype / StarredRepositoryConnection.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class StarredRepositoryConnection {
6+ private long totalCount;
7+
8+ @JsonProperty("totalCount")
9+ public long getTotalCount() { return totalCount; }
10+ @JsonProperty("totalCount")
11+ public void setTotalCount(long value) { this.totalCount = value; }
12+}
Mgraphql-java-lombokdefault / src / main / java / io / quicktype / User.java+6 −6
@@ -4,8 +4,8 @@ import com.fasterxml.jackson.annotation.*;
44
55 public class User {
66 private String login;
7- private Connection starredRepositories;
8- private RepositoryConnection repositories;
7+ private StarredRepositoryConnection starredRepositories;
8+ private UserRepositoryConnection repositories;
99
1010 @JsonProperty("login")
1111 public String getLogin() { return login; }
@@ -13,12 +13,12 @@ public class User {
1313 public void setLogin(String value) { this.login = value; }
1414
1515 @JsonProperty("starredRepositories")
16- public Connection getStarredRepositories() { return starredRepositories; }
16+ public StarredRepositoryConnection getStarredRepositories() { return starredRepositories; }
1717 @JsonProperty("starredRepositories")
18- public void setStarredRepositories(Connection value) { this.starredRepositories = value; }
18+ public void setStarredRepositories(StarredRepositoryConnection value) { this.starredRepositories = value; }
1919
2020 @JsonProperty("repositories")
21- public RepositoryConnection getRepositories() { return repositories; }
21+ public UserRepositoryConnection getRepositories() { return repositories; }
2222 @JsonProperty("repositories")
23- public void setRepositories(RepositoryConnection value) { this.repositories = value; }
23+ public void setRepositories(UserRepositoryConnection value) { this.repositories = value; }
2424 }
Agraphql-java-lombokdefault / src / main / java / io / quicktype / UserConnection.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class UserConnection {
6+ private long totalCount;
7+
8+ @JsonProperty("totalCount")
9+ public long getTotalCount() { return totalCount; }
10+ @JsonProperty("totalCount")
11+ public void setTotalCount(long value) { this.totalCount = value; }
12+}
Agraphql-java-lombokdefault / src / main / java / io / quicktype / UserRepositoryConnection.java+13 −0
@@ -0,0 +1,13 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+import java.util.List;
5+
6+public class UserRepositoryConnection {
7+ private List<RepositoryEdge> edges;
8+
9+ @JsonProperty("edges")
10+ public List<RepositoryEdge> getEdges() { return edges; }
11+ @JsonProperty("edges")
12+ public void setEdges(List<RepositoryEdge> value) { this.edges = value; }
13+}
Dgraphql-javadefault / src / main / java / io / quicktype / Connection.java+0 −12
@@ -1,12 +0,0 @@
1-package io.quicktype;
2-
3-import com.fasterxml.jackson.annotation.*;
4-
5-public class Connection {
6- private long totalCount;
7-
8- @JsonProperty("totalCount")
9- public long getTotalCount() { return totalCount; }
10- @JsonProperty("totalCount")
11- public void setTotalCount(long value) { this.totalCount = value; }
12-}
Agraphql-javadefault / src / main / java / io / quicktype / IssueConnection.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class IssueConnection {
6+ private long totalCount;
7+
8+ @JsonProperty("totalCount")
9+ public long getTotalCount() { return totalCount; }
10+ @JsonProperty("totalCount")
11+ public void setTotalCount(long value) { this.totalCount = value; }
12+}
Mgraphql-javadefault / src / main / java / io / quicktype / Repository.java+12 −12
@@ -4,10 +4,10 @@ import com.fasterxml.jackson.annotation.*;
44
55 public class Repository {
66 private String name;
7- private Connection stargazers;
8- private Connection forks;
9- private Connection watchers;
10- private Connection issues;
7+ private StargazerConnection stargazers;
8+ private RepositoryRepositoryConnection forks;
9+ private UserConnection watchers;
10+ private IssueConnection issues;
1111
1212 @JsonProperty("name")
1313 public String getName() { return name; }
@@ -15,22 +15,22 @@ public class Repository {
1515 public void setName(String value) { this.name = value; }
1616
1717 @JsonProperty("stargazers")
18- public Connection getStargazers() { return stargazers; }
18+ public StargazerConnection getStargazers() { return stargazers; }
1919 @JsonProperty("stargazers")
20- public void setStargazers(Connection value) { this.stargazers = value; }
20+ public void setStargazers(StargazerConnection value) { this.stargazers = value; }
2121
2222 @JsonProperty("forks")
23- public Connection getForks() { return forks; }
23+ public RepositoryRepositoryConnection getForks() { return forks; }
2424 @JsonProperty("forks")
25- public void setForks(Connection value) { this.forks = value; }
25+ public void setForks(RepositoryRepositoryConnection value) { this.forks = value; }
2626
2727 @JsonProperty("watchers")
28- public Connection getWatchers() { return watchers; }
28+ public UserConnection getWatchers() { return watchers; }
2929 @JsonProperty("watchers")
30- public void setWatchers(Connection value) { this.watchers = value; }
30+ public void setWatchers(UserConnection value) { this.watchers = value; }
3131
3232 @JsonProperty("issues")
33- public Connection getIssues() { return issues; }
33+ public IssueConnection getIssues() { return issues; }
3434 @JsonProperty("issues")
35- public void setIssues(Connection value) { this.issues = value; }
35+ public void setIssues(IssueConnection value) { this.issues = value; }
3636 }
Dgraphql-javadefault / src / main / java / io / quicktype / RepositoryConnection.java+0 −13
@@ -1,13 +0,0 @@
1-package io.quicktype;
2-
3-import com.fasterxml.jackson.annotation.*;
4-import java.util.List;
5-
6-public class RepositoryConnection {
7- private List<RepositoryEdge> edges;
8-
9- @JsonProperty("edges")
10- public List<RepositoryEdge> getEdges() { return edges; }
11- @JsonProperty("edges")
12- public void setEdges(List<RepositoryEdge> value) { this.edges = value; }
13-}
Agraphql-javadefault / src / main / java / io / quicktype / RepositoryRepositoryConnection.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class RepositoryRepositoryConnection {
6+ private long totalCount;
7+
8+ @JsonProperty("totalCount")
9+ public long getTotalCount() { return totalCount; }
10+ @JsonProperty("totalCount")
11+ public void setTotalCount(long value) { this.totalCount = value; }
12+}
Agraphql-javadefault / src / main / java / io / quicktype / StargazerConnection.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class StargazerConnection {
6+ private long totalCount;
7+
8+ @JsonProperty("totalCount")
9+ public long getTotalCount() { return totalCount; }
10+ @JsonProperty("totalCount")
11+ public void setTotalCount(long value) { this.totalCount = value; }
12+}
Agraphql-javadefault / src / main / java / io / quicktype / StarredRepositoryConnection.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class StarredRepositoryConnection {
6+ private long totalCount;
7+
8+ @JsonProperty("totalCount")
9+ public long getTotalCount() { return totalCount; }
10+ @JsonProperty("totalCount")
11+ public void setTotalCount(long value) { this.totalCount = value; }
12+}
Mgraphql-javadefault / src / main / java / io / quicktype / User.java+6 −6
@@ -4,8 +4,8 @@ import com.fasterxml.jackson.annotation.*;
44
55 public class User {
66 private String login;
7- private Connection starredRepositories;
8- private RepositoryConnection repositories;
7+ private StarredRepositoryConnection starredRepositories;
8+ private UserRepositoryConnection repositories;
99
1010 @JsonProperty("login")
1111 public String getLogin() { return login; }
@@ -13,12 +13,12 @@ public class User {
1313 public void setLogin(String value) { this.login = value; }
1414
1515 @JsonProperty("starredRepositories")
16- public Connection getStarredRepositories() { return starredRepositories; }
16+ public StarredRepositoryConnection getStarredRepositories() { return starredRepositories; }
1717 @JsonProperty("starredRepositories")
18- public void setStarredRepositories(Connection value) { this.starredRepositories = value; }
18+ public void setStarredRepositories(StarredRepositoryConnection value) { this.starredRepositories = value; }
1919
2020 @JsonProperty("repositories")
21- public RepositoryConnection getRepositories() { return repositories; }
21+ public UserRepositoryConnection getRepositories() { return repositories; }
2222 @JsonProperty("repositories")
23- public void setRepositories(RepositoryConnection value) { this.repositories = value; }
23+ public void setRepositories(UserRepositoryConnection value) { this.repositories = value; }
2424 }
Agraphql-javadefault / src / main / java / io / quicktype / UserConnection.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class UserConnection {
6+ private long totalCount;
7+
8+ @JsonProperty("totalCount")
9+ public long getTotalCount() { return totalCount; }
10+ @JsonProperty("totalCount")
11+ public void setTotalCount(long value) { this.totalCount = value; }
12+}
Agraphql-javadefault / src / main / java / io / quicktype / UserRepositoryConnection.java+13 −0
@@ -0,0 +1,13 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+import java.util.List;
5+
6+public class UserRepositoryConnection {
7+ private List<RepositoryEdge> edges;
8+
9+ @JsonProperty("edges")
10+ public List<RepositoryEdge> getEdges() { return edges; }
11+ @JsonProperty("edges")
12+ public void setEdges(List<RepositoryEdge> value) { this.edges = value; }
13+}
Mgraphql-javascriptdefault / TopLevel.js+20 −8
@@ -180,10 +180,10 @@ const typeMap = {
180180 ], false),
181181 "User": o([
182182 { json: "login", js: "login", typ: "" },
183- { json: "starredRepositories", js: "starredRepositories", typ: r("Connection") },
184- { json: "repositories", js: "repositories", typ: r("RepositoryConnection") },
183+ { json: "starredRepositories", js: "starredRepositories", typ: r("StarredRepositoryConnection") },
184+ { json: "repositories", js: "repositories", typ: r("UserRepositoryConnection") },
185185 ], false),
186- "RepositoryConnection": o([
186+ "UserRepositoryConnection": o([
187187 { json: "edges", js: "edges", typ: u(a(u(r("RepositoryEdge"), null)), null) },
188188 ], false),
189189 "RepositoryEdge": o([
@@ -191,12 +191,24 @@ const typeMap = {
191191 ], false),
192192 "Repository": o([
193193 { json: "name", js: "name", typ: "" },
194- { json: "stargazers", js: "stargazers", typ: r("Connection") },
195- { json: "forks", js: "forks", typ: r("Connection") },
196- { json: "watchers", js: "watchers", typ: r("Connection") },
197- { json: "issues", js: "issues", typ: r("Connection") },
194+ { json: "stargazers", js: "stargazers", typ: r("StargazerConnection") },
195+ { json: "forks", js: "forks", typ: r("RepositoryRepositoryConnection") },
196+ { json: "watchers", js: "watchers", typ: r("UserConnection") },
197+ { json: "issues", js: "issues", typ: r("IssueConnection") },
198198 ], false),
199- "Connection": o([
199+ "RepositoryRepositoryConnection": o([
200+ { json: "totalCount", js: "totalCount", typ: 0 },
201+ ], false),
202+ "IssueConnection": o([
203+ { json: "totalCount", js: "totalCount", typ: 0 },
204+ ], false),
205+ "StargazerConnection": o([
206+ { json: "totalCount", js: "totalCount", typ: 0 },
207+ ], false),
208+ "UserConnection": o([
209+ { json: "totalCount", js: "totalCount", typ: 0 },
210+ ], false),
211+ "StarredRepositoryConnection": o([
200212 { json: "totalCount", js: "totalCount", typ: 0 },
201213 ], false),
202214 "Error": o([
Mgraphql-objective-cdefault / QTTopLevel.h+30 −10
@@ -8,10 +8,14 @@
88 @class QTTopLevel;
99 @class QTData;
1010 @class QTUser;
11-@class QTRepositoryConnection;
11+@class QTUserRepositoryConnection;
1212 @class QTRepositoryEdge;
1313 @class QTRepository;
14-@class QTConnection;
14+@class QTRepositoryRepositoryConnection;
15+@class QTIssueConnection;
16+@class QTStargazerConnection;
17+@class QTUserConnection;
18+@class QTStarredRepositoryConnection;
1519 @class QTError;
1620
1721 NS_ASSUME_NONNULL_BEGIN
@@ -41,11 +45,11 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding en
4145
4246 @interface QTUser : NSObject
4347 @property (nonatomic, copy) NSString *login;
44-@property (nonatomic, strong) QTConnection *starredRepositories;
45-@property (nonatomic, strong) QTRepositoryConnection *repositories;
48+@property (nonatomic, strong) QTStarredRepositoryConnection *starredRepositories;
49+@property (nonatomic, strong) QTUserRepositoryConnection *repositories;
4650 @end
4751
48-@interface QTRepositoryConnection : NSObject
52+@interface QTUserRepositoryConnection : NSObject
4953 @property (nonatomic, nullable, copy) NSArray<QTRepositoryEdge *> *edges;
5054 @end
5155
@@ -55,13 +59,29 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding en
5559
5660 @interface QTRepository : NSObject
5761 @property (nonatomic, copy) NSString *name;
58-@property (nonatomic, strong) QTConnection *stargazers;
59-@property (nonatomic, strong) QTConnection *forks;
60-@property (nonatomic, strong) QTConnection *watchers;
61-@property (nonatomic, strong) QTConnection *issues;
62+@property (nonatomic, strong) QTStargazerConnection *stargazers;
63+@property (nonatomic, strong) QTRepositoryRepositoryConnection *forks;
64+@property (nonatomic, strong) QTUserConnection *watchers;
65+@property (nonatomic, strong) QTIssueConnection *issues;
6266 @end
6367
64-@interface QTConnection : NSObject
68+@interface QTRepositoryRepositoryConnection : NSObject
69+@property (nonatomic, assign) NSInteger totalCount;
70+@end
71+
72+@interface QTIssueConnection : NSObject
73+@property (nonatomic, assign) NSInteger totalCount;
74+@end
75+
76+@interface QTStargazerConnection : NSObject
77+@property (nonatomic, assign) NSInteger totalCount;
78+@end
79+
80+@interface QTUserConnection : NSObject
81+@property (nonatomic, assign) NSInteger totalCount;
82+@end
83+
84+@interface QTStarredRepositoryConnection : NSObject
6585 @property (nonatomic, assign) NSInteger totalCount;
6686 @end
Mgraphql-objective-cdefault / QTTopLevel.m+198 −18
@@ -23,7 +23,7 @@ NS_ASSUME_NONNULL_BEGIN
2323 - (NSDictionary *)JSONDictionary;
2424 @end
2525
26-@interface QTRepositoryConnection (JSONConversion)
26+@interface QTUserRepositoryConnection (JSONConversion)
2727 + (instancetype)fromJSONDictionary:(NSDictionary *)dict;
2828 - (NSDictionary *)JSONDictionary;
2929 @end
@@ -38,7 +38,27 @@ NS_ASSUME_NONNULL_BEGIN
3838 - (NSDictionary *)JSONDictionary;
3939 @end
4040
41-@interface QTConnection (JSONConversion)
41+@interface QTRepositoryRepositoryConnection (JSONConversion)
42++ (instancetype)fromJSONDictionary:(NSDictionary *)dict;
43+- (NSDictionary *)JSONDictionary;
44+@end
45+
46+@interface QTIssueConnection (JSONConversion)
47++ (instancetype)fromJSONDictionary:(NSDictionary *)dict;
48+- (NSDictionary *)JSONDictionary;
49+@end
50+
51+@interface QTStargazerConnection (JSONConversion)
52++ (instancetype)fromJSONDictionary:(NSDictionary *)dict;
53+- (NSDictionary *)JSONDictionary;
54+@end
55+
56+@interface QTUserConnection (JSONConversion)
57++ (instancetype)fromJSONDictionary:(NSDictionary *)dict;
58+- (NSDictionary *)JSONDictionary;
59+@end
60+
61+@interface QTStarredRepositoryConnection (JSONConversion)
4262 + (instancetype)fromJSONDictionary:(NSDictionary *)dict;
4363 - (NSDictionary *)JSONDictionary;
4464 @end
@@ -233,8 +253,8 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco
233253 {
234254 if (self = [super init]) {
235255 [self setValuesForKeysWithDictionary:dict];
236- _starredRepositories = [QTConnection fromJSONDictionary:(id)_starredRepositories];
237- _repositories = [QTRepositoryConnection fromJSONDictionary:(id)_repositories];
256+ _starredRepositories = [QTStarredRepositoryConnection fromJSONDictionary:(id)_starredRepositories];
257+ _repositories = [QTUserRepositoryConnection fromJSONDictionary:(id)_repositories];
238258 }
239259 return self;
240260 }
@@ -264,7 +284,7 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco
264284 }
265285 @end
266286
267-@implementation QTRepositoryConnection
287+@implementation QTUserRepositoryConnection
268288 + (NSDictionary<NSString *, NSString *> *)properties
269289 {
270290 static NSDictionary<NSString *, NSString *> *properties;
@@ -275,7 +295,7 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco
275295
276296 + (instancetype)fromJSONDictionary:(NSDictionary *)dict
277297 {
278- return dict ? [[QTRepositoryConnection alloc] initWithJSONDictionary:dict] : nil;
298+ return dict ? [[QTUserRepositoryConnection alloc] initWithJSONDictionary:dict] : nil;
279299 }
280300
281301 - (instancetype)initWithJSONDictionary:(NSDictionary *)dict
@@ -289,19 +309,19 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco
289309
290310 - (void)setValue:(nullable id)value forKey:(NSString *)key
291311 {
292- id resolved = QTRepositoryConnection.properties[key];
312+ id resolved = QTUserRepositoryConnection.properties[key];
293313 if (resolved) [super setValue:value forKey:resolved];
294314 }
295315
296316 - (void)setNilValueForKey:(NSString *)key
297317 {
298- id resolved = QTRepositoryConnection.properties[key];
318+ id resolved = QTUserRepositoryConnection.properties[key];
299319 if (resolved) [super setValue:@(0) forKey:resolved];
300320 }
301321
302322 - (NSDictionary *)JSONDictionary
303323 {
304- id dict = [[self dictionaryWithValuesForKeys:QTRepositoryConnection.properties.allValues] mutableCopy];
324+ id dict = [[self dictionaryWithValuesForKeys:QTUserRepositoryConnection.properties.allValues] mutableCopy];
305325
306326 [dict addEntriesFromDictionary:@{
307327 @"edges": NSNullify(map(_edges, λ(id x, NSNullify([x JSONDictionary])))),
@@ -380,10 +400,10 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco
380400 {
381401 if (self = [super init]) {
382402 [self setValuesForKeysWithDictionary:dict];
383- _stargazers = [QTConnection fromJSONDictionary:(id)_stargazers];
384- _forks = [QTConnection fromJSONDictionary:(id)_forks];
385- _watchers = [QTConnection fromJSONDictionary:(id)_watchers];
386- _issues = [QTConnection fromJSONDictionary:(id)_issues];
403+ _stargazers = [QTStargazerConnection fromJSONDictionary:(id)_stargazers];
404+ _forks = [QTRepositoryRepositoryConnection fromJSONDictionary:(id)_forks];
405+ _watchers = [QTUserConnection fromJSONDictionary:(id)_watchers];
406+ _issues = [QTIssueConnection fromJSONDictionary:(id)_issues];
387407 }
388408 return self;
389409 }
@@ -415,7 +435,167 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco
415435 }
416436 @end
417437
418-@implementation QTConnection
438+@implementation QTRepositoryRepositoryConnection
439++ (NSDictionary<NSString *, NSString *> *)properties
440+{
441+ static NSDictionary<NSString *, NSString *> *properties;
442+ return properties = properties ? properties : @{
443+ @"totalCount": @"totalCount",
444+ };
445+}
446+
447++ (instancetype)fromJSONDictionary:(NSDictionary *)dict
448+{
449+ return dict ? [[QTRepositoryRepositoryConnection alloc] initWithJSONDictionary:dict] : nil;
450+}
451+
452+- (instancetype)initWithJSONDictionary:(NSDictionary *)dict
453+{
454+ if (self = [super init]) {
455+ [self setValuesForKeysWithDictionary:dict];
456+ }
457+ return self;
458+}
459+
460+- (void)setValue:(nullable id)value forKey:(NSString *)key
461+{
462+ id resolved = QTRepositoryRepositoryConnection.properties[key];
463+ if (resolved) [super setValue:value forKey:resolved];
464+}
465+
466+- (void)setNilValueForKey:(NSString *)key
467+{
468+ id resolved = QTRepositoryRepositoryConnection.properties[key];
469+ if (resolved) [super setValue:@(0) forKey:resolved];
470+}
471+
472+- (NSDictionary *)JSONDictionary
473+{
474+ return [self dictionaryWithValuesForKeys:QTRepositoryRepositoryConnection.properties.allValues];
475+}
476+@end
477+
478+@implementation QTIssueConnection
479++ (NSDictionary<NSString *, NSString *> *)properties
480+{
481+ static NSDictionary<NSString *, NSString *> *properties;
482+ return properties = properties ? properties : @{
483+ @"totalCount": @"totalCount",
484+ };
485+}
486+
487++ (instancetype)fromJSONDictionary:(NSDictionary *)dict
488+{
489+ return dict ? [[QTIssueConnection alloc] initWithJSONDictionary:dict] : nil;
490+}
491+
492+- (instancetype)initWithJSONDictionary:(NSDictionary *)dict
493+{
494+ if (self = [super init]) {
495+ [self setValuesForKeysWithDictionary:dict];
496+ }
497+ return self;
498+}
499+
500+- (void)setValue:(nullable id)value forKey:(NSString *)key
501+{
502+ id resolved = QTIssueConnection.properties[key];
503+ if (resolved) [super setValue:value forKey:resolved];
504+}
505+
506+- (void)setNilValueForKey:(NSString *)key
507+{
508+ id resolved = QTIssueConnection.properties[key];
509+ if (resolved) [super setValue:@(0) forKey:resolved];
510+}
511+
512+- (NSDictionary *)JSONDictionary
513+{
514+ return [self dictionaryWithValuesForKeys:QTIssueConnection.properties.allValues];
515+}
516+@end
517+
518+@implementation QTStargazerConnection
519++ (NSDictionary<NSString *, NSString *> *)properties
520+{
521+ static NSDictionary<NSString *, NSString *> *properties;
522+ return properties = properties ? properties : @{
523+ @"totalCount": @"totalCount",
524+ };
525+}
526+
527++ (instancetype)fromJSONDictionary:(NSDictionary *)dict
528+{
529+ return dict ? [[QTStargazerConnection alloc] initWithJSONDictionary:dict] : nil;
530+}
531+
532+- (instancetype)initWithJSONDictionary:(NSDictionary *)dict
533+{
534+ if (self = [super init]) {
535+ [self setValuesForKeysWithDictionary:dict];
536+ }
537+ return self;
538+}
539+
540+- (void)setValue:(nullable id)value forKey:(NSString *)key
541+{
542+ id resolved = QTStargazerConnection.properties[key];
543+ if (resolved) [super setValue:value forKey:resolved];
544+}
545+
546+- (void)setNilValueForKey:(NSString *)key
547+{
548+ id resolved = QTStargazerConnection.properties[key];
549+ if (resolved) [super setValue:@(0) forKey:resolved];
550+}
551+
552+- (NSDictionary *)JSONDictionary
553+{
554+ return [self dictionaryWithValuesForKeys:QTStargazerConnection.properties.allValues];
555+}
556+@end
557+
558+@implementation QTUserConnection
559++ (NSDictionary<NSString *, NSString *> *)properties
560+{
561+ static NSDictionary<NSString *, NSString *> *properties;
562+ return properties = properties ? properties : @{
563+ @"totalCount": @"totalCount",
564+ };
565+}
566+
567++ (instancetype)fromJSONDictionary:(NSDictionary *)dict
568+{
569+ return dict ? [[QTUserConnection alloc] initWithJSONDictionary:dict] : nil;
570+}
571+
572+- (instancetype)initWithJSONDictionary:(NSDictionary *)dict
573+{
574+ if (self = [super init]) {
575+ [self setValuesForKeysWithDictionary:dict];
576+ }
577+ return self;
578+}
579+
580+- (void)setValue:(nullable id)value forKey:(NSString *)key
581+{
582+ id resolved = QTUserConnection.properties[key];
583+ if (resolved) [super setValue:value forKey:resolved];
584+}
585+
586+- (void)setNilValueForKey:(NSString *)key
587+{
588+ id resolved = QTUserConnection.properties[key];
589+ if (resolved) [super setValue:@(0) forKey:resolved];
590+}
591+
592+- (NSDictionary *)JSONDictionary
593+{
594+ return [self dictionaryWithValuesForKeys:QTUserConnection.properties.allValues];
595+}
596+@end
597+
598+@implementation QTStarredRepositoryConnection
419599 + (NSDictionary<NSString *, NSString *> *)properties
420600 {
421601 static NSDictionary<NSString *, NSString *> *properties;
@@ -426,7 +606,7 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco
426606
427607 + (instancetype)fromJSONDictionary:(NSDictionary *)dict
428608 {
429- return dict ? [[QTConnection alloc] initWithJSONDictionary:dict] : nil;
609+ return dict ? [[QTStarredRepositoryConnection alloc] initWithJSONDictionary:dict] : nil;
430610 }
431611
432612 - (instancetype)initWithJSONDictionary:(NSDictionary *)dict
@@ -439,19 +619,19 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco
439619
440620 - (void)setValue:(nullable id)value forKey:(NSString *)key
441621 {
442- id resolved = QTConnection.properties[key];
622+ id resolved = QTStarredRepositoryConnection.properties[key];
443623 if (resolved) [super setValue:value forKey:resolved];
444624 }
445625
446626 - (void)setNilValueForKey:(NSString *)key
447627 {
448- id resolved = QTConnection.properties[key];
628+ id resolved = QTStarredRepositoryConnection.properties[key];
449629 if (resolved) [super setValue:@(0) forKey:resolved];
450630 }
451631
452632 - (NSDictionary *)JSONDictionary
453633 {
454- return [self dictionaryWithValuesForKeys:QTConnection.properties.allValues];
634+ return [self dictionaryWithValuesForKeys:QTStarredRepositoryConnection.properties.allValues];
455635 }
456636 @end
Mgraphql-phpdefault / TopLevel.php+497 −105
@@ -289,15 +289,15 @@ class Data {
289289
290290 class User {
291291 private string $login; // json:login Required
292- private Connection $starredRepositories; // json:starredRepositories Required
293- private RepositoryConnection $repositories; // json:repositories Required
292+ private StarredRepositoryConnection $starredRepositories; // json:starredRepositories Required
293+ private UserRepositoryConnection $repositories; // json:repositories Required
294294
295295 /**
296296 * @param string $login
297- * @param Connection $starredRepositories
298- * @param RepositoryConnection $repositories
297+ * @param StarredRepositoryConnection $starredRepositories
298+ * @param UserRepositoryConnection $repositories
299299 */
300- public function __construct(string $login, Connection $starredRepositories, RepositoryConnection $repositories) {
300+ public function __construct(string $login, StarredRepositoryConnection $starredRepositories, UserRepositoryConnection $repositories) {
301301 $this->login = $login;
302302 $this->starredRepositories = $starredRepositories;
303303 $this->repositories = $repositories;
@@ -353,10 +353,10 @@ class User {
353353 /**
354354 * @param stdClass $value
355355 * @throws Exception
356- * @return Connection
356+ * @return StarredRepositoryConnection
357357 */
358- public static function fromStarredRepositories(stdClass $value): Connection {
359- return Connection::from($value); /*class*/
358+ public static function fromStarredRepositories(stdClass $value): StarredRepositoryConnection {
359+ return StarredRepositoryConnection::from($value); /*class*/
360360 }
361361
362362 /**
@@ -371,20 +371,20 @@ class User {
371371 }
372372
373373 /**
374- * @param Connection
374+ * @param StarredRepositoryConnection
375375 * @return bool
376376 * @throws Exception
377377 */
378- public static function validateStarredRepositories(Connection $value): bool {
378+ public static function validateStarredRepositories(StarredRepositoryConnection $value): bool {
379379 $value->validate();
380380 return true;
381381 }
382382
383383 /**
384384 * @throws Exception
385- * @return Connection
385+ * @return StarredRepositoryConnection
386386 */
387- public function getStarredRepositories(): Connection {
387+ public function getStarredRepositories(): StarredRepositoryConnection {
388388 if (User::validateStarredRepositories($this->starredRepositories)) {
389389 return $this->starredRepositories;
390390 }
@@ -392,19 +392,19 @@ class User {
392392 }
393393
394394 /**
395- * @return Connection
395+ * @return StarredRepositoryConnection
396396 */
397- public static function sampleStarredRepositories(): Connection {
398- return Connection::sample(); /*32:starredRepositories*/
397+ public static function sampleStarredRepositories(): StarredRepositoryConnection {
398+ return StarredRepositoryConnection::sample(); /*32:starredRepositories*/
399399 }
400400
401401 /**
402402 * @param stdClass $value
403403 * @throws Exception
404- * @return RepositoryConnection
404+ * @return UserRepositoryConnection
405405 */
406- public static function fromRepositories(stdClass $value): RepositoryConnection {
407- return RepositoryConnection::from($value); /*class*/
406+ public static function fromRepositories(stdClass $value): UserRepositoryConnection {
407+ return UserRepositoryConnection::from($value); /*class*/
408408 }
409409
410410 /**
@@ -419,20 +419,20 @@ class User {
419419 }
420420
421421 /**
422- * @param RepositoryConnection
422+ * @param UserRepositoryConnection
423423 * @return bool
424424 * @throws Exception
425425 */
426- public static function validateRepositories(RepositoryConnection $value): bool {
426+ public static function validateRepositories(UserRepositoryConnection $value): bool {
427427 $value->validate();
428428 return true;
429429 }
430430
431431 /**
432432 * @throws Exception
433- * @return RepositoryConnection
433+ * @return UserRepositoryConnection
434434 */
435- public function getRepositories(): RepositoryConnection {
435+ public function getRepositories(): UserRepositoryConnection {
436436 if (User::validateRepositories($this->repositories)) {
437437 return $this->repositories;
438438 }
@@ -440,10 +440,10 @@ class User {
440440 }
441441
442442 /**
443- * @return RepositoryConnection
443+ * @return UserRepositoryConnection
444444 */
445- public static function sampleRepositories(): RepositoryConnection {
446- return RepositoryConnection::sample(); /*33:repositories*/
445+ public static function sampleRepositories(): UserRepositoryConnection {
446+ return UserRepositoryConnection::sample(); /*33:repositories*/
447447 }
448448
449449 /**
@@ -493,9 +493,9 @@ class User {
493493 }
494494 }
495495
496-// This is an autogenerated file:RepositoryConnection
496+// This is an autogenerated file:UserRepositoryConnection
497497
498-class RepositoryConnection {
498+class UserRepositoryConnection {
499499 private ?array $edges; // json:edges Optional
500500
501501 /**
@@ -529,7 +529,7 @@ class RepositoryConnection {
529529 * @return ?array
530530 */
531531 public function toEdges(): ?array {
532- if (RepositoryConnection::validateEdges($this->edges)) {
532+ if (UserRepositoryConnection::validateEdges($this->edges)) {
533533 if (!is_null($this->edges)) {
534534 return array_map(function ($value) {
535535 if (!is_null($value)) {
@@ -542,7 +542,7 @@ class RepositoryConnection {
542542 return null;
543543 }
544544 }
545- throw new Exception('never get to this RepositoryConnection::edges');
545+ throw new Exception('never get to this UserRepositoryConnection::edges');
546546 }
547547
548548 /**
@@ -553,7 +553,7 @@ class RepositoryConnection {
553553 public static function validateEdges(?array $value): bool {
554554 if (!is_null($value)) {
555555 if (!is_array($value)) {
556- throw new Exception("Attribute Error:RepositoryConnection::edges");
556+ throw new Exception("Attribute Error:UserRepositoryConnection::edges");
557557 }
558558 array_walk($value, function($value_v) {
559559 if (!is_null($value_v)) {
@@ -569,10 +569,10 @@ class RepositoryConnection {
569569 * @return ?array
570570 */
571571 public function getEdges(): ?array {
572- if (RepositoryConnection::validateEdges($this->edges)) {
572+ if (UserRepositoryConnection::validateEdges($this->edges)) {
573573 return $this->edges;
574574 }
575- throw new Exception('never get to getEdges RepositoryConnection::edges');
575+ throw new Exception('never get to getEdges UserRepositoryConnection::edges');
576576 }
577577
578578 /**
@@ -589,7 +589,7 @@ class RepositoryConnection {
589589 * @return bool
590590 */
591591 public function validate(): bool {
592- return RepositoryConnection::validateEdges($this->edges);
592+ return UserRepositoryConnection::validateEdges($this->edges);
593593 }
594594
595595 /**
@@ -604,21 +604,21 @@ class RepositoryConnection {
604604
605605 /**
606606 * @param stdClass $obj
607- * @return RepositoryConnection
607+ * @return UserRepositoryConnection
608608 * @throws Exception
609609 */
610- public static function from(stdClass $obj): RepositoryConnection {
611- return new RepositoryConnection(
612- RepositoryConnection::fromEdges($obj->{'edges'})
610+ public static function from(stdClass $obj): UserRepositoryConnection {
611+ return new UserRepositoryConnection(
612+ UserRepositoryConnection::fromEdges($obj->{'edges'})
613613 );
614614 }
615615
616616 /**
617- * @return RepositoryConnection
617+ * @return UserRepositoryConnection
618618 */
619- public static function sample(): RepositoryConnection {
620- return new RepositoryConnection(
621- RepositoryConnection::sampleEdges()
619+ public static function sample(): UserRepositoryConnection {
620+ return new UserRepositoryConnection(
621+ UserRepositoryConnection::sampleEdges()
622622 );
623623 }
624624 }
@@ -736,19 +736,19 @@ class RepositoryEdge {
736736
737737 class Repository {
738738 private string $name; // json:name Required
739- private Connection $stargazers; // json:stargazers Required
740- private Connection $forks; // json:forks Required
741- private Connection $watchers; // json:watchers Required
742- private Connection $issues; // json:issues Required
739+ private StargazerConnection $stargazers; // json:stargazers Required
740+ private RepositoryRepositoryConnection $forks; // json:forks Required
741+ private UserConnection $watchers; // json:watchers Required
742+ private IssueConnection $issues; // json:issues Required
743743
744744 /**
745745 * @param string $name
746- * @param Connection $stargazers
747- * @param Connection $forks
748- * @param Connection $watchers
749- * @param Connection $issues
746+ * @param StargazerConnection $stargazers
747+ * @param RepositoryRepositoryConnection $forks
748+ * @param UserConnection $watchers
749+ * @param IssueConnection $issues
750750 */
751- public function __construct(string $name, Connection $stargazers, Connection $forks, Connection $watchers, Connection $issues) {
751+ public function __construct(string $name, StargazerConnection $stargazers, RepositoryRepositoryConnection $forks, UserConnection $watchers, IssueConnection $issues) {
752752 $this->name = $name;
753753 $this->stargazers = $stargazers;
754754 $this->forks = $forks;
@@ -806,10 +806,10 @@ class Repository {
806806 /**
807807 * @param stdClass $value
808808 * @throws Exception
809- * @return Connection
809+ * @return StargazerConnection
810810 */
811- public static function fromStargazers(stdClass $value): Connection {
812- return Connection::from($value); /*class*/
811+ public static function fromStargazers(stdClass $value): StargazerConnection {
812+ return StargazerConnection::from($value); /*class*/
813813 }
814814
815815 /**
@@ -824,20 +824,20 @@ class Repository {
824824 }
825825
826826 /**
827- * @param Connection
827+ * @param StargazerConnection
828828 * @return bool
829829 * @throws Exception
830830 */
831- public static function validateStargazers(Connection $value): bool {
831+ public static function validateStargazers(StargazerConnection $value): bool {
832832 $value->validate();
833833 return true;
834834 }
835835
836836 /**
837837 * @throws Exception
838- * @return Connection
838+ * @return StargazerConnection
839839 */
840- public function getStargazers(): Connection {
840+ public function getStargazers(): StargazerConnection {
841841 if (Repository::validateStargazers($this->stargazers)) {
842842 return $this->stargazers;
843843 }
@@ -845,19 +845,19 @@ class Repository {
845845 }
846846
847847 /**
848- * @return Connection
848+ * @return StargazerConnection
849849 */
850- public static function sampleStargazers(): Connection {
851- return Connection::sample(); /*32:stargazers*/
850+ public static function sampleStargazers(): StargazerConnection {
851+ return StargazerConnection::sample(); /*32:stargazers*/
852852 }
853853
854854 /**
855855 * @param stdClass $value
856856 * @throws Exception
857- * @return Connection
857+ * @return RepositoryRepositoryConnection
858858 */
859- public static function fromForks(stdClass $value): Connection {
860- return Connection::from($value); /*class*/
859+ public static function fromForks(stdClass $value): RepositoryRepositoryConnection {
860+ return RepositoryRepositoryConnection::from($value); /*class*/
861861 }
862862
863863 /**
@@ -872,20 +872,20 @@ class Repository {
872872 }
873873
874874 /**
875- * @param Connection
875+ * @param RepositoryRepositoryConnection
876876 * @return bool
877877 * @throws Exception
878878 */
879- public static function validateForks(Connection $value): bool {
879+ public static function validateForks(RepositoryRepositoryConnection $value): bool {
880880 $value->validate();
881881 return true;
882882 }
883883
884884 /**
885885 * @throws Exception
886- * @return Connection
886+ * @return RepositoryRepositoryConnection
887887 */
888- public function getForks(): Connection {
888+ public function getForks(): RepositoryRepositoryConnection {
889889 if (Repository::validateForks($this->forks)) {
890890 return $this->forks;
891891 }
@@ -893,19 +893,19 @@ class Repository {
893893 }
894894
895895 /**
896- * @return Connection
896+ * @return RepositoryRepositoryConnection
897897 */
898- public static function sampleForks(): Connection {
899- return Connection::sample(); /*33:forks*/
898+ public static function sampleForks(): RepositoryRepositoryConnection {
899+ return RepositoryRepositoryConnection::sample(); /*33:forks*/
900900 }
901901
902902 /**
903903 * @param stdClass $value
904904 * @throws Exception
905- * @return Connection
905+ * @return UserConnection
906906 */
907- public static function fromWatchers(stdClass $value): Connection {
908- return Connection::from($value); /*class*/
907+ public static function fromWatchers(stdClass $value): UserConnection {
908+ return UserConnection::from($value); /*class*/
909909 }
910910
911911 /**
@@ -920,20 +920,20 @@ class Repository {
920920 }
921921
922922 /**
923- * @param Connection
923+ * @param UserConnection
924924 * @return bool
925925 * @throws Exception
926926 */
927- public static function validateWatchers(Connection $value): bool {
927+ public static function validateWatchers(UserConnection $value): bool {
928928 $value->validate();
929929 return true;
930930 }
931931
932932 /**
933933 * @throws Exception
934- * @return Connection
934+ * @return UserConnection
935935 */
936- public function getWatchers(): Connection {
936+ public function getWatchers(): UserConnection {
937937 if (Repository::validateWatchers($this->watchers)) {
938938 return $this->watchers;
939939 }
@@ -941,19 +941,19 @@ class Repository {
941941 }
942942
943943 /**
944- * @return Connection
944+ * @return UserConnection
945945 */
946- public static function sampleWatchers(): Connection {
947- return Connection::sample(); /*34:watchers*/
946+ public static function sampleWatchers(): UserConnection {
947+ return UserConnection::sample(); /*34:watchers*/
948948 }
949949
950950 /**
951951 * @param stdClass $value
952952 * @throws Exception
953- * @return Connection
953+ * @return IssueConnection
954954 */
955- public static function fromIssues(stdClass $value): Connection {
956- return Connection::from($value); /*class*/
955+ public static function fromIssues(stdClass $value): IssueConnection {
956+ return IssueConnection::from($value); /*class*/
957957 }
958958
959959 /**
@@ -968,20 +968,20 @@ class Repository {
968968 }
969969
970970 /**
971- * @param Connection
971+ * @param IssueConnection
972972 * @return bool
973973 * @throws Exception
974974 */
975- public static function validateIssues(Connection $value): bool {
975+ public static function validateIssues(IssueConnection $value): bool {
976976 $value->validate();
977977 return true;
978978 }
979979
980980 /**
981981 * @throws Exception
982- * @return Connection
982+ * @return IssueConnection
983983 */
984- public function getIssues(): Connection {
984+ public function getIssues(): IssueConnection {
985985 if (Repository::validateIssues($this->issues)) {
986986 return $this->issues;
987987 }
@@ -989,10 +989,10 @@ class Repository {
989989 }
990990
991991 /**
992- * @return Connection
992+ * @return IssueConnection
993993 */
994- public static function sampleIssues(): Connection {
995- return Connection::sample(); /*35:issues*/
994+ public static function sampleIssues(): IssueConnection {
995+ return IssueConnection::sample(); /*35:issues*/
996996 }
997997
998998 /**
@@ -1050,9 +1050,9 @@ class Repository {
10501050 }
10511051 }
10521052
1053-// This is an autogenerated file:Connection
1053+// This is an autogenerated file:RepositoryRepositoryConnection
10541054
1055-class Connection {
1055+class RepositoryRepositoryConnection {
10561056 private int $totalCount; // json:totalCount Required
10571057
10581058 /**
@@ -1076,10 +1076,10 @@ class Connection {
10761076 * @return int
10771077 */
10781078 public function toTotalCount(): int {
1079- if (Connection::validateTotalCount($this->totalCount)) {
1079+ if (RepositoryRepositoryConnection::validateTotalCount($this->totalCount)) {
10801080 return $this->totalCount; /*int*/
10811081 }
1082- throw new Exception('never get to this Connection::totalCount');
1082+ throw new Exception('never get to this RepositoryRepositoryConnection::totalCount');
10831083 }
10841084
10851085 /**
@@ -1096,10 +1096,10 @@ class Connection {
10961096 * @return int
10971097 */
10981098 public function getTotalCount(): int {
1099- if (Connection::validateTotalCount($this->totalCount)) {
1099+ if (RepositoryRepositoryConnection::validateTotalCount($this->totalCount)) {
11001100 return $this->totalCount;
11011101 }
1102- throw new Exception('never get to getTotalCount Connection::totalCount');
1102+ throw new Exception('never get to getTotalCount RepositoryRepositoryConnection::totalCount');
11031103 }
11041104
11051105 /**
@@ -1114,7 +1114,7 @@ class Connection {
11141114 * @return bool
11151115 */
11161116 public function validate(): bool {
1117- return Connection::validateTotalCount($this->totalCount);
1117+ return RepositoryRepositoryConnection::validateTotalCount($this->totalCount);
11181118 }
11191119
11201120 /**
@@ -1129,21 +1129,413 @@ class Connection {
11291129
11301130 /**
11311131 * @param stdClass $obj
1132- * @return Connection
1132+ * @return RepositoryRepositoryConnection
11331133 * @throws Exception
11341134 */
1135- public static function from(stdClass $obj): Connection {
1136- return new Connection(
1137- Connection::fromTotalCount($obj->{'totalCount'})
1135+ public static function from(stdClass $obj): RepositoryRepositoryConnection {
1136+ return new RepositoryRepositoryConnection(
1137+ RepositoryRepositoryConnection::fromTotalCount($obj->{'totalCount'})
11381138 );
11391139 }
11401140
11411141 /**
1142- * @return Connection
1142+ * @return RepositoryRepositoryConnection
11431143 */
1144- public static function sample(): Connection {
1145- return new Connection(
1146- Connection::sampleTotalCount()
1144+ public static function sample(): RepositoryRepositoryConnection {
1145+ return new RepositoryRepositoryConnection(
1146+ RepositoryRepositoryConnection::sampleTotalCount()
1147+ );
1148+ }
1149+}
1150+
1151+// This is an autogenerated file:IssueConnection
1152+
1153+class IssueConnection {
1154+ private int $totalCount; // json:totalCount Required
1155+
1156+ /**
1157+ * @param int $totalCount
1158+ */
1159+ public function __construct(int $totalCount) {
1160+ $this->totalCount = $totalCount;
1161+ }
1162+
1163+ /**
1164+ * @param int $value
1165+ * @throws Exception
1166+ * @return int
1167+ */
1168+ public static function fromTotalCount(int $value): int {
1169+ return $value; /*int*/
1170+ }
1171+
1172+ /**
1173+ * @throws Exception
1174+ * @return int
1175+ */
1176+ public function toTotalCount(): int {
1177+ if (IssueConnection::validateTotalCount($this->totalCount)) {
1178+ return $this->totalCount; /*int*/
1179+ }
1180+ throw new Exception('never get to this IssueConnection::totalCount');
1181+ }
1182+
1183+ /**
1184+ * @param int
1185+ * @return bool
1186+ * @throws Exception
1187+ */
1188+ public static function validateTotalCount(int $value): bool {
1189+ return true;
1190+ }
1191+
1192+ /**
1193+ * @throws Exception
1194+ * @return int
1195+ */
1196+ public function getTotalCount(): int {
1197+ if (IssueConnection::validateTotalCount($this->totalCount)) {
1198+ return $this->totalCount;
1199+ }
1200+ throw new Exception('never get to getTotalCount IssueConnection::totalCount');
1201+ }
1202+
1203+ /**
1204+ * @return int
1205+ */
1206+ public static function sampleTotalCount(): int {
1207+ return 31; /*31:totalCount*/
1208+ }
1209+
1210+ /**
1211+ * @throws Exception
1212+ * @return bool
1213+ */
1214+ public function validate(): bool {
1215+ return IssueConnection::validateTotalCount($this->totalCount);
1216+ }
1217+
1218+ /**
1219+ * @return stdClass
1220+ * @throws Exception
1221+ */
1222+ public function to(): stdClass {
1223+ $out = new stdClass();
1224+ $out->{'totalCount'} = $this->toTotalCount();
1225+ return $out;
1226+ }
1227+
1228+ /**
1229+ * @param stdClass $obj
1230+ * @return IssueConnection
1231+ * @throws Exception
1232+ */
1233+ public static function from(stdClass $obj): IssueConnection {
1234+ return new IssueConnection(
1235+ IssueConnection::fromTotalCount($obj->{'totalCount'})
1236+ );
1237+ }
1238+
1239+ /**
1240+ * @return IssueConnection
1241+ */
1242+ public static function sample(): IssueConnection {
1243+ return new IssueConnection(
1244+ IssueConnection::sampleTotalCount()
1245+ );
1246+ }
1247+}
1248+
1249+// This is an autogenerated file:StargazerConnection
1250+
1251+class StargazerConnection {
1252+ private int $totalCount; // json:totalCount Required
1253+
1254+ /**
1255+ * @param int $totalCount
1256+ */
1257+ public function __construct(int $totalCount) {
1258+ $this->totalCount = $totalCount;
1259+ }
1260+
1261+ /**
1262+ * @param int $value
1263+ * @throws Exception
1264+ * @return int
1265+ */
1266+ public static function fromTotalCount(int $value): int {
1267+ return $value; /*int*/
1268+ }
1269+
1270+ /**
1271+ * @throws Exception
1272+ * @return int
1273+ */
1274+ public function toTotalCount(): int {
1275+ if (StargazerConnection::validateTotalCount($this->totalCount)) {
1276+ return $this->totalCount; /*int*/
1277+ }
1278+ throw new Exception('never get to this StargazerConnection::totalCount');
1279+ }
1280+
1281+ /**
1282+ * @param int
1283+ * @return bool
1284+ * @throws Exception
1285+ */
1286+ public static function validateTotalCount(int $value): bool {
1287+ return true;
1288+ }
1289+
1290+ /**
1291+ * @throws Exception
1292+ * @return int
1293+ */
1294+ public function getTotalCount(): int {
1295+ if (StargazerConnection::validateTotalCount($this->totalCount)) {
1296+ return $this->totalCount;
1297+ }
1298+ throw new Exception('never get to getTotalCount StargazerConnection::totalCount');
1299+ }
1300+
1301+ /**
1302+ * @return int
1303+ */
1304+ public static function sampleTotalCount(): int {
1305+ return 31; /*31:totalCount*/
1306+ }
1307+
1308+ /**
1309+ * @throws Exception
1310+ * @return bool
1311+ */
1312+ public function validate(): bool {
1313+ return StargazerConnection::validateTotalCount($this->totalCount);
1314+ }
1315+
1316+ /**
1317+ * @return stdClass
1318+ * @throws Exception
1319+ */
1320+ public function to(): stdClass {
1321+ $out = new stdClass();
1322+ $out->{'totalCount'} = $this->toTotalCount();
1323+ return $out;
1324+ }
1325+
1326+ /**
1327+ * @param stdClass $obj
1328+ * @return StargazerConnection
1329+ * @throws Exception
1330+ */
1331+ public static function from(stdClass $obj): StargazerConnection {
1332+ return new StargazerConnection(
1333+ StargazerConnection::fromTotalCount($obj->{'totalCount'})
1334+ );
1335+ }
1336+
1337+ /**
1338+ * @return StargazerConnection
1339+ */
1340+ public static function sample(): StargazerConnection {
1341+ return new StargazerConnection(
1342+ StargazerConnection::sampleTotalCount()
1343+ );
1344+ }
1345+}
1346+
1347+// This is an autogenerated file:UserConnection
1348+
1349+class UserConnection {
1350+ private int $totalCount; // json:totalCount Required
1351+
1352+ /**
1353+ * @param int $totalCount
1354+ */
1355+ public function __construct(int $totalCount) {
1356+ $this->totalCount = $totalCount;
1357+ }
1358+
1359+ /**
1360+ * @param int $value
1361+ * @throws Exception
1362+ * @return int
1363+ */
1364+ public static function fromTotalCount(int $value): int {
1365+ return $value; /*int*/
1366+ }
1367+
1368+ /**
1369+ * @throws Exception
1370+ * @return int
1371+ */
1372+ public function toTotalCount(): int {
1373+ if (UserConnection::validateTotalCount($this->totalCount)) {
1374+ return $this->totalCount; /*int*/
1375+ }
1376+ throw new Exception('never get to this UserConnection::totalCount');
1377+ }
1378+
1379+ /**
1380+ * @param int
1381+ * @return bool
1382+ * @throws Exception
1383+ */
1384+ public static function validateTotalCount(int $value): bool {
1385+ return true;
1386+ }
1387+
1388+ /**
1389+ * @throws Exception
1390+ * @return int
1391+ */
1392+ public function getTotalCount(): int {
1393+ if (UserConnection::validateTotalCount($this->totalCount)) {
1394+ return $this->totalCount;
1395+ }
1396+ throw new Exception('never get to getTotalCount UserConnection::totalCount');
1397+ }
1398+
1399+ /**
1400+ * @return int
1401+ */
1402+ public static function sampleTotalCount(): int {
1403+ return 31; /*31:totalCount*/
1404+ }
1405+
1406+ /**
1407+ * @throws Exception
1408+ * @return bool
1409+ */
1410+ public function validate(): bool {
1411+ return UserConnection::validateTotalCount($this->totalCount);
1412+ }
1413+
1414+ /**
1415+ * @return stdClass
1416+ * @throws Exception
1417+ */
1418+ public function to(): stdClass {
1419+ $out = new stdClass();
1420+ $out->{'totalCount'} = $this->toTotalCount();
1421+ return $out;
1422+ }
1423+
1424+ /**
1425+ * @param stdClass $obj
1426+ * @return UserConnection
1427+ * @throws Exception
1428+ */
1429+ public static function from(stdClass $obj): UserConnection {
1430+ return new UserConnection(
1431+ UserConnection::fromTotalCount($obj->{'totalCount'})
1432+ );
1433+ }
1434+
1435+ /**
1436+ * @return UserConnection
1437+ */
1438+ public static function sample(): UserConnection {
1439+ return new UserConnection(
1440+ UserConnection::sampleTotalCount()
1441+ );
1442+ }
1443+}
1444+
1445+// This is an autogenerated file:StarredRepositoryConnection
1446+
1447+class StarredRepositoryConnection {
1448+ private int $totalCount; // json:totalCount Required
1449+
1450+ /**
1451+ * @param int $totalCount
1452+ */
1453+ public function __construct(int $totalCount) {
1454+ $this->totalCount = $totalCount;
1455+ }
1456+
1457+ /**
1458+ * @param int $value
1459+ * @throws Exception
1460+ * @return int
1461+ */
1462+ public static function fromTotalCount(int $value): int {
1463+ return $value; /*int*/
1464+ }
1465+
1466+ /**
1467+ * @throws Exception
1468+ * @return int
1469+ */
1470+ public function toTotalCount(): int {
1471+ if (StarredRepositoryConnection::validateTotalCount($this->totalCount)) {
1472+ return $this->totalCount; /*int*/
1473+ }
1474+ throw new Exception('never get to this StarredRepositoryConnection::totalCount');
1475+ }
1476+
1477+ /**
1478+ * @param int
1479+ * @return bool
1480+ * @throws Exception
1481+ */
1482+ public static function validateTotalCount(int $value): bool {
1483+ return true;
1484+ }
1485+
1486+ /**
1487+ * @throws Exception
1488+ * @return int
1489+ */
1490+ public function getTotalCount(): int {
1491+ if (StarredRepositoryConnection::validateTotalCount($this->totalCount)) {
1492+ return $this->totalCount;
1493+ }
1494+ throw new Exception('never get to getTotalCount StarredRepositoryConnection::totalCount');
1495+ }
1496+
1497+ /**
1498+ * @return int
1499+ */
1500+ public static function sampleTotalCount(): int {
1501+ return 31; /*31:totalCount*/
1502+ }
1503+
1504+ /**
1505+ * @throws Exception
1506+ * @return bool
1507+ */
1508+ public function validate(): bool {
1509+ return StarredRepositoryConnection::validateTotalCount($this->totalCount);
1510+ }
1511+
1512+ /**
1513+ * @return stdClass
1514+ * @throws Exception
1515+ */
1516+ public function to(): stdClass {
1517+ $out = new stdClass();
1518+ $out->{'totalCount'} = $this->toTotalCount();
1519+ return $out;
1520+ }
1521+
1522+ /**
1523+ * @param stdClass $obj
1524+ * @return StarredRepositoryConnection
1525+ * @throws Exception
1526+ */
1527+ public static function from(stdClass $obj): StarredRepositoryConnection {
1528+ return new StarredRepositoryConnection(
1529+ StarredRepositoryConnection::fromTotalCount($obj->{'totalCount'})
1530+ );
1531+ }
1532+
1533+ /**
1534+ * @return StarredRepositoryConnection
1535+ */
1536+ public static function sample(): StarredRepositoryConnection {
1537+ return new StarredRepositoryConnection(
1538+ StarredRepositoryConnection::sampleTotalCount()
11471539 );
11481540 }
11491541 }
Mgraphql-pikedefault / TopLevel.pmod+94 −14
@@ -56,9 +56,9 @@ Data Data_from_JSON(mixed json) {
5656 }
5757
5858 class User {
59- string login; // json: "login"
60- Connection starred_repositories; // json: "starredRepositories"
61- RepositoryConnection repositories; // json: "repositories"
59+ string login; // json: "login"
60+ StarredRepositoryConnection starred_repositories; // json: "starredRepositories"
61+ UserRepositoryConnection repositories; // json: "repositories"
6262
6363 string encode_json() {
6464 mapping(string:mixed) json = ([
@@ -81,7 +81,7 @@ User User_from_JSON(mixed json) {
8181 return retval;
8282 }
8383
84-class RepositoryConnection {
84+class UserRepositoryConnection {
8585 array(RepositoryEdge|mixed)|mixed edges; // json: "edges"
8686
8787 string encode_json() {
@@ -93,8 +93,8 @@ class RepositoryConnection {
9393 }
9494 }
9595
96-RepositoryConnection RepositoryConnection_from_JSON(mixed json) {
97- RepositoryConnection retval = RepositoryConnection();
96+UserRepositoryConnection UserRepositoryConnection_from_JSON(mixed json) {
97+ UserRepositoryConnection retval = UserRepositoryConnection();
9898
9999 retval.edges = json["edges"];
100100
@@ -122,11 +122,11 @@ RepositoryEdge RepositoryEdge_from_JSON(mixed json) {
122122 }
123123
124124 class Repository {
125- string name; // json: "name"
126- Connection stargazers; // json: "stargazers"
127- Connection forks; // json: "forks"
128- Connection watchers; // json: "watchers"
129- Connection issues; // json: "issues"
125+ string name; // json: "name"
126+ StargazerConnection stargazers; // json: "stargazers"
127+ RepositoryRepositoryConnection forks; // json: "forks"
128+ UserConnection watchers; // json: "watchers"
129+ IssueConnection issues; // json: "issues"
130130
131131 string encode_json() {
132132 mapping(string:mixed) json = ([
@@ -153,7 +153,7 @@ Repository Repository_from_JSON(mixed json) {
153153 return retval;
154154 }
155155
156-class Connection {
156+class RepositoryRepositoryConnection {
157157 int total_count; // json: "totalCount"
158158
159159 string encode_json() {
@@ -165,8 +165,88 @@ class Connection {
165165 }
166166 }
167167
168-Connection Connection_from_JSON(mixed json) {
169- Connection retval = Connection();
168+RepositoryRepositoryConnection RepositoryRepositoryConnection_from_JSON(mixed json) {
169+ RepositoryRepositoryConnection retval = RepositoryRepositoryConnection();
170+
171+ retval.total_count = json["totalCount"];
172+
173+ return retval;
174+}
175+
176+class IssueConnection {
177+ int total_count; // json: "totalCount"
178+
179+ string encode_json() {
180+ mapping(string:mixed) json = ([
181+ "totalCount" : total_count,
182+ ]);
183+
184+ return Standards.JSON.encode(json);
185+ }
186+}
187+
188+IssueConnection IssueConnection_from_JSON(mixed json) {
189+ IssueConnection retval = IssueConnection();
190+
191+ retval.total_count = json["totalCount"];
192+
193+ return retval;
194+}
195+
196+class StargazerConnection {
197+ int total_count; // json: "totalCount"
198+
199+ string encode_json() {
200+ mapping(string:mixed) json = ([
201+ "totalCount" : total_count,
202+ ]);
203+
204+ return Standards.JSON.encode(json);
205+ }
206+}
207+
208+StargazerConnection StargazerConnection_from_JSON(mixed json) {
209+ StargazerConnection retval = StargazerConnection();
210+
211+ retval.total_count = json["totalCount"];
212+
213+ return retval;
214+}
215+
216+class UserConnection {
217+ int total_count; // json: "totalCount"
218+
219+ string encode_json() {
220+ mapping(string:mixed) json = ([
221+ "totalCount" : total_count,
222+ ]);
223+
224+ return Standards.JSON.encode(json);
225+ }
226+}
227+
228+UserConnection UserConnection_from_JSON(mixed json) {
229+ UserConnection retval = UserConnection();
230+
231+ retval.total_count = json["totalCount"];
232+
233+ return retval;
234+}
235+
236+class StarredRepositoryConnection {
237+ int total_count; // json: "totalCount"
238+
239+ string encode_json() {
240+ mapping(string:mixed) json = ([
241+ "totalCount" : total_count,
242+ ]);
243+
244+ return Standards.JSON.encode(json);
245+ }
246+}
247+
248+StarredRepositoryConnection StarredRepositoryConnection_from_JSON(mixed json) {
249+ StarredRepositoryConnection retval = StarredRepositoryConnection();
170250
171251 retval.total_count = json["totalCount"];
Mgraphql-pythondefault / quicktype.py+88 −24
@@ -40,14 +40,62 @@ def from_list(f: Callable[[Any], T], x: Any) -> list[T]:
4040
4141
4242 @dataclass
43-class Connection:
43+class RepositoryRepositoryConnection:
4444 total_count: int
4545
4646 @staticmethod
47- def from_dict(obj: Any) -> 'Connection':
47+ def from_dict(obj: Any) -> 'RepositoryRepositoryConnection':
4848 assert isinstance(obj, dict)
4949 total_count = from_int(obj.get("totalCount"))
50- return Connection(total_count)
50+ return RepositoryRepositoryConnection(total_count)
51+
52+ def to_dict(self) -> dict:
53+ result: dict = {}
54+ result["totalCount"] = from_int(self.total_count)
55+ return result
56+
57+
58+@dataclass
59+class IssueConnection:
60+ total_count: int
61+
62+ @staticmethod
63+ def from_dict(obj: Any) -> 'IssueConnection':
64+ assert isinstance(obj, dict)
65+ total_count = from_int(obj.get("totalCount"))
66+ return IssueConnection(total_count)
67+
68+ def to_dict(self) -> dict:
69+ result: dict = {}
70+ result["totalCount"] = from_int(self.total_count)
71+ return result
72+
73+
74+@dataclass
75+class StargazerConnection:
76+ total_count: int
77+
78+ @staticmethod
79+ def from_dict(obj: Any) -> 'StargazerConnection':
80+ assert isinstance(obj, dict)
81+ total_count = from_int(obj.get("totalCount"))
82+ return StargazerConnection(total_count)
83+
84+ def to_dict(self) -> dict:
85+ result: dict = {}
86+ result["totalCount"] = from_int(self.total_count)
87+ return result
88+
89+
90+@dataclass
91+class UserConnection:
92+ total_count: int
93+
94+ @staticmethod
95+ def from_dict(obj: Any) -> 'UserConnection':
96+ assert isinstance(obj, dict)
97+ total_count = from_int(obj.get("totalCount"))
98+ return UserConnection(total_count)
5199
52100 def to_dict(self) -> dict:
53101 result: dict = {}
@@ -58,28 +106,28 @@ class Connection:
58106 @dataclass
59107 class Repository:
60108 name: str
61- stargazers: Connection
62- forks: Connection
63- watchers: Connection
64- issues: Connection
109+ stargazers: StargazerConnection
110+ forks: RepositoryRepositoryConnection
111+ watchers: UserConnection
112+ issues: IssueConnection
65113
66114 @staticmethod
67115 def from_dict(obj: Any) -> 'Repository':
68116 assert isinstance(obj, dict)
69117 name = from_str(obj.get("name"))
70- stargazers = Connection.from_dict(obj.get("stargazers"))
71- forks = Connection.from_dict(obj.get("forks"))
72- watchers = Connection.from_dict(obj.get("watchers"))
73- issues = Connection.from_dict(obj.get("issues"))
118+ stargazers = StargazerConnection.from_dict(obj.get("stargazers"))
119+ forks = RepositoryRepositoryConnection.from_dict(obj.get("forks"))
120+ watchers = UserConnection.from_dict(obj.get("watchers"))
121+ issues = IssueConnection.from_dict(obj.get("issues"))
74122 return Repository(name, stargazers, forks, watchers, issues)
75123
76124 def to_dict(self) -> dict:
77125 result: dict = {}
78126 result["name"] = from_str(self.name)
79- result["stargazers"] = to_class(Connection, self.stargazers)
80- result["forks"] = to_class(Connection, self.forks)
81- result["watchers"] = to_class(Connection, self.watchers)
82- result["issues"] = to_class(Connection, self.issues)
127+ result["stargazers"] = to_class(StargazerConnection, self.stargazers)
128+ result["forks"] = to_class(RepositoryRepositoryConnection, self.forks)
129+ result["watchers"] = to_class(UserConnection, self.watchers)
130+ result["issues"] = to_class(IssueConnection, self.issues)
83131 return result
84132
85133
@@ -100,14 +148,14 @@ class RepositoryEdge:
100148
101149
102150 @dataclass
103-class RepositoryConnection:
151+class UserRepositoryConnection:
104152 edges: list[RepositoryEdge | None] | None = None
105153
106154 @staticmethod
107- def from_dict(obj: Any) -> 'RepositoryConnection':
155+ def from_dict(obj: Any) -> 'UserRepositoryConnection':
108156 assert isinstance(obj, dict)
109157 edges = from_union([lambda x: from_list(lambda x: from_union([RepositoryEdge.from_dict, from_none], x), x), from_none], obj.get("edges"))
110- return RepositoryConnection(edges)
158+ return UserRepositoryConnection(edges)
111159
112160 def to_dict(self) -> dict:
113161 result: dict = {}
@@ -115,25 +163,41 @@ class RepositoryConnection:
115163 return result
116164
117165
166+@dataclass
167+class StarredRepositoryConnection:
168+ total_count: int
169+
170+ @staticmethod
171+ def from_dict(obj: Any) -> 'StarredRepositoryConnection':
172+ assert isinstance(obj, dict)
173+ total_count = from_int(obj.get("totalCount"))
174+ return StarredRepositoryConnection(total_count)
175+
176+ def to_dict(self) -> dict:
177+ result: dict = {}
178+ result["totalCount"] = from_int(self.total_count)
179+ return result
180+
181+
118182 @dataclass
119183 class User:
120184 login: str
121- starred_repositories: Connection
122- repositories: RepositoryConnection
185+ starred_repositories: StarredRepositoryConnection
186+ repositories: UserRepositoryConnection
123187
124188 @staticmethod
125189 def from_dict(obj: Any) -> 'User':
126190 assert isinstance(obj, dict)
127191 login = from_str(obj.get("login"))
128- starred_repositories = Connection.from_dict(obj.get("starredRepositories"))
129- repositories = RepositoryConnection.from_dict(obj.get("repositories"))
192+ starred_repositories = StarredRepositoryConnection.from_dict(obj.get("starredRepositories"))
193+ repositories = UserRepositoryConnection.from_dict(obj.get("repositories"))
130194 return User(login, starred_repositories, repositories)
131195
132196 def to_dict(self) -> dict:
133197 result: dict = {}
134198 result["login"] = from_str(self.login)
135- result["starredRepositories"] = to_class(Connection, self.starred_repositories)
136- result["repositories"] = to_class(RepositoryConnection, self.repositories)
199+ result["starredRepositories"] = to_class(StarredRepositoryConnection, self.starred_repositories)
200+ result["repositories"] = to_class(UserRepositoryConnection, self.repositories)
137201 return result
Mgraphql-swiftdefault / quicktype.swift+202 −26
@@ -100,8 +100,8 @@ extension DataClass {
100100 // MARK: - User
101101 struct User: Codable {
102102 let login: String
103- let starredRepositories: Connection
104- let repositories: RepositoryConnection
103+ let starredRepositories: StarredRepositoryConnection
104+ let repositories: UserRepositoryConnection
105105
106106 enum CodingKeys: String, CodingKey {
107107 case login = "login"
@@ -130,8 +130,8 @@ extension User {
130130
131131 func with(
132132 login: String? = nil,
133- starredRepositories: Connection? = nil,
134- repositories: RepositoryConnection? = nil
133+ starredRepositories: StarredRepositoryConnection? = nil,
134+ repositories: UserRepositoryConnection? = nil
135135 ) -> User {
136136 return User(
137137 login: login ?? self.login,
@@ -149,8 +149,8 @@ extension User {
149149 }
150150 }
151151
152-// MARK: - RepositoryConnection
153-struct RepositoryConnection: Codable {
152+// MARK: - UserRepositoryConnection
153+struct UserRepositoryConnection: Codable {
154154 let edges: [RepositoryEdge?]?
155155
156156 enum CodingKeys: String, CodingKey {
@@ -158,11 +158,11 @@ struct RepositoryConnection: Codable {
158158 }
159159 }
160160
161-// MARK: RepositoryConnection convenience initializers and mutators
161+// MARK: UserRepositoryConnection convenience initializers and mutators
162162
163-extension RepositoryConnection {
163+extension UserRepositoryConnection {
164164 init(data: Data) throws {
165- self = try newJSONDecoder().decode(RepositoryConnection.self, from: data)
165+ self = try newJSONDecoder().decode(UserRepositoryConnection.self, from: data)
166166 }
167167
168168 init(_ json: String, using encoding: String.Encoding = .utf8) throws {
@@ -178,8 +178,8 @@ extension RepositoryConnection {
178178
179179 func with(
180180 edges: [RepositoryEdge?]?? = nil
181- ) -> RepositoryConnection {
182- return RepositoryConnection(
181+ ) -> UserRepositoryConnection {
182+ return UserRepositoryConnection(
183183 edges: edges ?? self.edges
184184 )
185185 }
@@ -240,10 +240,10 @@ extension RepositoryEdge {
240240 // MARK: - Repository
241241 struct Repository: Codable {
242242 let name: String
243- let stargazers: Connection
244- let forks: Connection
245- let watchers: Connection
246- let issues: Connection
243+ let stargazers: StargazerConnection
244+ let forks: RepositoryRepositoryConnection
245+ let watchers: UserConnection
246+ let issues: IssueConnection
247247
248248 enum CodingKeys: String, CodingKey {
249249 case name = "name"
@@ -274,10 +274,10 @@ extension Repository {
274274
275275 func with(
276276 name: String? = nil,
277- stargazers: Connection? = nil,
278- forks: Connection? = nil,
279- watchers: Connection? = nil,
280- issues: Connection? = nil
277+ stargazers: StargazerConnection? = nil,
278+ forks: RepositoryRepositoryConnection? = nil,
279+ watchers: UserConnection? = nil,
280+ issues: IssueConnection? = nil
281281 ) -> Repository {
282282 return Repository(
283283 name: name ?? self.name,
@@ -297,8 +297,8 @@ extension Repository {
297297 }
298298 }
299299
300-// MARK: - Connection
301-struct Connection: Codable {
300+// MARK: - RepositoryRepositoryConnection
301+struct RepositoryRepositoryConnection: Codable {
302302 let totalCount: Int
303303
304304 enum CodingKeys: String, CodingKey {
@@ -306,11 +306,11 @@ struct Connection: Codable {
306306 }
307307 }
308308
309-// MARK: Connection convenience initializers and mutators
309+// MARK: RepositoryRepositoryConnection convenience initializers and mutators
310310
311-extension Connection {
311+extension RepositoryRepositoryConnection {
312312 init(data: Data) throws {
313- self = try newJSONDecoder().decode(Connection.self, from: data)
313+ self = try newJSONDecoder().decode(RepositoryRepositoryConnection.self, from: data)
314314 }
315315
316316 init(_ json: String, using encoding: String.Encoding = .utf8) throws {
@@ -326,8 +326,184 @@ extension Connection {
326326
327327 func with(
328328 totalCount: Int? = nil
329- ) -> Connection {
330- return Connection(
329+ ) -> RepositoryRepositoryConnection {
330+ return RepositoryRepositoryConnection(
331+ totalCount: totalCount ?? self.totalCount
332+ )
333+ }
334+
335+ func jsonData() throws -> Data {
336+ return try newJSONEncoder().encode(self)
337+ }
338+
339+ func jsonString(encoding: String.Encoding = .utf8) throws -> String? {
340+ return String(data: try self.jsonData(), encoding: encoding)
341+ }
342+}
343+
344+// MARK: - IssueConnection
345+struct IssueConnection: Codable {
346+ let totalCount: Int
347+
348+ enum CodingKeys: String, CodingKey {
349+ case totalCount = "totalCount"
350+ }
351+}
352+
353+// MARK: IssueConnection convenience initializers and mutators
354+
355+extension IssueConnection {
356+ init(data: Data) throws {
357+ self = try newJSONDecoder().decode(IssueConnection.self, from: data)
358+ }
359+
360+ init(_ json: String, using encoding: String.Encoding = .utf8) throws {
361+ guard let data = json.data(using: encoding) else {
362+ throw NSError(domain: "JSONDecoding", code: 0, userInfo: nil)
363+ }
364+ try self.init(data: data)
365+ }
366+
367+ init(fromURL url: URL) throws {
368+ try self.init(data: try Data(contentsOf: url))
369+ }
370+
371+ func with(
372+ totalCount: Int? = nil
373+ ) -> IssueConnection {
374+ return IssueConnection(
375+ totalCount: totalCount ?? self.totalCount
376+ )
377+ }
378+
379+ func jsonData() throws -> Data {
380+ return try newJSONEncoder().encode(self)
381+ }
382+
383+ func jsonString(encoding: String.Encoding = .utf8) throws -> String? {
384+ return String(data: try self.jsonData(), encoding: encoding)
385+ }
386+}
387+
388+// MARK: - StargazerConnection
389+struct StargazerConnection: Codable {
390+ let totalCount: Int
391+
392+ enum CodingKeys: String, CodingKey {
393+ case totalCount = "totalCount"
394+ }
395+}
396+
397+// MARK: StargazerConnection convenience initializers and mutators
398+
399+extension StargazerConnection {
400+ init(data: Data) throws {
401+ self = try newJSONDecoder().decode(StargazerConnection.self, from: data)
402+ }
403+
404+ init(_ json: String, using encoding: String.Encoding = .utf8) throws {
405+ guard let data = json.data(using: encoding) else {
406+ throw NSError(domain: "JSONDecoding", code: 0, userInfo: nil)
407+ }
408+ try self.init(data: data)
409+ }
410+
411+ init(fromURL url: URL) throws {
412+ try self.init(data: try Data(contentsOf: url))
413+ }
414+
415+ func with(
416+ totalCount: Int? = nil
417+ ) -> StargazerConnection {
418+ return StargazerConnection(
419+ totalCount: totalCount ?? self.totalCount
420+ )
421+ }
422+
423+ func jsonData() throws -> Data {
424+ return try newJSONEncoder().encode(self)
425+ }
426+
427+ func jsonString(encoding: String.Encoding = .utf8) throws -> String? {
428+ return String(data: try self.jsonData(), encoding: encoding)
429+ }
430+}
431+
432+// MARK: - UserConnection
433+struct UserConnection: Codable {
434+ let totalCount: Int
435+
436+ enum CodingKeys: String, CodingKey {
437+ case totalCount = "totalCount"
438+ }
439+}
440+
441+// MARK: UserConnection convenience initializers and mutators
442+
443+extension UserConnection {
444+ init(data: Data) throws {
445+ self = try newJSONDecoder().decode(UserConnection.self, from: data)
446+ }
447+
448+ init(_ json: String, using encoding: String.Encoding = .utf8) throws {
449+ guard let data = json.data(using: encoding) else {
450+ throw NSError(domain: "JSONDecoding", code: 0, userInfo: nil)
451+ }
452+ try self.init(data: data)
453+ }
454+
455+ init(fromURL url: URL) throws {
456+ try self.init(data: try Data(contentsOf: url))
457+ }
458+
459+ func with(
460+ totalCount: Int? = nil
461+ ) -> UserConnection {
462+ return UserConnection(
463+ totalCount: totalCount ?? self.totalCount
464+ )
465+ }
466+
467+ func jsonData() throws -> Data {
468+ return try newJSONEncoder().encode(self)
469+ }
470+
471+ func jsonString(encoding: String.Encoding = .utf8) throws -> String? {
472+ return String(data: try self.jsonData(), encoding: encoding)
473+ }
474+}
475+
476+// MARK: - StarredRepositoryConnection
477+struct StarredRepositoryConnection: Codable {
478+ let totalCount: Int
479+
480+ enum CodingKeys: String, CodingKey {
481+ case totalCount = "totalCount"
482+ }
483+}
484+
485+// MARK: StarredRepositoryConnection convenience initializers and mutators
486+
487+extension StarredRepositoryConnection {
488+ init(data: Data) throws {
489+ self = try newJSONDecoder().decode(StarredRepositoryConnection.self, from: data)
490+ }
491+
492+ init(_ json: String, using encoding: String.Encoding = .utf8) throws {
493+ guard let data = json.data(using: encoding) else {
494+ throw NSError(domain: "JSONDecoding", code: 0, userInfo: nil)
495+ }
496+ try self.init(data: data)
497+ }
498+
499+ init(fromURL url: URL) throws {
500+ try self.init(data: try Data(contentsOf: url))
501+ }
502+
503+ func with(
504+ totalCount: Int? = nil
505+ ) -> StarredRepositoryConnection {
506+ return StarredRepositoryConnection(
331507 totalCount: totalCount ?? self.totalCount
332508 )
333509 }
Mgraphql-typescriptdefault / TopLevel.ts+44 −16
@@ -18,11 +18,11 @@ export interface Data {
1818
1919 export interface User {
2020 login: string;
21- starredRepositories: Connection;
22- repositories: RepositoryConnection;
21+ starredRepositories: StarredRepositoryConnection;
22+ repositories: UserRepositoryConnection;
2323 }
2424
25-export interface RepositoryConnection {
25+export interface UserRepositoryConnection {
2626 edges: (RepositoryEdge | null)[] | null;
2727 }
2828
@@ -32,13 +32,29 @@ export interface RepositoryEdge {
3232
3333 export interface Repository {
3434 name: string;
35- stargazers: Connection;
36- forks: Connection;
37- watchers: Connection;
38- issues: Connection;
35+ stargazers: StargazerConnection;
36+ forks: RepositoryRepositoryConnection;
37+ watchers: UserConnection;
38+ issues: IssueConnection;
3939 }
4040
41-export interface Connection {
41+export interface RepositoryRepositoryConnection {
42+ totalCount: number;
43+}
44+
45+export interface IssueConnection {
46+ totalCount: number;
47+}
48+
49+export interface StargazerConnection {
50+ totalCount: number;
51+}
52+
53+export interface UserConnection {
54+ totalCount: number;
55+}
56+
57+export interface StarredRepositoryConnection {
4258 totalCount: number;
4359 }
4460
@@ -221,10 +237,10 @@ const typeMap: any = {
221237 ], false),
222238 "User": o([
223239 { json: "login", js: "login", typ: "" },
224- { json: "starredRepositories", js: "starredRepositories", typ: r("Connection") },
225- { json: "repositories", js: "repositories", typ: r("RepositoryConnection") },
240+ { json: "starredRepositories", js: "starredRepositories", typ: r("StarredRepositoryConnection") },
241+ { json: "repositories", js: "repositories", typ: r("UserRepositoryConnection") },
226242 ], false),
227- "RepositoryConnection": o([
243+ "UserRepositoryConnection": o([
228244 { json: "edges", js: "edges", typ: u(a(u(r("RepositoryEdge"), null)), null) },
229245 ], false),
230246 "RepositoryEdge": o([
@@ -232,12 +248,24 @@ const typeMap: any = {
232248 ], false),
233249 "Repository": o([
234250 { json: "name", js: "name", typ: "" },
235- { json: "stargazers", js: "stargazers", typ: r("Connection") },
236- { json: "forks", js: "forks", typ: r("Connection") },
237- { json: "watchers", js: "watchers", typ: r("Connection") },
238- { json: "issues", js: "issues", typ: r("Connection") },
251+ { json: "stargazers", js: "stargazers", typ: r("StargazerConnection") },
252+ { json: "forks", js: "forks", typ: r("RepositoryRepositoryConnection") },
253+ { json: "watchers", js: "watchers", typ: r("UserConnection") },
254+ { json: "issues", js: "issues", typ: r("IssueConnection") },
255+ ], false),
256+ "RepositoryRepositoryConnection": o([
257+ { json: "totalCount", js: "totalCount", typ: 0 },
258+ ], false),
259+ "IssueConnection": o([
260+ { json: "totalCount", js: "totalCount", typ: 0 },
261+ ], false),
262+ "StargazerConnection": o([
263+ { json: "totalCount", js: "totalCount", typ: 0 },
264+ ], false),
265+ "UserConnection": o([
266+ { json: "totalCount", js: "totalCount", typ: 0 },
239267 ], false),
240- "Connection": o([
268+ "StarredRepositoryConnection": o([
241269 { json: "totalCount", js: "totalCount", typ: 0 },
242270 ], false),
243271 "Error": o([
Test case

test/inputs/graphql/github9.graphql

23 generated files · +495 −43
Mgraphql-cjsondefault / TopLevel.c+58 −5
@@ -84,6 +84,59 @@ void cJSON_DeleteReaction(struct Reaction * x) {
8484 }
8585 }
8686
87+struct ReactionGroup * cJSON_ParseReactionGroup(const char * s) {
88+ struct ReactionGroup * x = NULL;
89+ if (NULL != s) {
90+ cJSON * j = cJSON_Parse(s);
91+ if (NULL != j) {
92+ x = cJSON_GetReactionGroupValue(j);
93+ cJSON_Delete(j);
94+ }
95+ }
96+ return x;
97+}
98+
99+struct ReactionGroup * cJSON_GetReactionGroupValue(const cJSON * j) {
100+ struct ReactionGroup * x = NULL;
101+ if (NULL != j) {
102+ if (NULL != (x = cJSON_malloc(sizeof(struct ReactionGroup)))) {
103+ memset(x, 0, sizeof(struct ReactionGroup));
104+ if (cJSON_HasObjectItem(j, "content")) {
105+ x->content = cJSON_GetReactionContentValue(cJSON_GetObjectItemCaseSensitive(j, "content"));
106+ }
107+ }
108+ }
109+ return x;
110+}
111+
112+cJSON * cJSON_CreateReactionGroup(const struct ReactionGroup * x) {
113+ cJSON * j = NULL;
114+ if (NULL != x) {
115+ if (NULL != (j = cJSON_CreateObject())) {
116+ cJSON_AddItemToObject(j, "content", cJSON_CreateReactionContent(x->content));
117+ }
118+ }
119+ return j;
120+}
121+
122+char * cJSON_PrintReactionGroup(const struct ReactionGroup * x) {
123+ char * s = NULL;
124+ if (NULL != x) {
125+ cJSON * j = cJSON_CreateReactionGroup(x);
126+ if (NULL != j) {
127+ s = cJSON_Print(j);
128+ cJSON_Delete(j);
129+ }
130+ }
131+ return s;
132+}
133+
134+void cJSON_DeleteReactionGroup(struct ReactionGroup * x) {
135+ if (NULL != x) {
136+ cJSON_free(x);
137+ }
138+}
139+
87140 struct Reactable * cJSON_ParseReactable(const char * s) {
88141 struct Reactable * x = NULL;
89142 if (NULL != s) {
@@ -110,7 +163,7 @@ struct Reactable * cJSON_GetReactableValue(const cJSON * j) {
110163 cJSON * e1 = NULL;
111164 cJSON * j1 = cJSON_GetObjectItemCaseSensitive(j, "reactionGroups");
112165 cJSON_ArrayForEach(e1, j1) {
113- list_add_tail(x1, cJSON_GetReactionValue(e1), sizeof(struct Reaction *));
166+ list_add_tail(x1, cJSON_GetReactionGroupValue(e1), sizeof(struct ReactionGroup *));
114167 }
115168 x->reaction_groups = x1;
116169 }
@@ -128,9 +181,9 @@ cJSON * cJSON_CreateReactable(const struct Reactable * x) {
128181 if (NULL != x->reaction_groups) {
129182 cJSON * j1 = cJSON_AddArrayToObject(j, "reactionGroups");
130183 if (NULL != j1) {
131- struct Reaction * x1 = list_get_head(x->reaction_groups);
184+ struct ReactionGroup * x1 = list_get_head(x->reaction_groups);
132185 while (NULL != x1) {
133- cJSON_AddItemToArray(j1, cJSON_CreateReaction(x1));
186+ cJSON_AddItemToArray(j1, cJSON_CreateReactionGroup(x1));
134187 x1 = list_get_next(x->reaction_groups);
135188 }
136189 }
@@ -158,9 +211,9 @@ char * cJSON_PrintReactable(const struct Reactable * x) {
158211 void cJSON_DeleteReactable(struct Reactable * x) {
159212 if (NULL != x) {
160213 if (NULL != x->reaction_groups) {
161- struct Reaction * x1 = list_get_head(x->reaction_groups);
214+ struct ReactionGroup * x1 = list_get_head(x->reaction_groups);
162215 while (NULL != x1) {
163- cJSON_DeleteReaction(x1);
216+ cJSON_DeleteReactionGroup(x1);
164217 x1 = list_get_next(x->reaction_groups);
165218 }
166219 list_release(x->reaction_groups);
Mgraphql-cjsondefault / TopLevel.h+10 −0
@@ -47,6 +47,10 @@ struct Reaction {
4747 enum ReactionContent content;
4848 };
4949
50+struct ReactionGroup {
51+ enum ReactionContent content;
52+};
53+
5054 struct Reactable {
5155 bool viewer_can_react;
5256 list_t * reaction_groups;
@@ -80,6 +84,12 @@ cJSON * cJSON_CreateReaction(const struct Reaction * x);
8084 char * cJSON_PrintReaction(const struct Reaction * x);
8185 void cJSON_DeleteReaction(struct Reaction * x);
8286
87+struct ReactionGroup * cJSON_ParseReactionGroup(const char * s);
88+struct ReactionGroup * cJSON_GetReactionGroupValue(const cJSON * j);
89+cJSON * cJSON_CreateReactionGroup(const struct ReactionGroup * x);
90+char * cJSON_PrintReactionGroup(const struct ReactionGroup * x);
91+void cJSON_DeleteReactionGroup(struct ReactionGroup * x);
92+
8393 struct Reactable * cJSON_ParseReactable(const char * s);
8494 struct Reactable * cJSON_GetReactableValue(const cJSON * j);
8595 cJSON * cJSON_CreateReactable(const struct Reactable * x);
Mgraphql-cplusplusdefault / quicktype.hpp+30 −4
@@ -104,6 +104,20 @@ namespace quicktype {
104104 void set_content(const ReactionContent & value) { this->content = value; }
105105 };
106106
107+ class ReactionGroup {
108+ public:
109+ ReactionGroup() = default;
110+ virtual ~ReactionGroup() = default;
111+
112+ private:
113+ ReactionContent content;
114+
115+ public:
116+ const ReactionContent & get_content() const { return content; }
117+ ReactionContent & get_mutable_content() { return content; }
118+ void set_content(const ReactionContent & value) { this->content = value; }
119+ };
120+
107121 class Reactable {
108122 public:
109123 Reactable() = default;
@@ -111,15 +125,15 @@ namespace quicktype {
111125
112126 private:
113127 bool viewer_can_react;
114- std::optional<std::vector<Reaction>> reaction_groups;
128+ std::optional<std::vector<ReactionGroup>> reaction_groups;
115129
116130 public:
117131 const bool & get_viewer_can_react() const { return viewer_can_react; }
118132 bool & get_mutable_viewer_can_react() { return viewer_can_react; }
119133 void set_viewer_can_react(const bool & value) { this->viewer_can_react = value; }
120134
121- std::optional<std::vector<Reaction>> get_reaction_groups() const { return reaction_groups; }
122- void set_reaction_groups(std::optional<std::vector<Reaction>> value) { this->reaction_groups = value; }
135+ std::optional<std::vector<ReactionGroup>> get_reaction_groups() const { return reaction_groups; }
136+ void set_reaction_groups(std::optional<std::vector<ReactionGroup>> value) { this->reaction_groups = value; }
123137 };
124138
125139 class AddReactionPayload {
@@ -195,6 +209,9 @@ namespace quicktype {
195209 void from_json(const json & j, Reaction & x);
196210 void to_json(json & j, const Reaction & x);
197211
212+ void from_json(const json & j, ReactionGroup & x);
213+ void to_json(json & j, const ReactionGroup & x);
214+
198215 void from_json(const json & j, Reactable & x);
199216 void to_json(json & j, const Reactable & x);
200217
@@ -222,9 +239,18 @@ namespace quicktype {
222239 j["content"] = x.get_content();
223240 }
224241
242+ inline void from_json(const json & j, ReactionGroup& x) {
243+ x.set_content(j.at("content").get<ReactionContent>());
244+ }
245+
246+ inline void to_json(json & j, const ReactionGroup & x) {
247+ j = json::object();
248+ j["content"] = x.get_content();
249+ }
250+
225251 inline void from_json(const json & j, Reactable& x) {
226252 x.set_viewer_can_react(j.at("viewerCanReact").get<bool>());
227- x.set_reaction_groups(get_stack_optional<std::vector<Reaction>>(j, "reactionGroups"));
253+ x.set_reaction_groups(get_stack_optional<std::vector<ReactionGroup>>(j, "reactionGroups"));
228254 }
229255
230256 inline void to_json(json & j, const Reactable & x) {
Mgraphql-csharpdefault / QuickType.cs+7 −1
@@ -62,7 +62,13 @@ namespace QuickType
6262 public bool ViewerCanReact { get; set; }
6363
6464 [JsonProperty("reactionGroups", Required = Required.AllowNull)]
65- public Reaction[]? ReactionGroups { get; set; }
65+ public ReactionGroup[]? ReactionGroups { get; set; }
66+ }
67+
68+ public partial class ReactionGroup
69+ {
70+ [JsonProperty("content", Required = Required.Always)]
71+ public ReactionContent Content { get; set; }
6672 }
6773
6874 public partial class Error
Mgraphql-dartdefault / TopLevel.dart+18 −2
@@ -104,7 +104,7 @@ final reactionContentValues = EnumValues({
104104
105105 class Reactable {
106106 final bool viewerCanReact;
107- final List<Reaction>? reactionGroups;
107+ final List<ReactionGroup>? reactionGroups;
108108
109109 Reactable({
110110 required this.viewerCanReact,
@@ -113,7 +113,7 @@ class Reactable {
113113
114114 factory Reactable.fromJson(Map<String, dynamic> json) => Reactable(
115115 viewerCanReact: json["viewerCanReact"],
116- reactionGroups: json["reactionGroups"] == null ? null : List<Reaction>.from(json["reactionGroups"]!.map((x) => Reaction.fromJson(x))),
116+ reactionGroups: json["reactionGroups"] == null ? null : List<ReactionGroup>.from(json["reactionGroups"]!.map((x) => ReactionGroup.fromJson(x))),
117117 );
118118
119119 Map<String, dynamic> toJson() => {
@@ -122,6 +122,22 @@ class Reactable {
122122 };
123123 }
124124
125+class ReactionGroup {
126+ final ReactionContent content;
127+
128+ ReactionGroup({
129+ required this.content,
130+ });
131+
132+ factory ReactionGroup.fromJson(Map<String, dynamic> json) => ReactionGroup(
133+ content: reactionContentValues.map[json["content"]]!,
134+ );
135+
136+ Map<String, dynamic> toJson() => {
137+ "content": reactionContentValues.reverse[content],
138+ };
139+}
140+
125141 class Error {
126142 final String message;
Mgraphql-elixirdefault / QuickType.ex+36 −3
@@ -88,19 +88,52 @@ defmodule Reaction do
8888 end
8989 end
9090
91+defmodule ReactionGroup do
92+ @enforce_keys [:content]
93+ defstruct [:content]
94+
95+ @type t :: %__MODULE__{
96+ content: ReactionContent.t()
97+ }
98+
99+ def from_map(m) do
100+ %ReactionGroup{
101+ content: ReactionContent.decode(m["content"]),
102+ }
103+ end
104+
105+ def from_json(json) do
106+ json
107+ |> Jason.decode!()
108+ |> from_map()
109+ end
110+
111+ def to_map(struct) do
112+ %{
113+ "content" => ReactionContent.encode(struct.content),
114+ }
115+ end
116+
117+ def to_json(struct) do
118+ struct
119+ |> to_map()
120+ |> Jason.encode!()
121+ end
122+end
123+
91124 defmodule Reactable do
92125 @enforce_keys [:viewer_can_react, :reaction_groups]
93126 defstruct [:viewer_can_react, :reaction_groups]
94127
95128 @type t :: %__MODULE__{
96129 viewer_can_react: boolean(),
97- reaction_groups: [Reaction.t()] | nil
130+ reaction_groups: [ReactionGroup.t()] | nil
98131 }
99132
100133 def from_map(m) do
101134 %Reactable{
102135 viewer_can_react: m["viewerCanReact"],
103- reaction_groups: m["reactionGroups"] && Enum.map(m["reactionGroups"], &Reaction.from_map/1),
136+ reaction_groups: m["reactionGroups"] && Enum.map(m["reactionGroups"], &ReactionGroup.from_map/1),
104137 }
105138 end
106139
@@ -113,7 +146,7 @@ defmodule Reactable do
113146 def to_map(struct) do
114147 %{
115148 "viewerCanReact" => struct.viewer_can_react,
116- "reactionGroups" => struct.reaction_groups && Enum.map(struct.reaction_groups, &Reaction.to_map/1),
149+ "reactionGroups" => struct.reaction_groups && Enum.map(struct.reaction_groups, &ReactionGroup.to_map/1),
117150 }
118151 end
Mgraphql-flowdefault / TopLevel.js+9 −2
@@ -38,7 +38,11 @@ export type ReactionContent =
3838
3939 export type Reactable = {
4040 viewerCanReact: boolean;
41- reactionGroups: Reaction[] | null;
41+ reactionGroups: ReactionGroup[] | null;
42+};
43+
44+export type ReactionGroup = {
45+ content: ReactionContent;
4246 };
4347
4448 export type ErrorElement = {
@@ -226,7 +230,10 @@ const typeMap: any = {
226230 ], false),
227231 "Reactable": o([
228232 { json: "viewerCanReact", js: "viewerCanReact", typ: true },
229- { json: "reactionGroups", js: "reactionGroups", typ: u(a(r("Reaction")), null) },
233+ { json: "reactionGroups", js: "reactionGroups", typ: u(a(r("ReactionGroup")), null) },
234+ ], false),
235+ "ReactionGroup": o([
236+ { json: "content", js: "content", typ: r("ReactionContent") },
230237 ], false),
231238 "ErrorElement": o([
232239 { json: "message", js: "message", typ: "" },
Mgraphql-golangdefault / quicktype.go+6 −2
@@ -38,8 +38,12 @@ type Reaction struct {
3838 }
3939
4040 type Reactable struct {
41- ViewerCanReact bool `json:"viewerCanReact"`
42- ReactionGroups []Reaction `json:"reactionGroups"`
41+ ViewerCanReact bool `json:"viewerCanReact"`
42+ ReactionGroups []ReactionGroup `json:"reactionGroups"`
43+}
44+
45+type ReactionGroup struct {
46+ Content ReactionContent `json:"content"`
4347 }
4448
4549 type Error struct {
Mgraphql-haskelldefault / QuickType.hs+16 −1
@@ -7,6 +7,7 @@ module QuickType
77 , AddReactionPayload (..)
88 , Reaction (..)
99 , Reactable (..)
10+ , ReactionGroup (..)
1011 , ErrorElement (..)
1112 , ReactionContent (..)
1213 , decodeTopLevel
@@ -48,7 +49,11 @@ data ReactionContent
4849
4950 data Reactable = Reactable
5051 { viewerCanReactReactable :: Bool
51- , reactionGroupsReactable :: Maybe ([Reaction])
52+ , reactionGroupsReactable :: Maybe ([ReactionGroup])
53+ } deriving (Show)
54+
55+data ReactionGroup = ReactionGroup
56+ { contentReactionGroup :: ReactionContent
5257 } deriving (Show)
5358
5459 data ErrorElement = ErrorElement
@@ -134,6 +139,16 @@ instance FromJSON Reactable where
134139 <$> v .: "viewerCanReact"
135140 <*> v .: "reactionGroups"
136141
142+instance ToJSON ReactionGroup where
143+ toJSON (ReactionGroup contentReactionGroup) =
144+ object
145+ [ "content" .= contentReactionGroup
146+ ]
147+
148+instance FromJSON ReactionGroup where
149+ parseJSON (Object v) = ReactionGroup
150+ <$> v .: "content"
151+
137152 instance ToJSON ErrorElement where
138153 toJSON (ErrorElement messageErrorElement) =
139154 object
Mgraphql-java-datetime-legacydefault / src / main / java / io / quicktype / Reactable.java+3 −3
@@ -5,7 +5,7 @@ import java.util.List;
55
66 public class Reactable {
77 private boolean viewerCanReact;
8- private List<Reaction> reactionGroups;
8+ private List<ReactionGroup> reactionGroups;
99
1010 @JsonProperty("viewerCanReact")
1111 public boolean getViewerCanReact() { return viewerCanReact; }
@@ -13,7 +13,7 @@ public class Reactable {
1313 public void setViewerCanReact(boolean value) { this.viewerCanReact = value; }
1414
1515 @JsonProperty("reactionGroups")
16- public List<Reaction> getReactionGroups() { return reactionGroups; }
16+ public List<ReactionGroup> getReactionGroups() { return reactionGroups; }
1717 @JsonProperty("reactionGroups")
18- public void setReactionGroups(List<Reaction> value) { this.reactionGroups = value; }
18+ public void setReactionGroups(List<ReactionGroup> value) { this.reactionGroups = value; }
1919 }
Agraphql-java-datetime-legacydefault / src / main / java / io / quicktype / ReactionGroup.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class ReactionGroup {
6+ private ReactionContent content;
7+
8+ @JsonProperty("content")
9+ public ReactionContent getContent() { return content; }
10+ @JsonProperty("content")
11+ public void setContent(ReactionContent value) { this.content = value; }
12+}
Mgraphql-java-lombokdefault / src / main / java / io / quicktype / Reactable.java+3 −3
@@ -5,7 +5,7 @@ import java.util.List;
55
66 public class Reactable {
77 private boolean viewerCanReact;
8- private List<Reaction> reactionGroups;
8+ private List<ReactionGroup> reactionGroups;
99
1010 @JsonProperty("viewerCanReact")
1111 public boolean getViewerCanReact() { return viewerCanReact; }
@@ -13,7 +13,7 @@ public class Reactable {
1313 public void setViewerCanReact(boolean value) { this.viewerCanReact = value; }
1414
1515 @JsonProperty("reactionGroups")
16- public List<Reaction> getReactionGroups() { return reactionGroups; }
16+ public List<ReactionGroup> getReactionGroups() { return reactionGroups; }
1717 @JsonProperty("reactionGroups")
18- public void setReactionGroups(List<Reaction> value) { this.reactionGroups = value; }
18+ public void setReactionGroups(List<ReactionGroup> value) { this.reactionGroups = value; }
1919 }
Agraphql-java-lombokdefault / src / main / java / io / quicktype / ReactionGroup.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class ReactionGroup {
6+ private ReactionContent content;
7+
8+ @JsonProperty("content")
9+ public ReactionContent getContent() { return content; }
10+ @JsonProperty("content")
11+ public void setContent(ReactionContent value) { this.content = value; }
12+}
Mgraphql-javadefault / src / main / java / io / quicktype / Reactable.java+3 −3
@@ -5,7 +5,7 @@ import java.util.List;
55
66 public class Reactable {
77 private boolean viewerCanReact;
8- private List<Reaction> reactionGroups;
8+ private List<ReactionGroup> reactionGroups;
99
1010 @JsonProperty("viewerCanReact")
1111 public boolean getViewerCanReact() { return viewerCanReact; }
@@ -13,7 +13,7 @@ public class Reactable {
1313 public void setViewerCanReact(boolean value) { this.viewerCanReact = value; }
1414
1515 @JsonProperty("reactionGroups")
16- public List<Reaction> getReactionGroups() { return reactionGroups; }
16+ public List<ReactionGroup> getReactionGroups() { return reactionGroups; }
1717 @JsonProperty("reactionGroups")
18- public void setReactionGroups(List<Reaction> value) { this.reactionGroups = value; }
18+ public void setReactionGroups(List<ReactionGroup> value) { this.reactionGroups = value; }
1919 }
Agraphql-javadefault / src / main / java / io / quicktype / ReactionGroup.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class ReactionGroup {
6+ private ReactionContent content;
7+
8+ @JsonProperty("content")
9+ public ReactionContent getContent() { return content; }
10+ @JsonProperty("content")
11+ public void setContent(ReactionContent value) { this.content = value; }
12+}
Mgraphql-javascriptdefault / TopLevel.js+4 −1
@@ -188,7 +188,10 @@ const typeMap = {
188188 ], false),
189189 "Reactable": o([
190190 { json: "viewerCanReact", js: "viewerCanReact", typ: true },
191- { json: "reactionGroups", js: "reactionGroups", typ: u(a(r("Reaction")), null) },
191+ { json: "reactionGroups", js: "reactionGroups", typ: u(a(r("ReactionGroup")), null) },
192+ ], false),
193+ "ReactionGroup": o([
194+ { json: "content", js: "content", typ: r("ReactionContent") },
192195 ], false),
193196 "Error": o([
194197 { json: "message", js: "message", typ: "" },
Mgraphql-objective-cdefault / QTTopLevel.h+6 −1
@@ -11,6 +11,7 @@
1111 @class QTReaction;
1212 @class QTReactionContent;
1313 @class QTReactable;
14+@class QTReactionGroup;
1415 @class QTError;
1516
1617 NS_ASSUME_NONNULL_BEGIN
@@ -63,7 +64,11 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding en
6364
6465 @interface QTReactable : NSObject
6566 @property (nonatomic, assign) BOOL isViewerCanReact;
66-@property (nonatomic, nullable, copy) NSArray<QTReaction *> *reactionGroups;
67+@property (nonatomic, nullable, copy) NSArray<QTReactionGroup *> *reactionGroups;
68+@end
69+
70+@interface QTReactionGroup : NSObject
71+@property (nonatomic, assign) QTReactionContent *content;
6772 @end
6873
6974 @interface QTError : NSObject
Mgraphql-objective-cdefault / QTTopLevel.m+53 −1
@@ -33,6 +33,11 @@ NS_ASSUME_NONNULL_BEGIN
3333 - (NSDictionary *)JSONDictionary;
3434 @end
3535
36+@interface QTReactionGroup (JSONConversion)
37++ (instancetype)fromJSONDictionary:(NSDictionary *)dict;
38+- (NSDictionary *)JSONDictionary;
39+@end
40+
3641 @interface QTError (JSONConversion)
3742 + (instancetype)fromJSONDictionary:(NSDictionary *)dict;
3843 - (NSDictionary *)JSONDictionary;
@@ -363,7 +368,7 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco
363368 {
364369 if (self = [super init]) {
365370 [self setValuesForKeysWithDictionary:dict];
366- _reactionGroups = map(_reactionGroups, λ(id x, [QTReaction fromJSONDictionary:x]));
371+ _reactionGroups = map(_reactionGroups, λ(id x, [QTReactionGroup fromJSONDictionary:x]));
367372 }
368373 return self;
369374 }
@@ -401,6 +406,53 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco
401406 }
402407 @end
403408
409+@implementation QTReactionGroup
410++ (NSDictionary<NSString *, NSString *> *)properties
411+{
412+ static NSDictionary<NSString *, NSString *> *properties;
413+ return properties = properties ? properties : @{
414+ @"content": @"content",
415+ };
416+}
417+
418++ (instancetype)fromJSONDictionary:(NSDictionary *)dict
419+{
420+ return dict ? [[QTReactionGroup alloc] initWithJSONDictionary:dict] : nil;
421+}
422+
423+- (instancetype)initWithJSONDictionary:(NSDictionary *)dict
424+{
425+ if (self = [super init]) {
426+ [self setValuesForKeysWithDictionary:dict];
427+ _content = [QTReactionContent withValue:(id)_content];
428+ }
429+ return self;
430+}
431+
432+- (void)setValue:(nullable id)value forKey:(NSString *)key
433+{
434+ id resolved = QTReactionGroup.properties[key];
435+ if (resolved) [super setValue:value forKey:resolved];
436+}
437+
438+- (void)setNilValueForKey:(NSString *)key
439+{
440+ id resolved = QTReactionGroup.properties[key];
441+ if (resolved) [super setValue:@(0) forKey:resolved];
442+}
443+
444+- (NSDictionary *)JSONDictionary
445+{
446+ id dict = [[self dictionaryWithValuesForKeys:QTReactionGroup.properties.allValues] mutableCopy];
447+
448+ [dict addEntriesFromDictionary:@{
449+ @"content": [_content value],
450+ }];
451+
452+ return dict;
453+}
454+@end
455+
404456 @implementation QTError
405457 + (NSDictionary<NSString *, NSString *> *)properties
406458 {
Mgraphql-phpdefault / TopLevel.php+101 −2
@@ -747,7 +747,7 @@ class Reactable {
747747 public static function fromReactionGroups(?array $value): ?array {
748748 if (!is_null($value)) {
749749 return array_map(function ($value) {
750- return Reaction::from($value); /*class*/
750+ return ReactionGroup::from($value); /*class*/
751751 }, $value);
752752 } else {
753753 return null;
@@ -804,7 +804,7 @@ class Reactable {
804804 */
805805 public static function sampleReactionGroups(): ?array {
806806 return array(
807- Reaction::sample() /*32:*/
807+ ReactionGroup::sample() /*32:*/
808808 ); /* 32:reactionGroups*/
809809 }
810810
@@ -851,6 +851,105 @@ class Reactable {
851851 }
852852 }
853853
854+// This is an autogenerated file:ReactionGroup
855+
856+class ReactionGroup {
857+ private ReactionContent $content; // json:content Required
858+
859+ /**
860+ * @param ReactionContent $content
861+ */
862+ public function __construct(ReactionContent $content) {
863+ $this->content = $content;
864+ }
865+
866+ /**
867+ * @param string $value
868+ * @throws Exception
869+ * @return ReactionContent
870+ */
871+ public static function fromContent(string $value): ReactionContent {
872+ return ReactionContent::from($value); /*enum*/
873+ }
874+
875+ /**
876+ * @throws Exception
877+ * @return string
878+ */
879+ public function toContent(): string {
880+ if (ReactionGroup::validateContent($this->content)) {
881+ return ReactionContent::to($this->content); /*enum*/
882+ }
883+ throw new Exception('never get to this ReactionGroup::content');
884+ }
885+
886+ /**
887+ * @param ReactionContent
888+ * @return bool
889+ * @throws Exception
890+ */
891+ public static function validateContent(ReactionContent $value): bool {
892+ ReactionContent::to($value);
893+ return true;
894+ }
895+
896+ /**
897+ * @throws Exception
898+ * @return ReactionContent
899+ */
900+ public function getContent(): ReactionContent {
901+ if (ReactionGroup::validateContent($this->content)) {
902+ return $this->content;
903+ }
904+ throw new Exception('never get to getContent ReactionGroup::content');
905+ }
906+
907+ /**
908+ * @return ReactionContent
909+ */
910+ public static function sampleContent(): ReactionContent {
911+ return ReactionContent::sample(); /*enum*/
912+ }
913+
914+ /**
915+ * @throws Exception
916+ * @return bool
917+ */
918+ public function validate(): bool {
919+ return ReactionGroup::validateContent($this->content);
920+ }
921+
922+ /**
923+ * @return stdClass
924+ * @throws Exception
925+ */
926+ public function to(): stdClass {
927+ $out = new stdClass();
928+ $out->{'content'} = $this->toContent();
929+ return $out;
930+ }
931+
932+ /**
933+ * @param stdClass $obj
934+ * @return ReactionGroup
935+ * @throws Exception
936+ */
937+ public static function from(stdClass $obj): ReactionGroup {
938+ return new ReactionGroup(
939+ ReactionGroup::fromContent($obj->{'content'})
940+ );
941+ }
942+
943+ /**
944+ * @return ReactionGroup
945+ */
946+ public static function sample(): ReactionGroup {
947+ return new ReactionGroup(
948+ ReactionGroup::sampleContent()
949+ );
950+ }
951+}
952+
854953 // This is an autogenerated file:Error
855954
856955 class Error {
Mgraphql-pikedefault / TopLevel.pmod+22 −2
@@ -111,8 +111,8 @@ enum ReactionContent {
111111 }
112112
113113 class Reactable {
114- bool viewer_can_react; // json: "viewerCanReact"
115- array(Reaction)|mixed reaction_groups; // json: "reactionGroups"
114+ bool viewer_can_react; // json: "viewerCanReact"
115+ array(ReactionGroup)|mixed reaction_groups; // json: "reactionGroups"
116116
117117 string encode_json() {
118118 mapping(string:mixed) json = ([
@@ -133,6 +133,26 @@ Reactable Reactable_from_JSON(mixed json) {
133133 return retval;
134134 }
135135
136+class ReactionGroup {
137+ ReactionContent content; // json: "content"
138+
139+ string encode_json() {
140+ mapping(string:mixed) json = ([
141+ "content" : content,
142+ ]);
143+
144+ return Standards.JSON.encode(json);
145+ }
146+}
147+
148+ReactionGroup ReactionGroup_from_JSON(mixed json) {
149+ ReactionGroup retval = ReactionGroup();
150+
151+ retval.content = json["content"];
152+
153+ return retval;
154+}
155+
136156 class Error {
137157 string message; // json: "message"
Mgraphql-pythondefault / quicktype.py+19 −3
@@ -71,22 +71,38 @@ class Reaction:
7171 return result
7272
7373
74+@dataclass
75+class ReactionGroup:
76+ content: ReactionContent
77+
78+ @staticmethod
79+ def from_dict(obj: Any) -> 'ReactionGroup':
80+ assert isinstance(obj, dict)
81+ content = ReactionContent(obj.get("content"))
82+ return ReactionGroup(content)
83+
84+ def to_dict(self) -> dict:
85+ result: dict = {}
86+ result["content"] = to_enum(ReactionContent, self.content)
87+ return result
88+
89+
7490 @dataclass
7591 class Reactable:
7692 viewer_can_react: bool
77- reaction_groups: list[Reaction] | None = None
93+ reaction_groups: list[ReactionGroup] | None = None
7894
7995 @staticmethod
8096 def from_dict(obj: Any) -> 'Reactable':
8197 assert isinstance(obj, dict)
8298 viewer_can_react = from_bool(obj.get("viewerCanReact"))
83- reaction_groups = from_union([lambda x: from_list(Reaction.from_dict, x), from_none], obj.get("reactionGroups"))
99+ reaction_groups = from_union([lambda x: from_list(ReactionGroup.from_dict, x), from_none], obj.get("reactionGroups"))
84100 return Reactable(viewer_can_react, reaction_groups)
85101
86102 def to_dict(self) -> dict:
87103 result: dict = {}
88104 result["viewerCanReact"] = from_bool(self.viewer_can_react)
89- result["reactionGroups"] = from_union([lambda x: from_list(lambda x: to_class(Reaction, x), x), from_none], self.reaction_groups)
105+ result["reactionGroups"] = from_union([lambda x: from_list(lambda x: to_class(ReactionGroup, x), x), from_none], self.reaction_groups)
90106 return result
Mgraphql-swiftdefault / quicktype.swift+46 −2
@@ -205,7 +205,7 @@ enum ReactionContent: String, Codable {
205205 // MARK: - Reactable
206206 struct Reactable: Codable {
207207 let viewerCanReact: Bool
208- let reactionGroups: [Reaction]?
208+ let reactionGroups: [ReactionGroup]?
209209
210210 enum CodingKeys: String, CodingKey {
211211 case viewerCanReact = "viewerCanReact"
@@ -233,7 +233,7 @@ extension Reactable {
233233
234234 func with(
235235 viewerCanReact: Bool? = nil,
236- reactionGroups: [Reaction]?? = nil
236+ reactionGroups: [ReactionGroup]?? = nil
237237 ) -> Reactable {
238238 return Reactable(
239239 viewerCanReact: viewerCanReact ?? self.viewerCanReact,
@@ -250,6 +250,50 @@ extension Reactable {
250250 }
251251 }
252252
253+// MARK: - ReactionGroup
254+struct ReactionGroup: Codable {
255+ let content: ReactionContent
256+
257+ enum CodingKeys: String, CodingKey {
258+ case content = "content"
259+ }
260+}
261+
262+// MARK: ReactionGroup convenience initializers and mutators
263+
264+extension ReactionGroup {
265+ init(data: Data) throws {
266+ self = try newJSONDecoder().decode(ReactionGroup.self, from: data)
267+ }
268+
269+ init(_ json: String, using encoding: String.Encoding = .utf8) throws {
270+ guard let data = json.data(using: encoding) else {
271+ throw NSError(domain: "JSONDecoding", code: 0, userInfo: nil)
272+ }
273+ try self.init(data: data)
274+ }
275+
276+ init(fromURL url: URL) throws {
277+ try self.init(data: try Data(contentsOf: url))
278+ }
279+
280+ func with(
281+ content: ReactionContent? = nil
282+ ) -> ReactionGroup {
283+ return ReactionGroup(
284+ content: content ?? self.content
285+ )
286+ }
287+
288+ func jsonData() throws -> Data {
289+ return try newJSONEncoder().encode(self)
290+ }
291+
292+ func jsonString(encoding: String.Encoding = .utf8) throws -> String? {
293+ return String(data: try self.jsonData(), encoding: encoding)
294+ }
295+}
296+
253297 // MARK: - Error
254298 struct Error: Codable {
255299 let message: String
Mgraphql-typescriptdefault / TopLevel.ts+9 −2
@@ -30,7 +30,11 @@ export type ReactionContent = "THUMBS_UP" | "THUMBS_DOWN" | "LAUGH" | "HOORAY" |
3030
3131 export interface Reactable {
3232 viewerCanReact: boolean;
33- reactionGroups: Reaction[] | null;
33+ reactionGroups: ReactionGroup[] | null;
34+}
35+
36+export interface ReactionGroup {
37+ content: ReactionContent;
3438 }
3539
3640 export interface Error {
@@ -220,7 +224,10 @@ const typeMap: any = {
220224 ], false),
221225 "Reactable": o([
222226 { json: "viewerCanReact", js: "viewerCanReact", typ: true },
223- { json: "reactionGroups", js: "reactionGroups", typ: u(a(r("Reaction")), null) },
227+ { json: "reactionGroups", js: "reactionGroups", typ: u(a(r("ReactionGroup")), null) },
228+ ], false),
229+ "ReactionGroup": o([
230+ { json: "content", js: "content", typ: r("ReactionContent") },
224231 ], false),
225232 "Error": o([
226233 { json: "message", js: "message", typ: "" },
Test case

test/inputs/graphql/separate-types1.graphql

41 generated files · +5,009 −0
Agraphql-cjsondefault / TopLevel.c+543 −0
@@ -0,0 +1,543 @@
1+/**
2+ * TopLevel.c
3+ * This file has been autogenerated using quicktype https://github.com/quicktype/quicktype - DO NOT EDIT
4+ */
5+
6+#include "TopLevel.h"
7+
8+struct ComponentRef * cJSON_ParseComponentRef(const char * s) {
9+ struct ComponentRef * x = NULL;
10+ if (NULL != s) {
11+ cJSON * j = cJSON_Parse(s);
12+ if (NULL != j) {
13+ x = cJSON_GetComponentRefValue(j);
14+ cJSON_Delete(j);
15+ }
16+ }
17+ return x;
18+}
19+
20+struct ComponentRef * cJSON_GetComponentRefValue(const cJSON * j) {
21+ struct ComponentRef * x = NULL;
22+ if (NULL != j) {
23+ if (NULL != (x = cJSON_malloc(sizeof(struct ComponentRef)))) {
24+ memset(x, 0, sizeof(struct ComponentRef));
25+ if ((cJSON_HasObjectItem(j, "id")) && (!cJSON_IsNull(cJSON_GetObjectItemCaseSensitive(j, "id")))) {
26+ x->id = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "id")));
27+ }
28+ }
29+ }
30+ return x;
31+}
32+
33+cJSON * cJSON_CreateComponentRef(const struct ComponentRef * x) {
34+ cJSON * j = NULL;
35+ if (NULL != x) {
36+ if (NULL != (j = cJSON_CreateObject())) {
37+ if (NULL != x->id) {
38+ cJSON_AddStringToObject(j, "id", x->id);
39+ }
40+ else {
41+ cJSON_AddNullToObject(j, "id");
42+ }
43+ }
44+ }
45+ return j;
46+}
47+
48+char * cJSON_PrintComponentRef(const struct ComponentRef * x) {
49+ char * s = NULL;
50+ if (NULL != x) {
51+ cJSON * j = cJSON_CreateComponentRef(x);
52+ if (NULL != j) {
53+ s = cJSON_Print(j);
54+ cJSON_Delete(j);
55+ }
56+ }
57+ return s;
58+}
59+
60+void cJSON_DeleteComponentRef(struct ComponentRef * x) {
61+ if (NULL != x) {
62+ if (NULL != x->id) {
63+ cJSON_free(x->id);
64+ }
65+ cJSON_free(x);
66+ }
67+}
68+
69+struct GridConfig * cJSON_ParseGridConfig(const char * s) {
70+ struct GridConfig * x = NULL;
71+ if (NULL != s) {
72+ cJSON * j = cJSON_Parse(s);
73+ if (NULL != j) {
74+ x = cJSON_GetGridConfigValue(j);
75+ cJSON_Delete(j);
76+ }
77+ }
78+ return x;
79+}
80+
81+struct GridConfig * cJSON_GetGridConfigValue(const cJSON * j) {
82+ struct GridConfig * x = NULL;
83+ if (NULL != j) {
84+ if (NULL != (x = cJSON_malloc(sizeof(struct GridConfig)))) {
85+ memset(x, 0, sizeof(struct GridConfig));
86+ if ((cJSON_HasObjectItem(j, "items")) && (!cJSON_IsNull(cJSON_GetObjectItemCaseSensitive(j, "items")))) {
87+ list_t * x1 = list_create(false, NULL);
88+ if (NULL != x1) {
89+ cJSON * e1 = NULL;
90+ cJSON * j1 = cJSON_GetObjectItemCaseSensitive(j, "items");
91+ cJSON_ArrayForEach(e1, j1) {
92+ if (!cJSON_IsNull(e1)) {
93+ list_add_tail(x1, cJSON_GetComponentRefValue(e1), sizeof(struct ComponentRef *));
94+ }
95+ else {
96+ list_add_tail(x1, (void *)0xDEADBEEF, sizeof(void *));
97+ }
98+ }
99+ x->items = x1;
100+ }
101+ }
102+ }
103+ }
104+ return x;
105+}
106+
107+cJSON * cJSON_CreateGridConfig(const struct GridConfig * x) {
108+ cJSON * j = NULL;
109+ if (NULL != x) {
110+ if (NULL != (j = cJSON_CreateObject())) {
111+ if (NULL != x->items) {
112+ cJSON * j1 = cJSON_AddArrayToObject(j, "items");
113+ if (NULL != j1) {
114+ struct ComponentRef * x1 = list_get_head(x->items);
115+ while (NULL != x1) {
116+ if ((void *)0xDEADBEEF != x1) {
117+ cJSON_AddItemToArray(j1, cJSON_CreateComponentRef(x1));
118+ }
119+ else {
120+ cJSON_AddItemToArray(j1, cJSON_CreateNull());
121+ }
122+ x1 = list_get_next(x->items);
123+ }
124+ }
125+ }
126+ else {
127+ cJSON_AddNullToObject(j, "items");
128+ }
129+ }
130+ }
131+ return j;
132+}
133+
134+char * cJSON_PrintGridConfig(const struct GridConfig * x) {
135+ char * s = NULL;
136+ if (NULL != x) {
137+ cJSON * j = cJSON_CreateGridConfig(x);
138+ if (NULL != j) {
139+ s = cJSON_Print(j);
140+ cJSON_Delete(j);
141+ }
142+ }
143+ return s;
144+}
145+
146+void cJSON_DeleteGridConfig(struct GridConfig * x) {
147+ if (NULL != x) {
148+ if (NULL != x->items) {
149+ struct ComponentRef * x1 = list_get_head(x->items);
150+ while (NULL != x1) {
151+ if ((void *)0xDEADBEEF != x1) {
152+ cJSON_DeleteComponentRef(x1);
153+ }
154+ x1 = list_get_next(x->items);
155+ }
156+ list_release(x->items);
157+ }
158+ cJSON_free(x);
159+ }
160+}
161+
162+struct GridProps * cJSON_ParseGridProps(const char * s) {
163+ struct GridProps * x = NULL;
164+ if (NULL != s) {
165+ cJSON * j = cJSON_Parse(s);
166+ if (NULL != j) {
167+ x = cJSON_GetGridPropsValue(j);
168+ cJSON_Delete(j);
169+ }
170+ }
171+ return x;
172+}
173+
174+struct GridProps * cJSON_GetGridPropsValue(const cJSON * j) {
175+ struct GridProps * x = NULL;
176+ if (NULL != j) {
177+ if (NULL != (x = cJSON_malloc(sizeof(struct GridProps)))) {
178+ memset(x, 0, sizeof(struct GridProps));
179+ if ((cJSON_HasObjectItem(j, "items")) && (!cJSON_IsNull(cJSON_GetObjectItemCaseSensitive(j, "items")))) {
180+ list_t * x1 = list_create(false, NULL);
181+ if (NULL != x1) {
182+ cJSON * e1 = NULL;
183+ cJSON * j1 = cJSON_GetObjectItemCaseSensitive(j, "items");
184+ cJSON_ArrayForEach(e1, j1) {
185+ if (!cJSON_IsNull(e1)) {
186+ list_add_tail(x1, cJSON_GetComponentRefValue(e1), sizeof(struct ComponentRef *));
187+ }
188+ else {
189+ list_add_tail(x1, (void *)0xDEADBEEF, sizeof(void *));
190+ }
191+ }
192+ x->items = x1;
193+ }
194+ }
195+ }
196+ }
197+ return x;
198+}
199+
200+cJSON * cJSON_CreateGridProps(const struct GridProps * x) {
201+ cJSON * j = NULL;
202+ if (NULL != x) {
203+ if (NULL != (j = cJSON_CreateObject())) {
204+ if (NULL != x->items) {
205+ cJSON * j1 = cJSON_AddArrayToObject(j, "items");
206+ if (NULL != j1) {
207+ struct ComponentRef * x1 = list_get_head(x->items);
208+ while (NULL != x1) {
209+ if ((void *)0xDEADBEEF != x1) {
210+ cJSON_AddItemToArray(j1, cJSON_CreateComponentRef(x1));
211+ }
212+ else {
213+ cJSON_AddItemToArray(j1, cJSON_CreateNull());
214+ }
215+ x1 = list_get_next(x->items);
216+ }
217+ }
218+ }
219+ else {
220+ cJSON_AddNullToObject(j, "items");
221+ }
222+ }
223+ }
224+ return j;
225+}
226+
227+char * cJSON_PrintGridProps(const struct GridProps * x) {
228+ char * s = NULL;
229+ if (NULL != x) {
230+ cJSON * j = cJSON_CreateGridProps(x);
231+ if (NULL != j) {
232+ s = cJSON_Print(j);
233+ cJSON_Delete(j);
234+ }
235+ }
236+ return s;
237+}
238+
239+void cJSON_DeleteGridProps(struct GridProps * x) {
240+ if (NULL != x) {
241+ if (NULL != x->items) {
242+ struct ComponentRef * x1 = list_get_head(x->items);
243+ while (NULL != x1) {
244+ if ((void *)0xDEADBEEF != x1) {
245+ cJSON_DeleteComponentRef(x1);
246+ }
247+ x1 = list_get_next(x->items);
248+ }
249+ list_release(x->items);
250+ }
251+ cJSON_free(x);
252+ }
253+}
254+
255+struct Grid * cJSON_ParseGrid(const char * s) {
256+ struct Grid * x = NULL;
257+ if (NULL != s) {
258+ cJSON * j = cJSON_Parse(s);
259+ if (NULL != j) {
260+ x = cJSON_GetGridValue(j);
261+ cJSON_Delete(j);
262+ }
263+ }
264+ return x;
265+}
266+
267+struct Grid * cJSON_GetGridValue(const cJSON * j) {
268+ struct Grid * x = NULL;
269+ if (NULL != j) {
270+ if (NULL != (x = cJSON_malloc(sizeof(struct Grid)))) {
271+ memset(x, 0, sizeof(struct Grid));
272+ if ((cJSON_HasObjectItem(j, "config")) && (!cJSON_IsNull(cJSON_GetObjectItemCaseSensitive(j, "config")))) {
273+ x->config = cJSON_GetGridConfigValue(cJSON_GetObjectItemCaseSensitive(j, "config"));
274+ }
275+ if ((cJSON_HasObjectItem(j, "props")) && (!cJSON_IsNull(cJSON_GetObjectItemCaseSensitive(j, "props")))) {
276+ x->props = cJSON_GetGridPropsValue(cJSON_GetObjectItemCaseSensitive(j, "props"));
277+ }
278+ }
279+ }
280+ return x;
281+}
282+
283+cJSON * cJSON_CreateGrid(const struct Grid * x) {
284+ cJSON * j = NULL;
285+ if (NULL != x) {
286+ if (NULL != (j = cJSON_CreateObject())) {
287+ if (NULL != x->config) {
288+ cJSON_AddItemToObject(j, "config", cJSON_CreateGridConfig(x->config));
289+ }
290+ else {
291+ cJSON_AddNullToObject(j, "config");
292+ }
293+ if (NULL != x->props) {
294+ cJSON_AddItemToObject(j, "props", cJSON_CreateGridProps(x->props));
295+ }
296+ else {
297+ cJSON_AddNullToObject(j, "props");
298+ }
299+ }
300+ }
301+ return j;
302+}
303+
304+char * cJSON_PrintGrid(const struct Grid * x) {
305+ char * s = NULL;
306+ if (NULL != x) {
307+ cJSON * j = cJSON_CreateGrid(x);
308+ if (NULL != j) {
309+ s = cJSON_Print(j);
310+ cJSON_Delete(j);
311+ }
312+ }
313+ return s;
314+}
315+
316+void cJSON_DeleteGrid(struct Grid * x) {
317+ if (NULL != x) {
318+ if (NULL != x->config) {
319+ cJSON_DeleteGridConfig(x->config);
320+ }
321+ if (NULL != x->props) {
322+ cJSON_DeleteGridProps(x->props);
323+ }
324+ cJSON_free(x);
325+ }
326+}
327+
328+struct Data * cJSON_ParseData(const char * s) {
329+ struct Data * x = NULL;
330+ if (NULL != s) {
331+ cJSON * j = cJSON_Parse(s);
332+ if (NULL != j) {
333+ x = cJSON_GetDataValue(j);
334+ cJSON_Delete(j);
335+ }
336+ }
337+ return x;
338+}
339+
340+struct Data * cJSON_GetDataValue(const cJSON * j) {
341+ struct Data * x = NULL;
342+ if (NULL != j) {
343+ if (NULL != (x = cJSON_malloc(sizeof(struct Data)))) {
344+ memset(x, 0, sizeof(struct Data));
345+ if ((cJSON_HasObjectItem(j, "grid")) && (!cJSON_IsNull(cJSON_GetObjectItemCaseSensitive(j, "grid")))) {
346+ x->grid = cJSON_GetGridValue(cJSON_GetObjectItemCaseSensitive(j, "grid"));
347+ }
348+ }
349+ }
350+ return x;
351+}
352+
353+cJSON * cJSON_CreateData(const struct Data * x) {
354+ cJSON * j = NULL;
355+ if (NULL != x) {
356+ if (NULL != (j = cJSON_CreateObject())) {
357+ if (NULL != x->grid) {
358+ cJSON_AddItemToObject(j, "grid", cJSON_CreateGrid(x->grid));
359+ }
360+ else {
361+ cJSON_AddNullToObject(j, "grid");
362+ }
363+ }
364+ }
365+ return j;
366+}
367+
368+char * cJSON_PrintData(const struct Data * x) {
369+ char * s = NULL;
370+ if (NULL != x) {
371+ cJSON * j = cJSON_CreateData(x);
372+ if (NULL != j) {
373+ s = cJSON_Print(j);
374+ cJSON_Delete(j);
375+ }
376+ }
377+ return s;
378+}
379+
380+void cJSON_DeleteData(struct Data * x) {
381+ if (NULL != x) {
382+ if (NULL != x->grid) {
383+ cJSON_DeleteGrid(x->grid);
384+ }
385+ cJSON_free(x);
386+ }
387+}
388+
389+struct Error * cJSON_ParseError(const char * s) {
390+ struct Error * x = NULL;
391+ if (NULL != s) {
392+ cJSON * j = cJSON_Parse(s);
393+ if (NULL != j) {
394+ x = cJSON_GetErrorValue(j);
395+ cJSON_Delete(j);
396+ }
397+ }
398+ return x;
399+}
400+
401+struct Error * cJSON_GetErrorValue(const cJSON * j) {
402+ struct Error * x = NULL;
403+ if (NULL != j) {
404+ if (NULL != (x = cJSON_malloc(sizeof(struct Error)))) {
405+ memset(x, 0, sizeof(struct Error));
406+ if (cJSON_HasObjectItem(j, "message")) {
407+ x->message = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "message")));
408+ }
409+ else {
410+ if (NULL != (x->message = cJSON_malloc(sizeof(char)))) {
411+ x->message[0] = '\0';
412+ }
413+ }
414+ }
415+ }
416+ return x;
417+}
418+
419+cJSON * cJSON_CreateError(const struct Error * x) {
420+ cJSON * j = NULL;
421+ if (NULL != x) {
422+ if (NULL != (j = cJSON_CreateObject())) {
423+ if (NULL != x->message) {
424+ cJSON_AddStringToObject(j, "message", x->message);
425+ }
426+ else {
427+ cJSON_AddStringToObject(j, "message", "");
428+ }
429+ }
430+ }
431+ return j;
432+}
433+
434+char * cJSON_PrintError(const struct Error * x) {
435+ char * s = NULL;
436+ if (NULL != x) {
437+ cJSON * j = cJSON_CreateError(x);
438+ if (NULL != j) {
439+ s = cJSON_Print(j);
440+ cJSON_Delete(j);
441+ }
442+ }
443+ return s;
444+}
445+
446+void cJSON_DeleteError(struct Error * x) {
447+ if (NULL != x) {
448+ if (NULL != x->message) {
449+ cJSON_free(x->message);
450+ }
451+ cJSON_free(x);
452+ }
453+}
454+
455+struct TopLevel * cJSON_ParseTopLevel(const char * s) {
456+ struct TopLevel * x = NULL;
457+ if (NULL != s) {
458+ cJSON * j = cJSON_Parse(s);
459+ if (NULL != j) {
460+ x = cJSON_GetTopLevelValue(j);
461+ cJSON_Delete(j);
462+ }
463+ }
464+ return x;
465+}
466+
467+struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
468+ struct TopLevel * x = NULL;
469+ if (NULL != j) {
470+ if (NULL != (x = cJSON_malloc(sizeof(struct TopLevel)))) {
471+ memset(x, 0, sizeof(struct TopLevel));
472+ if ((cJSON_HasObjectItem(j, "data")) && (!cJSON_IsNull(cJSON_GetObjectItemCaseSensitive(j, "data")))) {
473+ x->data = cJSON_GetDataValue(cJSON_GetObjectItemCaseSensitive(j, "data"));
474+ }
475+ if (cJSON_HasObjectItem(j, "errors")) {
476+ list_t * x1 = list_create(false, NULL);
477+ if (NULL != x1) {
478+ cJSON * e1 = NULL;
479+ cJSON * j1 = cJSON_GetObjectItemCaseSensitive(j, "errors");
480+ cJSON_ArrayForEach(e1, j1) {
481+ list_add_tail(x1, cJSON_GetErrorValue(e1), sizeof(struct Error *));
482+ }
483+ x->errors = x1;
484+ }
485+ }
486+ }
487+ }
488+ return x;
489+}
490+
491+cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
492+ cJSON * j = NULL;
493+ if (NULL != x) {
494+ if (NULL != (j = cJSON_CreateObject())) {
495+ if (NULL != x->data) {
496+ cJSON_AddItemToObject(j, "data", cJSON_CreateData(x->data));
497+ }
498+ else {
499+ cJSON_AddNullToObject(j, "data");
500+ }
501+ if (NULL != x->errors) {
502+ cJSON * j1 = cJSON_AddArrayToObject(j, "errors");
503+ if (NULL != j1) {
504+ struct Error * x1 = list_get_head(x->errors);
505+ while (NULL != x1) {
506+ cJSON_AddItemToArray(j1, cJSON_CreateError(x1));
507+ x1 = list_get_next(x->errors);
508+ }
509+ }
510+ }
511+ }
512+ }
513+ return j;
514+}
515+
516+char * cJSON_PrintTopLevel(const struct TopLevel * x) {
517+ char * s = NULL;
518+ if (NULL != x) {
519+ cJSON * j = cJSON_CreateTopLevel(x);
520+ if (NULL != j) {
521+ s = cJSON_Print(j);
522+ cJSON_Delete(j);
523+ }
524+ }
525+ return s;
526+}
527+
528+void cJSON_DeleteTopLevel(struct TopLevel * x) {
529+ if (NULL != x) {
530+ if (NULL != x->data) {
531+ cJSON_DeleteData(x->data);
532+ }
533+ if (NULL != x->errors) {
534+ struct Error * x1 = list_get_head(x->errors);
535+ while (NULL != x1) {
536+ cJSON_DeleteError(x1);
537+ x1 = list_get_next(x->errors);
538+ }
539+ list_release(x->errors);
540+ }
541+ cJSON_free(x);
542+ }
543+}
Agraphql-cjsondefault / TopLevel.h+113 −0
@@ -0,0 +1,113 @@
1+/**
2+ * TopLevel.h
3+ * This file has been autogenerated using quicktype https://github.com/quicktype/quicktype - DO NOT EDIT
4+ * This file depends of https://github.com/DaveGamble/cJSON, https://github.com/joelguittet/c-list and https://github.com/joelguittet/c-hashtable
5+ * To parse json data from json string use the following: struct <type> * data = cJSON_Parse<type>(<string>);
6+ * To get json data from cJSON object use the following: struct <type> * data = cJSON_Get<type>Value(<cjson>);
7+ * To get cJSON object from json data use the following: cJSON * cjson = cJSON_Create<type>(<data>);
8+ * To print json string from json data use the following: char * string = cJSON_Print<type>(<data>);
9+ * To delete json data use the following: cJSON_Delete<type>(<data>);
10+ */
11+
12+#ifndef __TOPLEVEL_H__
13+#define __TOPLEVEL_H__
14+
15+#ifdef __cplusplus
16+extern "C" {
17+#endif
18+
19+#include <stdint.h>
20+#include <stdbool.h>
21+#include <stdlib.h>
22+#include <string.h>
23+#include <cJSON.h>
24+#include <hashtable.h>
25+#include <list.h>
26+
27+#ifndef cJSON_Bool
28+#define cJSON_Bool (cJSON_True | cJSON_False)
29+#endif
30+#ifndef cJSON_Map
31+#define cJSON_Map (1 << 16)
32+#endif
33+#ifndef cJSON_Enum
34+#define cJSON_Enum (1 << 17)
35+#endif
36+
37+struct ComponentRef {
38+ char * id;
39+};
40+
41+struct GridConfig {
42+ list_t * items;
43+};
44+
45+struct GridProps {
46+ list_t * items;
47+};
48+
49+struct Grid {
50+ struct GridConfig * config;
51+ struct GridProps * props;
52+};
53+
54+struct Data {
55+ struct Grid * grid;
56+};
57+
58+struct Error {
59+ char * message;
60+};
61+
62+struct TopLevel {
63+ struct Data * data;
64+ list_t * errors;
65+};
66+
67+struct ComponentRef * cJSON_ParseComponentRef(const char * s);
68+struct ComponentRef * cJSON_GetComponentRefValue(const cJSON * j);
69+cJSON * cJSON_CreateComponentRef(const struct ComponentRef * x);
70+char * cJSON_PrintComponentRef(const struct ComponentRef * x);
71+void cJSON_DeleteComponentRef(struct ComponentRef * x);
72+
73+struct GridConfig * cJSON_ParseGridConfig(const char * s);
74+struct GridConfig * cJSON_GetGridConfigValue(const cJSON * j);
75+cJSON * cJSON_CreateGridConfig(const struct GridConfig * x);
76+char * cJSON_PrintGridConfig(const struct GridConfig * x);
77+void cJSON_DeleteGridConfig(struct GridConfig * x);
78+
79+struct GridProps * cJSON_ParseGridProps(const char * s);
80+struct GridProps * cJSON_GetGridPropsValue(const cJSON * j);
81+cJSON * cJSON_CreateGridProps(const struct GridProps * x);
82+char * cJSON_PrintGridProps(const struct GridProps * x);
83+void cJSON_DeleteGridProps(struct GridProps * x);
84+
85+struct Grid * cJSON_ParseGrid(const char * s);
86+struct Grid * cJSON_GetGridValue(const cJSON * j);
87+cJSON * cJSON_CreateGrid(const struct Grid * x);
88+char * cJSON_PrintGrid(const struct Grid * x);
89+void cJSON_DeleteGrid(struct Grid * x);
90+
91+struct Data * cJSON_ParseData(const char * s);
92+struct Data * cJSON_GetDataValue(const cJSON * j);
93+cJSON * cJSON_CreateData(const struct Data * x);
94+char * cJSON_PrintData(const struct Data * x);
95+void cJSON_DeleteData(struct Data * x);
96+
97+struct Error * cJSON_ParseError(const char * s);
98+struct Error * cJSON_GetErrorValue(const cJSON * j);
99+cJSON * cJSON_CreateError(const struct Error * x);
100+char * cJSON_PrintError(const struct Error * x);
101+void cJSON_DeleteError(struct Error * x);
102+
103+struct TopLevel * cJSON_ParseTopLevel(const char * s);
104+struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j);
105+cJSON * cJSON_CreateTopLevel(const struct TopLevel * x);
106+char * cJSON_PrintTopLevel(const struct TopLevel * x);
107+void cJSON_DeleteTopLevel(struct TopLevel * x);
108+
109+#ifdef __cplusplus
110+}
111+#endif
112+
113+#endif /* __TOPLEVEL_H__ */
Agraphql-cplusplusdefault / quicktype.hpp+281 −0
@@ -0,0 +1,281 @@
1+// To parse this JSON data, first install
2+//
3+// json.hpp https://github.com/nlohmann/json
4+//
5+// Then include this file, and then do
6+//
7+// TopLevel data = nlohmann::json::parse(jsonString);
8+
9+#pragma once
10+
11+#include <optional>
12+#include "json.hpp"
13+
14+#include <optional>
15+#include <stdexcept>
16+#include <regex>
17+
18+#ifndef NLOHMANN_OPT_HELPER
19+#define NLOHMANN_OPT_HELPER
20+namespace nlohmann {
21+ template <typename T>
22+ struct adl_serializer<std::shared_ptr<T>> {
23+ static void to_json(json & j, const std::shared_ptr<T> & opt) {
24+ if (!opt) j = nullptr; else j = *opt;
25+ }
26+
27+ static std::shared_ptr<T> from_json(const json & j) {
28+ if (j.is_null()) return std::shared_ptr<T>(); else return std::make_shared<T>(j.get<T>());
29+ }
30+ };
31+ template <typename T>
32+ struct adl_serializer<std::optional<T>> {
33+ static void to_json(json & j, const std::optional<T> & opt) {
34+ if (!opt) j = nullptr; else j = *opt;
35+ }
36+
37+ static std::optional<T> from_json(const json & j) {
38+ if (j.is_null()) return std::optional<T>(); else return std::make_optional<T>(j.get<T>());
39+ }
40+ };
41+}
42+#endif
43+
44+namespace quicktype {
45+ using nlohmann::json;
46+
47+ #ifndef NLOHMANN_UNTYPED_quicktype_HELPER
48+ #define NLOHMANN_UNTYPED_quicktype_HELPER
49+ inline json get_untyped(const json & j, const char * property) {
50+ if (j.find(property) != j.end()) {
51+ return j.at(property).get<json>();
52+ }
53+ return json();
54+ }
55+
56+ inline json get_untyped(const json & j, std::string property) {
57+ return get_untyped(j, property.data());
58+ }
59+ #endif
60+
61+ #ifndef NLOHMANN_OPTIONAL_quicktype_HELPER
62+ #define NLOHMANN_OPTIONAL_quicktype_HELPER
63+ template <typename T>
64+ inline std::shared_ptr<T> get_heap_optional(const json & j, const char * property) {
65+ auto it = j.find(property);
66+ if (it != j.end() && !it->is_null()) {
67+ return j.at(property).get<std::shared_ptr<T>>();
68+ }
69+ return std::shared_ptr<T>();
70+ }
71+
72+ template <typename T>
73+ inline std::shared_ptr<T> get_heap_optional(const json & j, std::string property) {
74+ return get_heap_optional<T>(j, property.data());
75+ }
76+ template <typename T>
77+ inline std::optional<T> get_stack_optional(const json & j, const char * property) {
78+ auto it = j.find(property);
79+ if (it != j.end() && !it->is_null()) {
80+ return j.at(property).get<std::optional<T>>();
81+ }
82+ return std::optional<T>();
83+ }
84+
85+ template <typename T>
86+ inline std::optional<T> get_stack_optional(const json & j, std::string property) {
87+ return get_stack_optional<T>(j, property.data());
88+ }
89+ #endif
90+
91+ class ComponentRef {
92+ public:
93+ ComponentRef() = default;
94+ virtual ~ComponentRef() = default;
95+
96+ private:
97+ std::optional<std::string> id;
98+
99+ public:
100+ std::optional<std::string> get_id() const { return id; }
101+ void set_id(std::optional<std::string> value) { this->id = value; }
102+ };
103+
104+ class GridConfig {
105+ public:
106+ GridConfig() = default;
107+ virtual ~GridConfig() = default;
108+
109+ private:
110+ std::optional<std::vector<std::optional<ComponentRef>>> items;
111+
112+ public:
113+ std::optional<std::vector<std::optional<ComponentRef>>> get_items() const { return items; }
114+ void set_items(std::optional<std::vector<std::optional<ComponentRef>>> value) { this->items = value; }
115+ };
116+
117+ class GridProps {
118+ public:
119+ GridProps() = default;
120+ virtual ~GridProps() = default;
121+
122+ private:
123+ std::optional<std::vector<std::optional<ComponentRef>>> items;
124+
125+ public:
126+ std::optional<std::vector<std::optional<ComponentRef>>> get_items() const { return items; }
127+ void set_items(std::optional<std::vector<std::optional<ComponentRef>>> value) { this->items = value; }
128+ };
129+
130+ class Grid {
131+ public:
132+ Grid() = default;
133+ virtual ~Grid() = default;
134+
135+ private:
136+ std::optional<GridConfig> config;
137+ std::optional<GridProps> props;
138+
139+ public:
140+ std::optional<GridConfig> get_config() const { return config; }
141+ void set_config(std::optional<GridConfig> value) { this->config = value; }
142+
143+ std::optional<GridProps> get_props() const { return props; }
144+ void set_props(std::optional<GridProps> value) { this->props = value; }
145+ };
146+
147+ class Data {
148+ public:
149+ Data() = default;
150+ virtual ~Data() = default;
151+
152+ private:
153+ std::optional<Grid> grid;
154+
155+ public:
156+ std::optional<Grid> get_grid() const { return grid; }
157+ void set_grid(std::optional<Grid> value) { this->grid = value; }
158+ };
159+
160+ class Error {
161+ public:
162+ Error() = default;
163+ virtual ~Error() = default;
164+
165+ private:
166+ std::string message;
167+
168+ public:
169+ const std::string & get_message() const { return message; }
170+ std::string & get_mutable_message() { return message; }
171+ void set_message(const std::string & value) { this->message = value; }
172+ };
173+
174+ class TopLevel {
175+ public:
176+ TopLevel() = default;
177+ virtual ~TopLevel() = default;
178+
179+ private:
180+ std::optional<Data> data;
181+ std::optional<std::vector<Error>> errors;
182+
183+ public:
184+ std::optional<Data> get_data() const { return data; }
185+ void set_data(std::optional<Data> value) { this->data = value; }
186+
187+ const std::optional<std::vector<Error>> & get_errors() const { return errors; }
188+ std::optional<std::vector<Error>> & get_mutable_errors() { return errors; }
189+ void set_errors(const std::optional<std::vector<Error>> & value) { this->errors = value; }
190+ };
191+}
192+
193+namespace quicktype {
194+ void from_json(const json & j, ComponentRef & x);
195+ void to_json(json & j, const ComponentRef & x);
196+
197+ void from_json(const json & j, GridConfig & x);
198+ void to_json(json & j, const GridConfig & x);
199+
200+ void from_json(const json & j, GridProps & x);
201+ void to_json(json & j, const GridProps & x);
202+
203+ void from_json(const json & j, Grid & x);
204+ void to_json(json & j, const Grid & x);
205+
206+ void from_json(const json & j, Data & x);
207+ void to_json(json & j, const Data & x);
208+
209+ void from_json(const json & j, Error & x);
210+ void to_json(json & j, const Error & x);
211+
212+ void from_json(const json & j, TopLevel & x);
213+ void to_json(json & j, const TopLevel & x);
214+
215+ inline void from_json(const json & j, ComponentRef& x) {
216+ x.set_id(get_stack_optional<std::string>(j, "id"));
217+ }
218+
219+ inline void to_json(json & j, const ComponentRef & x) {
220+ j = json::object();
221+ j["id"] = x.get_id();
222+ }
223+
224+ inline void from_json(const json & j, GridConfig& x) {
225+ x.set_items(get_stack_optional<std::vector<std::optional<ComponentRef>>>(j, "items"));
226+ }
227+
228+ inline void to_json(json & j, const GridConfig & x) {
229+ j = json::object();
230+ j["items"] = x.get_items();
231+ }
232+
233+ inline void from_json(const json & j, GridProps& x) {
234+ x.set_items(get_stack_optional<std::vector<std::optional<ComponentRef>>>(j, "items"));
235+ }
236+
237+ inline void to_json(json & j, const GridProps & x) {
238+ j = json::object();
239+ j["items"] = x.get_items();
240+ }
241+
242+ inline void from_json(const json & j, Grid& x) {
243+ x.set_config(get_stack_optional<GridConfig>(j, "config"));
244+ x.set_props(get_stack_optional<GridProps>(j, "props"));
245+ }
246+
247+ inline void to_json(json & j, const Grid & x) {
248+ j = json::object();
249+ j["config"] = x.get_config();
250+ j["props"] = x.get_props();
251+ }
252+
253+ inline void from_json(const json & j, Data& x) {
254+ x.set_grid(get_stack_optional<Grid>(j, "grid"));
255+ }
256+
257+ inline void to_json(json & j, const Data & x) {
258+ j = json::object();
259+ j["grid"] = x.get_grid();
260+ }
261+
262+ inline void from_json(const json & j, Error& x) {
263+ x.set_message(j.at("message").get<std::string>());
264+ }
265+
266+ inline void to_json(json & j, const Error & x) {
267+ j = json::object();
268+ j["message"] = x.get_message();
269+ }
270+
271+ inline void from_json(const json & j, TopLevel& x) {
272+ x.set_data(get_stack_optional<Data>(j, "data"));
273+ x.set_errors(get_stack_optional<std::vector<Error>>(j, "errors"));
274+ }
275+
276+ inline void to_json(json & j, const TopLevel & x) {
277+ j = json::object();
278+ j["data"] = x.get_data();
279+ j["errors"] = x.get_errors();
280+ }
281+}
Agraphql-csharpdefault / QuickType.cs+103 −0
@@ -0,0 +1,103 @@
1+// <auto-generated />
2+//
3+// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
4+//
5+// using QuickType;
6+//
7+// var topLevel = TopLevel.FromJson(jsonString);
8+#nullable enable
9+#pragma warning disable CS8618
10+#pragma warning disable CS8601
11+#pragma warning disable CS8602
12+#pragma warning disable CS8603
13+#pragma warning disable CS8604
14+#pragma warning disable CS8625
15+#pragma warning disable CS8765
16+
17+namespace QuickType
18+{
19+ using System;
20+ using System.Collections.Generic;
21+
22+ using System.Globalization;
23+ using Newtonsoft.Json;
24+ using Newtonsoft.Json.Converters;
25+
26+ public partial class TopLevel
27+ {
28+ [JsonProperty("data", Required = Required.AllowNull)]
29+ public Data? Data { get; set; }
30+
31+ [JsonProperty("errors", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
32+ public Error[]? Errors { get; set; }
33+ }
34+
35+ public partial class Data
36+ {
37+ [JsonProperty("grid", Required = Required.AllowNull)]
38+ public Grid? Grid { get; set; }
39+ }
40+
41+ public partial class Grid
42+ {
43+ [JsonProperty("config", Required = Required.AllowNull)]
44+ public GridConfig? Config { get; set; }
45+
46+ [JsonProperty("props", Required = Required.AllowNull)]
47+ public GridProps? Props { get; set; }
48+ }
49+
50+ public partial class GridConfig
51+ {
52+ [JsonProperty("items", Required = Required.AllowNull)]
53+ public ComponentRef?[]? Items { get; set; }
54+ }
55+
56+ public partial class ComponentRef
57+ {
58+ [JsonProperty("id", Required = Required.AllowNull)]
59+ public string? Id { get; set; }
60+ }
61+
62+ public partial class GridProps
63+ {
64+ [JsonProperty("items", Required = Required.AllowNull)]
65+ public ComponentRef?[]? Items { get; set; }
66+ }
67+
68+ public partial class Error
69+ {
70+ [JsonProperty("message", Required = Required.Always)]
71+ public string Message { get; set; }
72+ }
73+
74+ public partial class TopLevel
75+ {
76+ public static TopLevel FromJson(string json) => JsonConvert.DeserializeObject<TopLevel>(json, QuickType.Converter.Settings);
77+ }
78+
79+ public static partial class Serialize
80+ {
81+ public static string ToJson(this TopLevel self) => JsonConvert.SerializeObject(self, QuickType.Converter.Settings);
82+ }
83+
84+ internal static partial class Converter
85+ {
86+ public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
87+ {
88+ MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
89+ DateParseHandling = DateParseHandling.None,
90+ Converters =
91+ {
92+ new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
93+ },
94+ };
95+ }
96+}
97+#pragma warning restore CS8618
98+#pragma warning restore CS8601
99+#pragma warning restore CS8602
100+#pragma warning restore CS8603
101+#pragma warning restore CS8604
102+#pragma warning restore CS8625
103+#pragma warning restore CS8765
Agraphql-dartdefault / TopLevel.dart+129 −0
@@ -0,0 +1,129 @@
1+// To parse this JSON data, do
2+//
3+// final topLevel = topLevelFromJson(jsonString);
4+
5+import 'dart:convert';
6+
7+TopLevel topLevelFromJson(String str) => TopLevel.fromJson(json.decode(str));
8+
9+String topLevelToJson(TopLevel data) => json.encode(data.toJson());
10+
11+class TopLevel {
12+ final Data? data;
13+ final List<Error>? errors;
14+
15+ TopLevel({
16+ required this.data,
17+ this.errors,
18+ });
19+
20+ factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel(
21+ data: json["data"] == null ? null : Data.fromJson(json["data"]),
22+ errors: json["errors"] == null ? null : List<Error>.from(json["errors"]!.map((x) => Error.fromJson(x))),
23+ );
24+
25+ Map<String, dynamic> toJson() => {
26+ "data": data?.toJson(),
27+ "errors": errors == null ? null : List<dynamic>.from(errors!.map((x) => x.toJson())),
28+ };
29+}
30+
31+class Data {
32+ final Grid? grid;
33+
34+ Data({
35+ required this.grid,
36+ });
37+
38+ factory Data.fromJson(Map<String, dynamic> json) => Data(
39+ grid: json["grid"] == null ? null : Grid.fromJson(json["grid"]),
40+ );
41+
42+ Map<String, dynamic> toJson() => {
43+ "grid": grid?.toJson(),
44+ };
45+}
46+
47+class Grid {
48+ final GridConfig? config;
49+ final GridProps? props;
50+
51+ Grid({
52+ required this.config,
53+ required this.props,
54+ });
55+
56+ factory Grid.fromJson(Map<String, dynamic> json) => Grid(
57+ config: json["config"] == null ? null : GridConfig.fromJson(json["config"]),
58+ props: json["props"] == null ? null : GridProps.fromJson(json["props"]),
59+ );
60+
61+ Map<String, dynamic> toJson() => {
62+ "config": config?.toJson(),
63+ "props": props?.toJson(),
64+ };
65+}
66+
67+class GridConfig {
68+ final List<ComponentRef?>? items;
69+
70+ GridConfig({
71+ required this.items,
72+ });
73+
74+ factory GridConfig.fromJson(Map<String, dynamic> json) => GridConfig(
75+ items: json["items"] == null ? null : List<ComponentRef?>.from(json["items"]!.map((x) => x == null ? null : ComponentRef.fromJson(x))),
76+ );
77+
78+ Map<String, dynamic> toJson() => {
79+ "items": items == null ? null : List<dynamic>.from(items!.map((x) => x?.toJson())),
80+ };
81+}
82+
83+class ComponentRef {
84+ final String? id;
85+
86+ ComponentRef({
87+ required this.id,
88+ });
89+
90+ factory ComponentRef.fromJson(Map<String, dynamic> json) => ComponentRef(
91+ id: json["id"],
92+ );
93+
94+ Map<String, dynamic> toJson() => {
95+ "id": id,
96+ };
97+}
98+
99+class GridProps {
100+ final List<ComponentRef?>? items;
101+
102+ GridProps({
103+ required this.items,
104+ });
105+
106+ factory GridProps.fromJson(Map<String, dynamic> json) => GridProps(
107+ items: json["items"] == null ? null : List<ComponentRef?>.from(json["items"]!.map((x) => x == null ? null : ComponentRef.fromJson(x))),
108+ );
109+
110+ Map<String, dynamic> toJson() => {
111+ "items": items == null ? null : List<dynamic>.from(items!.map((x) => x?.toJson())),
112+ };
113+}
114+
115+class Error {
116+ final String message;
117+
118+ Error({
119+ required this.message,
120+ });
121+
122+ factory Error.fromJson(Map<String, dynamic> json) => Error(
123+ message: json["message"],
124+ );
125+
126+ Map<String, dynamic> toJson() => {
127+ "message": message,
128+ };
129+}
Agraphql-elixirdefault / QuickType.ex+259 −0
@@ -0,0 +1,259 @@
1+# This file was autogenerated using quicktype https://github.com/quicktype/quicktype
2+#
3+# Add Jason to your mix.exs
4+#
5+# Decode a JSON string: TopLevel.from_json(data)
6+# Encode into a JSON string: TopLevel.to_json(struct)
7+
8+defmodule ComponentRef do
9+ @enforce_keys [:id]
10+ defstruct [:id]
11+
12+ @type t :: %__MODULE__{
13+ id: nil | String.t()
14+ }
15+
16+ def from_map(m) do
17+ %ComponentRef{
18+ id: m["id"],
19+ }
20+ end
21+
22+ def from_json(json) do
23+ json
24+ |> Jason.decode!()
25+ |> from_map()
26+ end
27+
28+ def to_map(struct) do
29+ %{
30+ "id" => struct.id,
31+ }
32+ end
33+
34+ def to_json(struct) do
35+ struct
36+ |> to_map()
37+ |> Jason.encode!()
38+ end
39+end
40+
41+defmodule GridConfig do
42+ @enforce_keys [:items]
43+ defstruct [:items]
44+
45+ @type t :: %__MODULE__{
46+ items: [ComponentRef.t() | nil] | nil
47+ }
48+
49+ def decode_items_element(%{"id" => _,} = value), do: ComponentRef.from_map(value)
50+ def decode_items_element(value) when is_nil(value), do: value
51+ def decode_items_element(_), do: {:error, "Unexpected type when decoding GridConfig.items"}
52+
53+ def encode_items_element(%ComponentRef{} = value), do: ComponentRef.to_map(value)
54+ def encode_items_element(value) when is_nil(value), do: value
55+ def encode_items_element(_), do: {:error, "Unexpected type when encoding GridConfig.items"}
56+
57+ def from_map(m) do
58+ %GridConfig{
59+ items: m["items"] && Enum.map(m["items"], &decode_items_element/1),
60+ }
61+ end
62+
63+ def from_json(json) do
64+ json
65+ |> Jason.decode!()
66+ |> from_map()
67+ end
68+
69+ def to_map(struct) do
70+ %{
71+ "items" => struct.items && Enum.map(struct.items, &encode_items_element/1),
72+ }
73+ end
74+
75+ def to_json(struct) do
76+ struct
77+ |> to_map()
78+ |> Jason.encode!()
79+ end
80+end
81+
82+defmodule GridProps do
83+ @enforce_keys [:items]
84+ defstruct [:items]
85+
86+ @type t :: %__MODULE__{
87+ items: [ComponentRef.t() | nil] | nil
88+ }
89+
90+ def decode_items_element(%{"id" => _,} = value), do: ComponentRef.from_map(value)
91+ def decode_items_element(value) when is_nil(value), do: value
92+ def decode_items_element(_), do: {:error, "Unexpected type when decoding GridProps.items"}
93+
94+ def encode_items_element(%ComponentRef{} = value), do: ComponentRef.to_map(value)
95+ def encode_items_element(value) when is_nil(value), do: value
96+ def encode_items_element(_), do: {:error, "Unexpected type when encoding GridProps.items"}
97+
98+ def from_map(m) do
99+ %GridProps{
100+ items: m["items"] && Enum.map(m["items"], &decode_items_element/1),
101+ }
102+ end
103+
104+ def from_json(json) do
105+ json
106+ |> Jason.decode!()
107+ |> from_map()
108+ end
109+
110+ def to_map(struct) do
111+ %{
112+ "items" => struct.items && Enum.map(struct.items, &encode_items_element/1),
113+ }
114+ end
115+
116+ def to_json(struct) do
117+ struct
118+ |> to_map()
119+ |> Jason.encode!()
120+ end
121+end
122+
123+defmodule Grid do
124+ @enforce_keys [:config, :props]
125+ defstruct [:config, :props]
126+
127+ @type t :: %__MODULE__{
128+ config: GridConfig.t() | nil,
129+ props: GridProps.t() | nil
130+ }
131+
132+ def from_map(m) do
133+ %Grid{
134+ config: m["config"] && GridConfig.from_map(m["config"]),
135+ props: m["props"] && GridProps.from_map(m["props"]),
136+ }
137+ end
138+
139+ def from_json(json) do
140+ json
141+ |> Jason.decode!()
142+ |> from_map()
143+ end
144+
145+ def to_map(struct) do
146+ %{
147+ "config" => struct.config && GridConfig.to_map(struct.config),
148+ "props" => struct.props && GridProps.to_map(struct.props),
149+ }
150+ end
151+
152+ def to_json(struct) do
153+ struct
154+ |> to_map()
155+ |> Jason.encode!()
156+ end
157+end
158+
159+defmodule Data do
160+ @enforce_keys [:grid]
161+ defstruct [:grid]
162+
163+ @type t :: %__MODULE__{
164+ grid: Grid.t() | nil
165+ }
166+
167+ def from_map(m) do
168+ %Data{
169+ grid: m["grid"] && Grid.from_map(m["grid"]),
170+ }
171+ end
172+
173+ def from_json(json) do
174+ json
175+ |> Jason.decode!()
176+ |> from_map()
177+ end
178+
179+ def to_map(struct) do
180+ %{
181+ "grid" => struct.grid && Grid.to_map(struct.grid),
182+ }
183+ end
184+
185+ def to_json(struct) do
186+ struct
187+ |> to_map()
188+ |> Jason.encode!()
189+ end
190+end
191+
192+defmodule Error do
193+ @enforce_keys [:message]
194+ defstruct [:message]
195+
196+ @type t :: %__MODULE__{
197+ message: String.t()
198+ }
199+
200+ def from_map(m) do
201+ %Error{
202+ message: m["message"],
203+ }
204+ end
205+
206+ def from_json(json) do
207+ json
208+ |> Jason.decode!()
209+ |> from_map()
210+ end
211+
212+ def to_map(struct) do
213+ %{
214+ "message" => struct.message,
215+ }
216+ end
217+
218+ def to_json(struct) do
219+ struct
220+ |> to_map()
221+ |> Jason.encode!()
222+ end
223+end
224+
225+defmodule TopLevel do
226+ @enforce_keys [:data]
227+ defstruct [:data, :errors]
228+
229+ @type t :: %__MODULE__{
230+ data: Data.t() | nil,
231+ errors: [Error.t()] | nil
232+ }
233+
234+ def from_map(m) do
235+ %TopLevel{
236+ data: m["data"] && Data.from_map(m["data"]),
237+ errors: m["errors"] && Enum.map(m["errors"], &Error.from_map/1),
238+ }
239+ end
240+
241+ def from_json(json) do
242+ json
243+ |> Jason.decode!()
244+ |> from_map()
245+ end
246+
247+ def to_map(struct) do
248+ %{
249+ "data" => struct.data && Data.to_map(struct.data),
250+ "errors" => struct.errors && Enum.map(struct.errors, &Error.to_map/1),
251+ }
252+ end
253+
254+ def to_json(struct) do
255+ struct
256+ |> to_map()
257+ |> Jason.encode!()
258+ end
259+end
Agraphql-flowdefault / TopLevel.js+234 −0
@@ -0,0 +1,234 @@
1+// @flow
2+
3+// To parse this data:
4+//
5+// const Convert = require("./TopLevel");
6+//
7+// const topLevel = Convert.toTopLevel(json);
8+//
9+// These functions will throw an error if the JSON doesn't
10+// match the expected interface, even if the JSON is valid.
11+
12+export type TopLevel = {
13+ data: Data | null;
14+ errors?: ErrorElement[];
15+};
16+
17+export type Data = {
18+ grid: Grid | null;
19+};
20+
21+export type Grid = {
22+ config: GridConfig | null;
23+ props: GridProps | null;
24+};
25+
26+export type GridConfig = {
27+ items: (ComponentRef | null)[] | null;
28+};
29+
30+export type ComponentRef = {
31+ id: null | string;
32+};
33+
34+export type GridProps = {
35+ items: (ComponentRef | null)[] | null;
36+};
37+
38+export type ErrorElement = {
39+ message: string;
40+};
41+
42+// Converts JSON strings to/from your types
43+// and asserts the results of JSON.parse at runtime
44+function toTopLevel(json: string): TopLevel {
45+ return cast(JSON.parse(json), r("TopLevel"));
46+}
47+
48+function topLevelToJson(value: TopLevel): string {
49+ return JSON.stringify(uncast(value, r("TopLevel")), null, 2);
50+}
51+
52+function invalidValue(typ: any, val: any, key: any, parent: any = '') {
53+ const prettyTyp = prettyTypeName(typ);
54+ const parentText = parent ? ` on ${parent}` : '';
55+ const keyText = key ? ` for key "${key}"` : '';
56+ throw Error(`Invalid value${keyText}${parentText}. Expected ${prettyTyp} but got ${JSON.stringify(val)}`);
57+}
58+
59+function prettyTypeName(typ: any): string {
60+ if (Array.isArray(typ)) {
61+ if (typ.length === 2 && typ[0] === undefined) {
62+ return `an optional ${prettyTypeName(typ[1])}`;
63+ } else {
64+ return `one of [${typ.map(a => { return prettyTypeName(a); }).join(", ")}]`;
65+ }
66+ } else if (typeof typ === "object" && typ.literal !== undefined) {
67+ return typ.literal;
68+ } else {
69+ return typeof typ;
70+ }
71+}
72+
73+function jsonToJSProps(typ: any): any {
74+ if (typ.jsonToJS === undefined) {
75+ const map: any = {};
76+ typ.props.forEach((p: any) => map[p.json] = { key: p.js, typ: p.typ });
77+ typ.jsonToJS = map;
78+ }
79+ return typ.jsonToJS;
80+}
81+
82+function jsToJSONProps(typ: any): any {
83+ if (typ.jsToJSON === undefined) {
84+ const map: any = {};
85+ typ.props.forEach((p: any) => map[p.js] = { key: p.json, typ: p.typ });
86+ typ.jsToJSON = map;
87+ }
88+ return typ.jsToJSON;
89+}
90+
91+function transform(val: any, typ: any, getProps: any, key: any = '', parent: any = ''): any {
92+ function transformPrimitive(typ: string, val: any): any {
93+ if (typeof typ === typeof val) return val;
94+ return invalidValue(typ, val, key, parent);
95+ }
96+
97+ function transformUnion(typs: any[], val: any): any {
98+ // val must validate against one typ in typs
99+ const l = typs.length;
100+ for (let i = 0; i < l; i++) {
101+ const typ = typs[i];
102+ try {
103+ return transform(val, typ, getProps);
104+ } catch (_) {}
105+ }
106+ return invalidValue(typs, val, key, parent);
107+ }
108+
109+ function transformEnum(cases: string[], val: any): any {
110+ if (cases.indexOf(val) !== -1) return val;
111+ return invalidValue(cases.map(a => { return l(a); }), val, key, parent);
112+ }
113+
114+ function transformArray(typ: any, val: any): any {
115+ // val must be an array with no invalid elements
116+ if (!Array.isArray(val)) return invalidValue(l("array"), val, key, parent);
117+ return val.map(el => transform(el, typ, getProps));
118+ }
119+
120+ function transformDate(val: any): any {
121+ if (val === null) {
122+ return null;
123+ }
124+ const d = new Date(val);
125+ if (isNaN(d.valueOf())) {
126+ return invalidValue(l("Date"), val, key, parent);
127+ }
128+ return d;
129+ }
130+
131+ function transformObject(props: { [k: string]: any }, additional: any, val: any): any {
132+ if (val === null || typeof val !== "object" || Array.isArray(val)) {
133+ return invalidValue(l(ref || "object"), val, key, parent);
134+ }
135+ const result: any = {};
136+ Object.getOwnPropertyNames(props).forEach(key => {
137+ const prop = props[key];
138+ const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
139+ result[prop.key] = transform(v, prop.typ, getProps, key, ref);
140+ });
141+ Object.getOwnPropertyNames(val).forEach(key => {
142+ if (!Object.prototype.hasOwnProperty.call(props, key)) {
143+ result[key] = transform(val[key], additional, getProps, key, ref);
144+ }
145+ });
146+ return result;
147+ }
148+
149+ if (typ === "any") return val;
150+ if (typ === null) {
151+ if (val === null) return val;
152+ return invalidValue(typ, val, key, parent);
153+ }
154+ if (typ === false) return invalidValue(typ, val, key, parent);
155+ let ref: any = undefined;
156+ while (typeof typ === "object" && typ.ref !== undefined) {
157+ ref = typ.ref;
158+ typ = typeMap[typ.ref];
159+ }
160+ if (Array.isArray(typ)) return transformEnum(typ, val);
161+ if (typeof typ === "object") {
162+ return typ.hasOwnProperty("unionMembers") ? transformUnion(typ.unionMembers, val)
163+ : typ.hasOwnProperty("arrayItems") ? transformArray(typ.arrayItems, val)
164+ : typ.hasOwnProperty("props") ? transformObject(getProps(typ), typ.additional, val)
165+ : invalidValue(typ, val, key, parent);
166+ }
167+ // Numbers can be parsed by Date but shouldn't be.
168+ if (typ === Date && typeof val !== "number") return transformDate(val);
169+ return transformPrimitive(typ, val);
170+}
171+
172+function cast<T>(val: any, typ: any): T {
173+ return transform(val, typ, jsonToJSProps);
174+}
175+
176+function uncast<T>(val: T, typ: any): any {
177+ return transform(val, typ, jsToJSONProps);
178+}
179+
180+function l(typ: any) {
181+ return { literal: typ };
182+}
183+
184+function a(typ: any) {
185+ return { arrayItems: typ };
186+}
187+
188+function u(...typs: any[]) {
189+ return { unionMembers: typs };
190+}
191+
192+function o(props: any[], additional: any) {
193+ return { props, additional };
194+}
195+
196+function m(additional: any) {
197+ const props: any[] = [];
198+ return { props, additional };
199+}
200+
201+function r(name: string) {
202+ return { ref: name };
203+}
204+
205+const typeMap: any = {
206+ "TopLevel": o([
207+ { json: "data", js: "data", typ: u(r("Data"), null) },
208+ { json: "errors", js: "errors", typ: u(undefined, a(r("ErrorElement"))) },
209+ ], false),
210+ "Data": o([
211+ { json: "grid", js: "grid", typ: u(r("Grid"), null) },
212+ ], false),
213+ "Grid": o([
214+ { json: "config", js: "config", typ: u(r("GridConfig"), null) },
215+ { json: "props", js: "props", typ: u(r("GridProps"), null) },
216+ ], false),
217+ "GridConfig": o([
218+ { json: "items", js: "items", typ: u(a(u(r("ComponentRef"), null)), null) },
219+ ], false),
220+ "ComponentRef": o([
221+ { json: "id", js: "id", typ: u(null, "") },
222+ ], false),
223+ "GridProps": o([
224+ { json: "items", js: "items", typ: u(a(u(r("ComponentRef"), null)), null) },
225+ ], false),
226+ "ErrorElement": o([
227+ { json: "message", js: "message", typ: "" },
228+ ], false),
229+};
230+
231+module.exports = {
232+ "topLevelToJson": topLevelToJson,
233+ "toTopLevel": toTopLevel,
234+};
Agraphql-golangdefault / quicktype.go+49 −0
@@ -0,0 +1,49 @@
1+// Code generated from JSON Schema using quicktype. DO NOT EDIT.
2+// To parse and unparse this JSON data, add this code to your project and do:
3+//
4+// topLevel, err := UnmarshalTopLevel(bytes)
5+// bytes, err = topLevel.Marshal()
6+
7+package main
8+
9+import "encoding/json"
10+
11+func UnmarshalTopLevel(data []byte) (TopLevel, error) {
12+ var r TopLevel
13+ err := json.Unmarshal(data, &r)
14+ return r, err
15+}
16+
17+func (r *TopLevel) Marshal() ([]byte, error) {
18+ return json.Marshal(r)
19+}
20+
21+type TopLevel struct {
22+ Data *Data `json:"data"`
23+ Errors []Error `json:"errors,omitempty"`
24+}
25+
26+type Data struct {
27+ Grid *Grid `json:"grid"`
28+}
29+
30+type Grid struct {
31+ Config *GridConfig `json:"config"`
32+ Props *GridProps `json:"props"`
33+}
34+
35+type GridConfig struct {
36+ Items []*ComponentRef `json:"items"`
37+}
38+
39+type ComponentRef struct {
40+ ID *string `json:"id"`
41+}
42+
43+type GridProps struct {
44+ Items []*ComponentRef `json:"items"`
45+}
46+
47+type Error struct {
48+ Message string `json:"message"`
49+}
Agraphql-haskelldefault / QuickType.hs+126 −0
@@ -0,0 +1,126 @@
1+{-# LANGUAGE StrictData #-}
2+{-# LANGUAGE OverloadedStrings #-}
3+
4+module QuickType
5+ ( QuickType (..)
6+ , ErrorElement (..)
7+ , Data (..)
8+ , Grid (..)
9+ , GridConfig (..)
10+ , ComponentRef (..)
11+ , GridProps (..)
12+ , decodeTopLevel
13+ ) where
14+
15+import Data.Aeson
16+import Data.Aeson.Types (emptyObject)
17+import Data.ByteString.Lazy (ByteString)
18+import Data.HashMap.Strict (HashMap)
19+import Data.Text (Text)
20+
21+data QuickType = QuickType
22+ { gridQueryDataQuickType :: Maybe Data
23+ , errorsQuickType :: Maybe ([ErrorElement])
24+ } deriving (Show)
25+
26+data ErrorElement = ErrorElement
27+ { messageErrorElement :: Text
28+ } deriving (Show)
29+
30+data Data = Data
31+ { gridData :: Maybe Grid
32+ } deriving (Show)
33+
34+data Grid = Grid
35+ { configGrid :: Maybe GridConfig
36+ , propsGrid :: Maybe GridProps
37+ } deriving (Show)
38+
39+data GridConfig = GridConfig
40+ { itemsGridConfig :: Maybe ([(Maybe ComponentRef)])
41+ } deriving (Show)
42+
43+data ComponentRef = ComponentRef
44+ { componentRefIDComponentRef :: Maybe Text
45+ } deriving (Show)
46+
47+data GridProps = GridProps
48+ { itemsGridProps :: Maybe ([(Maybe ComponentRef)])
49+ } deriving (Show)
50+
51+decodeTopLevel :: ByteString -> Maybe QuickType
52+decodeTopLevel = decode
53+
54+instance ToJSON QuickType where
55+ toJSON (QuickType gridQueryDataQuickType errorsQuickType) =
56+ object
57+ [ "data" .= gridQueryDataQuickType
58+ , "errors" .= errorsQuickType
59+ ]
60+
61+instance FromJSON QuickType where
62+ parseJSON (Object v) = QuickType
63+ <$> v .: "data"
64+ <*> v .:? "errors"
65+
66+instance ToJSON ErrorElement where
67+ toJSON (ErrorElement messageErrorElement) =
68+ object
69+ [ "message" .= messageErrorElement
70+ ]
71+
72+instance FromJSON ErrorElement where
73+ parseJSON (Object v) = ErrorElement
74+ <$> v .: "message"
75+
76+instance ToJSON Data where
77+ toJSON (Data gridData) =
78+ object
79+ [ "grid" .= gridData
80+ ]
81+
82+instance FromJSON Data where
83+ parseJSON (Object v) = Data
84+ <$> v .: "grid"
85+
86+instance ToJSON Grid where
87+ toJSON (Grid configGrid propsGrid) =
88+ object
89+ [ "config" .= configGrid
90+ , "props" .= propsGrid
91+ ]
92+
93+instance FromJSON Grid where
94+ parseJSON (Object v) = Grid
95+ <$> v .: "config"
96+ <*> v .: "props"
97+
98+instance ToJSON GridConfig where
99+ toJSON (GridConfig itemsGridConfig) =
100+ object
101+ [ "items" .= itemsGridConfig
102+ ]
103+
104+instance FromJSON GridConfig where
105+ parseJSON (Object v) = GridConfig
106+ <$> v .: "items"
107+
108+instance ToJSON ComponentRef where
109+ toJSON (ComponentRef componentRefIDComponentRef) =
110+ object
111+ [ "id" .= componentRefIDComponentRef
112+ ]
113+
114+instance FromJSON ComponentRef where
115+ parseJSON (Object v) = ComponentRef
116+ <$> v .: "id"
117+
118+instance ToJSON GridProps where
119+ toJSON (GridProps itemsGridProps) =
120+ object
121+ [ "items" .= itemsGridProps
122+ ]
123+
124+instance FromJSON GridProps where
125+ parseJSON (Object v) = GridProps
126+ <$> v .: "items"
Agraphql-java-datetime-legacydefault / src / main / java / io / quicktype / ComponentRef.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class ComponentRef {
6+ private String id;
7+
8+ @JsonProperty("id")
9+ public String getID() { return id; }
10+ @JsonProperty("id")
11+ public void setID(String value) { this.id = value; }
12+}
Agraphql-java-datetime-legacydefault / src / main / java / io / quicktype / Converter.java+121 −0
@@ -0,0 +1,121 @@
1+// To use this code, add the following Maven dependency to your project:
2+//
3+//
4+// com.fasterxml.jackson.core : jackson-databind : 2.9.0
5+//
6+//
7+// Import this package:
8+//
9+// import io.quicktype.Converter;
10+//
11+// Then you can deserialize a JSON string with
12+//
13+// TopLevel data = Converter.fromJsonString(jsonString);
14+
15+package io.quicktype;
16+
17+import java.io.IOException;
18+import com.fasterxml.jackson.databind.*;
19+import com.fasterxml.jackson.databind.module.SimpleModule;
20+import com.fasterxml.jackson.core.JsonParser;
21+import com.fasterxml.jackson.core.JsonProcessingException;
22+import java.util.*;
23+import java.util.Date;
24+import java.text.SimpleDateFormat;
25+
26+public class Converter {
27+ // Date-time helpers
28+
29+ private static final String[] DATE_TIME_FORMATS = {
30+ "yyyy-MM-dd'T'HH:mm:ss.SX",
31+ "yyyy-MM-dd'T'HH:mm:ss.S",
32+ "yyyy-MM-dd'T'HH:mm:ssX",
33+ "yyyy-MM-dd'T'HH:mm:ss",
34+ "yyyy-MM-dd HH:mm:ss.SX",
35+ "yyyy-MM-dd HH:mm:ss.S",
36+ "yyyy-MM-dd HH:mm:ssX",
37+ "yyyy-MM-dd HH:mm:ss",
38+ "HH:mm:ss.SZ",
39+ "HH:mm:ss.S",
40+ "HH:mm:ssZ",
41+ "HH:mm:ss",
42+ "yyyy-MM-dd",
43+ };
44+
45+ public static Date parseAllDateTimeString(String str) {
46+ for (String format : DATE_TIME_FORMATS) {
47+ try {
48+ return new SimpleDateFormat(format).parse(str);
49+ } catch (Exception ex) {
50+ // Ignored
51+ }
52+ }
53+ return null;
54+ }
55+
56+ public static String serializeDateTime(Date datetime) {
57+ return new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ssZ").format(datetime);
58+ }
59+
60+ public static String serializeDate(Date datetime) {
61+ return new SimpleDateFormat("yyyy-MM-dd").format(datetime);
62+ }
63+
64+ public static String serializeTime(Date datetime) {
65+ return new SimpleDateFormat("hh:mm:ssZ").format(datetime);
66+ }
67+ // Serialize/deserialize helpers
68+
69+ public static TopLevel fromJsonString(String json) throws IOException {
70+ return getObjectReader().readValue(json);
71+ }
72+
73+ public static String toJsonString(TopLevel obj) throws JsonProcessingException {
74+ return getObjectWriter().writeValueAsString(obj);
75+ }
76+
77+ private static ObjectReader reader;
78+ private static ObjectWriter writer;
79+
80+ private static void instantiateMapper() {
81+ ObjectMapper mapper = new ObjectMapper();
82+ mapper.findAndRegisterModules();
83+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
84+ mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
85+ SimpleModule module = new SimpleModule();
86+ module.addDeserializer(Date.class, new JsonDeserializer<Date>() {
87+ @Override
88+ public Date deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
89+ String value = jsonParser.getText();
90+ return Converter.parseAllDateTimeString(value);
91+ }
92+ });
93+ module.addDeserializer(Date.class, new JsonDeserializer<Date>() {
94+ @Override
95+ public Date deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
96+ String value = jsonParser.getText();
97+ return Converter.parseAllDateTimeString(value);
98+ }
99+ });
100+ module.addDeserializer(Date.class, new JsonDeserializer<Date>() {
101+ @Override
102+ public Date deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
103+ String value = jsonParser.getText();
104+ return Converter.parseAllDateTimeString(value);
105+ }
106+ });
107+ mapper.registerModule(module);
108+ reader = mapper.readerFor(TopLevel.class);
109+ writer = mapper.writerFor(TopLevel.class);
110+ }
111+
112+ private static ObjectReader getObjectReader() {
113+ if (reader == null) instantiateMapper();
114+ return reader;
115+ }
116+
117+ private static ObjectWriter getObjectWriter() {
118+ if (writer == null) instantiateMapper();
119+ return writer;
120+ }
121+}
Agraphql-java-datetime-legacydefault / src / main / java / io / quicktype / Data.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class Data {
6+ private Grid grid;
7+
8+ @JsonProperty("grid")
9+ public Grid getGrid() { return grid; }
10+ @JsonProperty("grid")
11+ public void setGrid(Grid value) { this.grid = value; }
12+}
Agraphql-java-datetime-legacydefault / src / main / java / io / quicktype / Error.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class Error {
6+ private String message;
7+
8+ @JsonProperty("message")
9+ public String getMessage() { return message; }
10+ @JsonProperty("message")
11+ public void setMessage(String value) { this.message = value; }
12+}
Agraphql-java-datetime-legacydefault / src / main / java / io / quicktype / Grid.java+18 −0
@@ -0,0 +1,18 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class Grid {
6+ private GridConfig config;
7+ private GridProps props;
8+
9+ @JsonProperty("config")
10+ public GridConfig getConfig() { return config; }
11+ @JsonProperty("config")
12+ public void setConfig(GridConfig value) { this.config = value; }
13+
14+ @JsonProperty("props")
15+ public GridProps getProps() { return props; }
16+ @JsonProperty("props")
17+ public void setProps(GridProps value) { this.props = value; }
18+}
Agraphql-java-datetime-legacydefault / src / main / java / io / quicktype / GridConfig.java+13 −0
@@ -0,0 +1,13 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+import java.util.List;
5+
6+public class GridConfig {
7+ private List<ComponentRef> items;
8+
9+ @JsonProperty("items")
10+ public List<ComponentRef> getItems() { return items; }
11+ @JsonProperty("items")
12+ public void setItems(List<ComponentRef> value) { this.items = value; }
13+}
Agraphql-java-datetime-legacydefault / src / main / java / io / quicktype / GridProps.java+13 −0
@@ -0,0 +1,13 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+import java.util.List;
5+
6+public class GridProps {
7+ private List<ComponentRef> items;
8+
9+ @JsonProperty("items")
10+ public List<ComponentRef> getItems() { return items; }
11+ @JsonProperty("items")
12+ public void setItems(List<ComponentRef> value) { this.items = value; }
13+}
Agraphql-java-datetime-legacydefault / src / main / java / io / quicktype / TopLevel.java+19 −0
@@ -0,0 +1,19 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+import java.util.List;
5+
6+public class TopLevel {
7+ private Data data;
8+ private List<Error> errors;
9+
10+ @JsonProperty("data")
11+ public Data getData() { return data; }
12+ @JsonProperty("data")
13+ public void setData(Data value) { this.data = value; }
14+
15+ @JsonProperty("errors")
16+ public List<Error> getErrors() { return errors; }
17+ @JsonProperty("errors")
18+ public void setErrors(List<Error> value) { this.errors = value; }
19+}
Agraphql-java-lombokdefault / src / main / java / io / quicktype / ComponentRef.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class ComponentRef {
6+ private String id;
7+
8+ @JsonProperty("id")
9+ public String getID() { return id; }
10+ @JsonProperty("id")
11+ public void setID(String value) { this.id = value; }
12+}
Agraphql-java-lombokdefault / src / main / java / io / quicktype / Converter.java+101 −0
@@ -0,0 +1,101 @@
1+// To use this code, add the following Maven dependency to your project:
2+//
3+//
4+// com.fasterxml.jackson.core : jackson-databind : 2.9.0
5+// com.fasterxml.jackson.datatype : jackson-datatype-jsr310 : 2.9.0
6+//
7+// Import this package:
8+//
9+// import io.quicktype.Converter;
10+//
11+// Then you can deserialize a JSON string with
12+//
13+// TopLevel data = Converter.fromJsonString(jsonString);
14+
15+package io.quicktype;
16+
17+import java.io.IOException;
18+import com.fasterxml.jackson.databind.*;
19+import com.fasterxml.jackson.databind.module.SimpleModule;
20+import com.fasterxml.jackson.core.JsonParser;
21+import com.fasterxml.jackson.core.JsonProcessingException;
22+import java.util.*;
23+import java.time.LocalDate;
24+import java.time.OffsetDateTime;
25+import java.time.OffsetTime;
26+import java.time.ZoneOffset;
27+import java.time.ZonedDateTime;
28+import java.time.format.DateTimeFormatter;
29+import java.time.format.DateTimeFormatterBuilder;
30+import java.time.temporal.ChronoField;
31+
32+public class Converter {
33+ // Date-time helpers
34+
35+ private static final DateTimeFormatter DATE_TIME_FORMATTER = new DateTimeFormatterBuilder()
36+ .appendOptional(DateTimeFormatter.ISO_DATE_TIME)
37+ .appendOptional(DateTimeFormatter.ISO_OFFSET_DATE_TIME)
38+ .appendOptional(DateTimeFormatter.ISO_INSTANT)
39+ .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SX"))
40+ .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ssX"))
41+ .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
42+ .toFormatter()
43+ .withZone(ZoneOffset.UTC);
44+
45+ public static OffsetDateTime parseDateTimeString(String str) {
46+ return ZonedDateTime.from(Converter.DATE_TIME_FORMATTER.parse(str)).toOffsetDateTime();
47+ }
48+
49+ private static final DateTimeFormatter TIME_FORMATTER = new DateTimeFormatterBuilder()
50+ .appendOptional(DateTimeFormatter.ISO_TIME)
51+ .appendOptional(DateTimeFormatter.ISO_OFFSET_TIME)
52+ .parseDefaulting(ChronoField.YEAR, 2020)
53+ .parseDefaulting(ChronoField.MONTH_OF_YEAR, 1)
54+ .parseDefaulting(ChronoField.DAY_OF_MONTH, 1)
55+ .toFormatter()
56+ .withZone(ZoneOffset.UTC);
57+
58+ public static OffsetTime parseTimeString(String str) {
59+ return ZonedDateTime.from(Converter.TIME_FORMATTER.parse(str)).toOffsetDateTime().toOffsetTime();
60+ }
61+ // Serialize/deserialize helpers
62+
63+ public static TopLevel fromJsonString(String json) throws IOException {
64+ return getObjectReader().readValue(json);
65+ }
66+
67+ public static String toJsonString(TopLevel obj) throws JsonProcessingException {
68+ return getObjectWriter().writeValueAsString(obj);
69+ }
70+
71+ private static ObjectReader reader;
72+ private static ObjectWriter writer;
73+
74+ private static void instantiateMapper() {
75+ ObjectMapper mapper = new ObjectMapper();
76+ mapper.findAndRegisterModules();
77+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
78+ mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
79+ SimpleModule module = new SimpleModule();
80+ module.addDeserializer(OffsetDateTime.class, new JsonDeserializer<OffsetDateTime>() {
81+ @Override
82+ public OffsetDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
83+ String value = jsonParser.getText();
84+ return Converter.parseDateTimeString(value);
85+ }
86+ });
87+ mapper.registerModule(module);
88+ reader = mapper.readerFor(TopLevel.class);
89+ writer = mapper.writerFor(TopLevel.class);
90+ }
91+
92+ private static ObjectReader getObjectReader() {
93+ if (reader == null) instantiateMapper();
94+ return reader;
95+ }
96+
97+ private static ObjectWriter getObjectWriter() {
98+ if (writer == null) instantiateMapper();
99+ return writer;
100+ }
101+}
Agraphql-java-lombokdefault / src / main / java / io / quicktype / Data.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class Data {
6+ private Grid grid;
7+
8+ @JsonProperty("grid")
9+ public Grid getGrid() { return grid; }
10+ @JsonProperty("grid")
11+ public void setGrid(Grid value) { this.grid = value; }
12+}
Agraphql-java-lombokdefault / src / main / java / io / quicktype / Error.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class Error {
6+ private String message;
7+
8+ @JsonProperty("message")
9+ public String getMessage() { return message; }
10+ @JsonProperty("message")
11+ public void setMessage(String value) { this.message = value; }
12+}
Agraphql-java-lombokdefault / src / main / java / io / quicktype / Grid.java+18 −0
@@ -0,0 +1,18 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class Grid {
6+ private GridConfig config;
7+ private GridProps props;
8+
9+ @JsonProperty("config")
10+ public GridConfig getConfig() { return config; }
11+ @JsonProperty("config")
12+ public void setConfig(GridConfig value) { this.config = value; }
13+
14+ @JsonProperty("props")
15+ public GridProps getProps() { return props; }
16+ @JsonProperty("props")
17+ public void setProps(GridProps value) { this.props = value; }
18+}
Agraphql-java-lombokdefault / src / main / java / io / quicktype / GridConfig.java+13 −0
@@ -0,0 +1,13 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+import java.util.List;
5+
6+public class GridConfig {
7+ private List<ComponentRef> items;
8+
9+ @JsonProperty("items")
10+ public List<ComponentRef> getItems() { return items; }
11+ @JsonProperty("items")
12+ public void setItems(List<ComponentRef> value) { this.items = value; }
13+}
Agraphql-java-lombokdefault / src / main / java / io / quicktype / GridProps.java+13 −0
@@ -0,0 +1,13 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+import java.util.List;
5+
6+public class GridProps {
7+ private List<ComponentRef> items;
8+
9+ @JsonProperty("items")
10+ public List<ComponentRef> getItems() { return items; }
11+ @JsonProperty("items")
12+ public void setItems(List<ComponentRef> value) { this.items = value; }
13+}
Agraphql-java-lombokdefault / src / main / java / io / quicktype / TopLevel.java+19 −0
@@ -0,0 +1,19 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+import java.util.List;
5+
6+public class TopLevel {
7+ private Data data;
8+ private List<Error> errors;
9+
10+ @JsonProperty("data")
11+ public Data getData() { return data; }
12+ @JsonProperty("data")
13+ public void setData(Data value) { this.data = value; }
14+
15+ @JsonProperty("errors")
16+ public List<Error> getErrors() { return errors; }
17+ @JsonProperty("errors")
18+ public void setErrors(List<Error> value) { this.errors = value; }
19+}
Agraphql-javadefault / src / main / java / io / quicktype / ComponentRef.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class ComponentRef {
6+ private String id;
7+
8+ @JsonProperty("id")
9+ public String getID() { return id; }
10+ @JsonProperty("id")
11+ public void setID(String value) { this.id = value; }
12+}
Agraphql-javadefault / src / main / java / io / quicktype / Converter.java+101 −0
@@ -0,0 +1,101 @@
1+// To use this code, add the following Maven dependency to your project:
2+//
3+//
4+// com.fasterxml.jackson.core : jackson-databind : 2.9.0
5+// com.fasterxml.jackson.datatype : jackson-datatype-jsr310 : 2.9.0
6+//
7+// Import this package:
8+//
9+// import io.quicktype.Converter;
10+//
11+// Then you can deserialize a JSON string with
12+//
13+// TopLevel data = Converter.fromJsonString(jsonString);
14+
15+package io.quicktype;
16+
17+import java.io.IOException;
18+import com.fasterxml.jackson.databind.*;
19+import com.fasterxml.jackson.databind.module.SimpleModule;
20+import com.fasterxml.jackson.core.JsonParser;
21+import com.fasterxml.jackson.core.JsonProcessingException;
22+import java.util.*;
23+import java.time.LocalDate;
24+import java.time.OffsetDateTime;
25+import java.time.OffsetTime;
26+import java.time.ZoneOffset;
27+import java.time.ZonedDateTime;
28+import java.time.format.DateTimeFormatter;
29+import java.time.format.DateTimeFormatterBuilder;
30+import java.time.temporal.ChronoField;
31+
32+public class Converter {
33+ // Date-time helpers
34+
35+ private static final DateTimeFormatter DATE_TIME_FORMATTER = new DateTimeFormatterBuilder()
36+ .appendOptional(DateTimeFormatter.ISO_DATE_TIME)
37+ .appendOptional(DateTimeFormatter.ISO_OFFSET_DATE_TIME)
38+ .appendOptional(DateTimeFormatter.ISO_INSTANT)
39+ .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SX"))
40+ .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ssX"))
41+ .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
42+ .toFormatter()
43+ .withZone(ZoneOffset.UTC);
44+
45+ public static OffsetDateTime parseDateTimeString(String str) {
46+ return ZonedDateTime.from(Converter.DATE_TIME_FORMATTER.parse(str)).toOffsetDateTime();
47+ }
48+
49+ private static final DateTimeFormatter TIME_FORMATTER = new DateTimeFormatterBuilder()
50+ .appendOptional(DateTimeFormatter.ISO_TIME)
51+ .appendOptional(DateTimeFormatter.ISO_OFFSET_TIME)
52+ .parseDefaulting(ChronoField.YEAR, 2020)
53+ .parseDefaulting(ChronoField.MONTH_OF_YEAR, 1)
54+ .parseDefaulting(ChronoField.DAY_OF_MONTH, 1)
55+ .toFormatter()
56+ .withZone(ZoneOffset.UTC);
57+
58+ public static OffsetTime parseTimeString(String str) {
59+ return ZonedDateTime.from(Converter.TIME_FORMATTER.parse(str)).toOffsetDateTime().toOffsetTime();
60+ }
61+ // Serialize/deserialize helpers
62+
63+ public static TopLevel fromJsonString(String json) throws IOException {
64+ return getObjectReader().readValue(json);
65+ }
66+
67+ public static String toJsonString(TopLevel obj) throws JsonProcessingException {
68+ return getObjectWriter().writeValueAsString(obj);
69+ }
70+
71+ private static ObjectReader reader;
72+ private static ObjectWriter writer;
73+
74+ private static void instantiateMapper() {
75+ ObjectMapper mapper = new ObjectMapper();
76+ mapper.findAndRegisterModules();
77+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
78+ mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
79+ SimpleModule module = new SimpleModule();
80+ module.addDeserializer(OffsetDateTime.class, new JsonDeserializer<OffsetDateTime>() {
81+ @Override
82+ public OffsetDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
83+ String value = jsonParser.getText();
84+ return Converter.parseDateTimeString(value);
85+ }
86+ });
87+ mapper.registerModule(module);
88+ reader = mapper.readerFor(TopLevel.class);
89+ writer = mapper.writerFor(TopLevel.class);
90+ }
91+
92+ private static ObjectReader getObjectReader() {
93+ if (reader == null) instantiateMapper();
94+ return reader;
95+ }
96+
97+ private static ObjectWriter getObjectWriter() {
98+ if (writer == null) instantiateMapper();
99+ return writer;
100+ }
101+}
Agraphql-javadefault / src / main / java / io / quicktype / Data.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class Data {
6+ private Grid grid;
7+
8+ @JsonProperty("grid")
9+ public Grid getGrid() { return grid; }
10+ @JsonProperty("grid")
11+ public void setGrid(Grid value) { this.grid = value; }
12+}
Agraphql-javadefault / src / main / java / io / quicktype / Error.java+12 −0
@@ -0,0 +1,12 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class Error {
6+ private String message;
7+
8+ @JsonProperty("message")
9+ public String getMessage() { return message; }
10+ @JsonProperty("message")
11+ public void setMessage(String value) { this.message = value; }
12+}
Agraphql-javadefault / src / main / java / io / quicktype / Grid.java+18 −0
@@ -0,0 +1,18 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class Grid {
6+ private GridConfig config;
7+ private GridProps props;
8+
9+ @JsonProperty("config")
10+ public GridConfig getConfig() { return config; }
11+ @JsonProperty("config")
12+ public void setConfig(GridConfig value) { this.config = value; }
13+
14+ @JsonProperty("props")
15+ public GridProps getProps() { return props; }
16+ @JsonProperty("props")
17+ public void setProps(GridProps value) { this.props = value; }
18+}
Agraphql-javadefault / src / main / java / io / quicktype / GridConfig.java+13 −0
@@ -0,0 +1,13 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+import java.util.List;
5+
6+public class GridConfig {
7+ private List<ComponentRef> items;
8+
9+ @JsonProperty("items")
10+ public List<ComponentRef> getItems() { return items; }
11+ @JsonProperty("items")
12+ public void setItems(List<ComponentRef> value) { this.items = value; }
13+}
Agraphql-javadefault / src / main / java / io / quicktype / GridProps.java+13 −0
@@ -0,0 +1,13 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+import java.util.List;
5+
6+public class GridProps {
7+ private List<ComponentRef> items;
8+
9+ @JsonProperty("items")
10+ public List<ComponentRef> getItems() { return items; }
11+ @JsonProperty("items")
12+ public void setItems(List<ComponentRef> value) { this.items = value; }
13+}
Agraphql-javadefault / src / main / java / io / quicktype / TopLevel.java+19 −0
@@ -0,0 +1,19 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+import java.util.List;
5+
6+public class TopLevel {
7+ private Data data;
8+ private List<Error> errors;
9+
10+ @JsonProperty("data")
11+ public Data getData() { return data; }
12+ @JsonProperty("data")
13+ public void setData(Data value) { this.data = value; }
14+
15+ @JsonProperty("errors")
16+ public List<Error> getErrors() { return errors; }
17+ @JsonProperty("errors")
18+ public void setErrors(List<Error> value) { this.errors = value; }
19+}
Agraphql-javascriptdefault / TopLevel.js+202 −0
@@ -0,0 +1,202 @@
1+// To parse this data:
2+//
3+// const Convert = require("./TopLevel");
4+//
5+// const topLevel = Convert.toTopLevel(json);
6+//
7+// These functions will throw an error if the JSON doesn't
8+// match the expected interface, even if the JSON is valid.
9+
10+// Converts JSON strings to/from your types
11+// and asserts the results of JSON.parse at runtime
12+function toTopLevel(json) {
13+ return cast(JSON.parse(json), r("TopLevel"));
14+}
15+
16+function topLevelToJson(value) {
17+ return JSON.stringify(uncast(value, r("TopLevel")), null, 2);
18+}
19+
20+function invalidValue(typ, val, key, parent = '') {
21+ const prettyTyp = prettyTypeName(typ);
22+ const parentText = parent ? ` on ${parent}` : '';
23+ const keyText = key ? ` for key "${key}"` : '';
24+ throw Error(`Invalid value${keyText}${parentText}. Expected ${prettyTyp} but got ${JSON.stringify(val)}`);
25+}
26+
27+function prettyTypeName(typ) {
28+ if (Array.isArray(typ)) {
29+ if (typ.length === 2 && typ[0] === undefined) {
30+ return `an optional ${prettyTypeName(typ[1])}`;
31+ } else {
32+ return `one of [${typ.map(a => { return prettyTypeName(a); }).join(", ")}]`;
33+ }
34+ } else if (typeof typ === "object" && typ.literal !== undefined) {
35+ return typ.literal;
36+ } else {
37+ return typeof typ;
38+ }
39+}
40+
41+function jsonToJSProps(typ) {
42+ if (typ.jsonToJS === undefined) {
43+ const map = {};
44+ typ.props.forEach((p) => map[p.json] = { key: p.js, typ: p.typ });
45+ typ.jsonToJS = map;
46+ }
47+ return typ.jsonToJS;
48+}
49+
50+function jsToJSONProps(typ) {
51+ if (typ.jsToJSON === undefined) {
52+ const map = {};
53+ typ.props.forEach((p) => map[p.js] = { key: p.json, typ: p.typ });
54+ typ.jsToJSON = map;
55+ }
56+ return typ.jsToJSON;
57+}
58+
59+function transform(val, typ, getProps, key = '', parent = '') {
60+ function transformPrimitive(typ, val) {
61+ if (typeof typ === typeof val) return val;
62+ return invalidValue(typ, val, key, parent);
63+ }
64+
65+ function transformUnion(typs, val) {
66+ // val must validate against one typ in typs
67+ const l = typs.length;
68+ for (let i = 0; i < l; i++) {
69+ const typ = typs[i];
70+ try {
71+ return transform(val, typ, getProps);
72+ } catch (_) {}
73+ }
74+ return invalidValue(typs, val, key, parent);
75+ }
76+
77+ function transformEnum(cases, val) {
78+ if (cases.indexOf(val) !== -1) return val;
79+ return invalidValue(cases.map(a => { return l(a); }), val, key, parent);
80+ }
81+
82+ function transformArray(typ, val) {
83+ // val must be an array with no invalid elements
84+ if (!Array.isArray(val)) return invalidValue(l("array"), val, key, parent);
85+ return val.map(el => transform(el, typ, getProps));
86+ }
87+
88+ function transformDate(val) {
89+ if (val === null) {
90+ return null;
91+ }
92+ const d = new Date(val);
93+ if (isNaN(d.valueOf())) {
94+ return invalidValue(l("Date"), val, key, parent);
95+ }
96+ return d;
97+ }
98+
99+ function transformObject(props, additional, val) {
100+ if (val === null || typeof val !== "object" || Array.isArray(val)) {
101+ return invalidValue(l(ref || "object"), val, key, parent);
102+ }
103+ const result = {};
104+ Object.getOwnPropertyNames(props).forEach(key => {
105+ const prop = props[key];
106+ const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
107+ result[prop.key] = transform(v, prop.typ, getProps, key, ref);
108+ });
109+ Object.getOwnPropertyNames(val).forEach(key => {
110+ if (!Object.prototype.hasOwnProperty.call(props, key)) {
111+ result[key] = transform(val[key], additional, getProps, key, ref);
112+ }
113+ });
114+ return result;
115+ }
116+
117+ if (typ === "any") return val;
118+ if (typ === null) {
119+ if (val === null) return val;
120+ return invalidValue(typ, val, key, parent);
121+ }
122+ if (typ === false) return invalidValue(typ, val, key, parent);
123+ let ref = undefined;
124+ while (typeof typ === "object" && typ.ref !== undefined) {
125+ ref = typ.ref;
126+ typ = typeMap[typ.ref];
127+ }
128+ if (Array.isArray(typ)) return transformEnum(typ, val);
129+ if (typeof typ === "object") {
130+ return typ.hasOwnProperty("unionMembers") ? transformUnion(typ.unionMembers, val)
131+ : typ.hasOwnProperty("arrayItems") ? transformArray(typ.arrayItems, val)
132+ : typ.hasOwnProperty("props") ? transformObject(getProps(typ), typ.additional, val)
133+ : invalidValue(typ, val, key, parent);
134+ }
135+ // Numbers can be parsed by Date but shouldn't be.
136+ if (typ === Date && typeof val !== "number") return transformDate(val);
137+ return transformPrimitive(typ, val);
138+}
139+
140+function cast(val, typ) {
141+ return transform(val, typ, jsonToJSProps);
142+}
143+
144+function uncast(val, typ) {
145+ return transform(val, typ, jsToJSONProps);
146+}
147+
148+function l(typ) {
149+ return { literal: typ };
150+}
151+
152+function a(typ) {
153+ return { arrayItems: typ };
154+}
155+
156+function u(...typs) {
157+ return { unionMembers: typs };
158+}
159+
160+function o(props, additional) {
161+ return { props, additional };
162+}
163+
164+function m(additional) {
165+ const props = [];
166+ return { props, additional };
167+}
168+
169+function r(name) {
170+ return { ref: name };
171+}
172+
173+const typeMap = {
174+ "TopLevel": o([
175+ { json: "data", js: "data", typ: u(r("Data"), null) },
176+ { json: "errors", js: "errors", typ: u(undefined, a(r("Error"))) },
177+ ], false),
178+ "Data": o([
179+ { json: "grid", js: "grid", typ: u(r("Grid"), null) },
180+ ], false),
181+ "Grid": o([
182+ { json: "config", js: "config", typ: u(r("GridConfig"), null) },
183+ { json: "props", js: "props", typ: u(r("GridProps"), null) },
184+ ], false),
185+ "GridConfig": o([
186+ { json: "items", js: "items", typ: u(a(u(r("ComponentRef"), null)), null) },
187+ ], false),
188+ "ComponentRef": o([
189+ { json: "id", js: "id", typ: u(null, "") },
190+ ], false),
191+ "GridProps": o([
192+ { json: "items", js: "items", typ: u(a(u(r("ComponentRef"), null)), null) },
193+ ], false),
194+ "Error": o([
195+ { json: "message", js: "message", typ: "" },
196+ ], false),
197+};
198+
199+module.exports = {
200+ "topLevelToJson": topLevelToJson,
201+ "toTopLevel": toTopLevel,
202+};
Agraphql-objective-cdefault / QTTopLevel.h+62 −0
@@ -0,0 +1,62 @@
1+// To parse this JSON:
2+//
3+// NSError *error;
4+// QTTopLevel *topLevel = [QTTopLevel fromJSON:json encoding:NSUTF8Encoding error:&error];
5+
6+#import <Foundation/Foundation.h>
7+
8+@class QTTopLevel;
9+@class QTData;
10+@class QTGrid;
11+@class QTGridConfig;
12+@class QTComponentRef;
13+@class QTGridProps;
14+@class QTError;
15+
16+NS_ASSUME_NONNULL_BEGIN
17+
18+#pragma mark - Top-level marshaling functions
19+
20+QTTopLevel *_Nullable QTTopLevelFromData(NSData *data, NSError **error);
21+QTTopLevel *_Nullable QTTopLevelFromJSON(NSString *json, NSStringEncoding encoding, NSError **error);
22+NSData *_Nullable QTTopLevelToData(QTTopLevel *topLevel, NSError **error);
23+NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding encoding, NSError **error);
24+
25+#pragma mark - Object interfaces
26+
27+@interface QTTopLevel : NSObject
28+@property (nonatomic, nullable, strong) QTData *data;
29+@property (nonatomic, nullable, copy) NSArray<QTError *> *errors;
30+
31++ (_Nullable instancetype)fromJSON:(NSString *)json encoding:(NSStringEncoding)encoding error:(NSError *_Nullable *)error;
32++ (_Nullable instancetype)fromData:(NSData *)data error:(NSError *_Nullable *)error;
33+- (NSString *_Nullable)toJSON:(NSStringEncoding)encoding error:(NSError *_Nullable *)error;
34+- (NSData *_Nullable)toData:(NSError *_Nullable *)error;
35+@end
36+
37+@interface QTData : NSObject
38+@property (nonatomic, nullable, strong) QTGrid *grid;
39+@end
40+
41+@interface QTGrid : NSObject
42+@property (nonatomic, nullable, strong) QTGridConfig *config;
43+@property (nonatomic, nullable, strong) QTGridProps *props;
44+@end
45+
46+@interface QTGridConfig : NSObject
47+@property (nonatomic, nullable, copy) NSArray<QTComponentRef *> *items;
48+@end
49+
50+@interface QTComponentRef : NSObject
51+@property (nonatomic, nullable, copy) NSString *identifier;
52+@end
53+
54+@interface QTGridProps : NSObject
55+@property (nonatomic, nullable, copy) NSArray<QTComponentRef *> *items;
56+@end
57+
58+@interface QTError : NSObject
59+@property (nonatomic, copy) NSString *message;
60+@end
61+
62+NS_ASSUME_NONNULL_END
Agraphql-objective-cdefault / QTTopLevel.m+445 −0
@@ -0,0 +1,445 @@
1+#import "QTTopLevel.h"
2+
3+#define λ(decl, expr) (^(decl) { return (expr); })
4+
5+static id NSNullify(id _Nullable x) {
6+ return (x == nil || x == NSNull.null) ? NSNull.null : x;
7+}
8+
9+NS_ASSUME_NONNULL_BEGIN
10+
11+@interface QTTopLevel (JSONConversion)
12++ (instancetype)fromJSONDictionary:(NSDictionary *)dict;
13+- (NSDictionary *)JSONDictionary;
14+@end
15+
16+@interface QTData (JSONConversion)
17++ (instancetype)fromJSONDictionary:(NSDictionary *)dict;
18+- (NSDictionary *)JSONDictionary;
19+@end
20+
21+@interface QTGrid (JSONConversion)
22++ (instancetype)fromJSONDictionary:(NSDictionary *)dict;
23+- (NSDictionary *)JSONDictionary;
24+@end
25+
26+@interface QTGridConfig (JSONConversion)
27++ (instancetype)fromJSONDictionary:(NSDictionary *)dict;
28+- (NSDictionary *)JSONDictionary;
29+@end
30+
31+@interface QTComponentRef (JSONConversion)
32++ (instancetype)fromJSONDictionary:(NSDictionary *)dict;
33+- (NSDictionary *)JSONDictionary;
34+@end
35+
36+@interface QTGridProps (JSONConversion)
37++ (instancetype)fromJSONDictionary:(NSDictionary *)dict;
38+- (NSDictionary *)JSONDictionary;
39+@end
40+
41+@interface QTError (JSONConversion)
42++ (instancetype)fromJSONDictionary:(NSDictionary *)dict;
43+- (NSDictionary *)JSONDictionary;
44+@end
45+
46+static id map(id collection, id (^f)(id value)) {
47+ id result = nil;
48+ if ([collection isKindOfClass:NSArray.class]) {
49+ result = [NSMutableArray arrayWithCapacity:[collection count]];
50+ for (id x in collection) [result addObject:f(x)];
51+ } else if ([collection isKindOfClass:NSDictionary.class]) {
52+ result = [NSMutableDictionary dictionaryWithCapacity:[collection count]];
53+ for (id key in collection) [result setObject:f([collection objectForKey:key]) forKey:key];
54+ }
55+ return result;
56+}
57+
58+#pragma mark - JSON serialization
59+
60+QTTopLevel *_Nullable QTTopLevelFromData(NSData *data, NSError **error)
61+{
62+ @try {
63+ id json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:error];
64+ return *error ? nil : [QTTopLevel fromJSONDictionary:json];
65+ } @catch (NSException *exception) {
66+ *error = [NSError errorWithDomain:@"JSONSerialization" code:-1 userInfo:@{ @"exception": exception }];
67+ return nil;
68+ }
69+}
70+
71+QTTopLevel *_Nullable QTTopLevelFromJSON(NSString *json, NSStringEncoding encoding, NSError **error)
72+{
73+ return QTTopLevelFromData([json dataUsingEncoding:encoding], error);
74+}
75+
76+NSData *_Nullable QTTopLevelToData(QTTopLevel *topLevel, NSError **error)
77+{
78+ @try {
79+ id json = [topLevel JSONDictionary];
80+ NSData *data = [NSJSONSerialization dataWithJSONObject:json options:kNilOptions error:error];
81+ return *error ? nil : data;
82+ } @catch (NSException *exception) {
83+ *error = [NSError errorWithDomain:@"JSONSerialization" code:-1 userInfo:@{ @"exception": exception }];
84+ return nil;
85+ }
86+}
87+
88+NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding encoding, NSError **error)
89+{
90+ NSData *data = QTTopLevelToData(topLevel, error);
91+ return data ? [[NSString alloc] initWithData:data encoding:encoding] : nil;
92+}
93+
94+@implementation QTTopLevel
95++ (NSDictionary<NSString *, NSString *> *)properties
96+{
97+ static NSDictionary<NSString *, NSString *> *properties;
98+ return properties = properties ? properties : @{
99+ @"data": @"data",
100+ @"errors": @"errors",
101+ };
102+}
103+
104++ (_Nullable instancetype)fromData:(NSData *)data error:(NSError *_Nullable *)error
105+{
106+ return QTTopLevelFromData(data, error);
107+}
108+
109++ (_Nullable instancetype)fromJSON:(NSString *)json encoding:(NSStringEncoding)encoding error:(NSError *_Nullable *)error
110+{
111+ return QTTopLevelFromJSON(json, encoding, error);
112+}
113+
114++ (instancetype)fromJSONDictionary:(NSDictionary *)dict
115+{
116+ return dict ? [[QTTopLevel alloc] initWithJSONDictionary:dict] : nil;
117+}
118+
119+- (instancetype)initWithJSONDictionary:(NSDictionary *)dict
120+{
121+ if (self = [super init]) {
122+ [self setValuesForKeysWithDictionary:dict];
123+ _data = [QTData fromJSONDictionary:(id)_data];
124+ _errors = map(_errors, λ(id x, [QTError fromJSONDictionary:x]));
125+ }
126+ return self;
127+}
128+
129+- (void)setValue:(nullable id)value forKey:(NSString *)key
130+{
131+ id resolved = QTTopLevel.properties[key];
132+ if (resolved) [super setValue:value forKey:resolved];
133+}
134+
135+- (void)setNilValueForKey:(NSString *)key
136+{
137+ id resolved = QTTopLevel.properties[key];
138+ if (resolved) [super setValue:@(0) forKey:resolved];
139+}
140+
141+- (NSDictionary *)JSONDictionary
142+{
143+ id dict = [[self dictionaryWithValuesForKeys:QTTopLevel.properties.allValues] mutableCopy];
144+
145+ [dict addEntriesFromDictionary:@{
146+ @"data": NSNullify([_data JSONDictionary]),
147+ @"errors": NSNullify(map(_errors, λ(id x, [x JSONDictionary]))),
148+ }];
149+
150+ return dict;
151+}
152+
153+- (NSData *_Nullable)toData:(NSError *_Nullable *)error
154+{
155+ return QTTopLevelToData(self, error);
156+}
157+
158+- (NSString *_Nullable)toJSON:(NSStringEncoding)encoding error:(NSError *_Nullable *)error
159+{
160+ return QTTopLevelToJSON(self, encoding, error);
161+}
162+@end
163+
164+@implementation QTData
165++ (NSDictionary<NSString *, NSString *> *)properties
166+{
167+ static NSDictionary<NSString *, NSString *> *properties;
168+ return properties = properties ? properties : @{
169+ @"grid": @"grid",
170+ };
171+}
172+
173++ (instancetype)fromJSONDictionary:(NSDictionary *)dict
174+{
175+ return dict ? [[QTData alloc] initWithJSONDictionary:dict] : nil;
176+}
177+
178+- (instancetype)initWithJSONDictionary:(NSDictionary *)dict
179+{
180+ if (self = [super init]) {
181+ [self setValuesForKeysWithDictionary:dict];
182+ _grid = [QTGrid fromJSONDictionary:(id)_grid];
183+ }
184+ return self;
185+}
186+
187+- (void)setValue:(nullable id)value forKey:(NSString *)key
188+{
189+ id resolved = QTData.properties[key];
190+ if (resolved) [super setValue:value forKey:resolved];
191+}
192+
193+- (void)setNilValueForKey:(NSString *)key
194+{
195+ id resolved = QTData.properties[key];
196+ if (resolved) [super setValue:@(0) forKey:resolved];
197+}
198+
199+- (NSDictionary *)JSONDictionary
200+{
201+ id dict = [[self dictionaryWithValuesForKeys:QTData.properties.allValues] mutableCopy];
202+
203+ [dict addEntriesFromDictionary:@{
204+ @"grid": NSNullify([_grid JSONDictionary]),
205+ }];
206+
207+ return dict;
208+}
209+@end
210+
211+@implementation QTGrid
212++ (NSDictionary<NSString *, NSString *> *)properties
213+{
214+ static NSDictionary<NSString *, NSString *> *properties;
215+ return properties = properties ? properties : @{
216+ @"config": @"config",
217+ @"props": @"props",
218+ };
219+}
220+
221++ (instancetype)fromJSONDictionary:(NSDictionary *)dict
222+{
223+ return dict ? [[QTGrid alloc] initWithJSONDictionary:dict] : nil;
224+}
225+
226+- (instancetype)initWithJSONDictionary:(NSDictionary *)dict
227+{
228+ if (self = [super init]) {
229+ [self setValuesForKeysWithDictionary:dict];
230+ _config = [QTGridConfig fromJSONDictionary:(id)_config];
231+ _props = [QTGridProps fromJSONDictionary:(id)_props];
232+ }
233+ return self;
234+}
235+
236+- (void)setValue:(nullable id)value forKey:(NSString *)key
237+{
238+ id resolved = QTGrid.properties[key];
239+ if (resolved) [super setValue:value forKey:resolved];
240+}
241+
242+- (void)setNilValueForKey:(NSString *)key
243+{
244+ id resolved = QTGrid.properties[key];
245+ if (resolved) [super setValue:@(0) forKey:resolved];
246+}
247+
248+- (NSDictionary *)JSONDictionary
249+{
250+ id dict = [[self dictionaryWithValuesForKeys:QTGrid.properties.allValues] mutableCopy];
251+
252+ [dict addEntriesFromDictionary:@{
253+ @"config": NSNullify([_config JSONDictionary]),
254+ @"props": NSNullify([_props JSONDictionary]),
255+ }];
256+
257+ return dict;
258+}
259+@end
260+
261+@implementation QTGridConfig
262++ (NSDictionary<NSString *, NSString *> *)properties
263+{
264+ static NSDictionary<NSString *, NSString *> *properties;
265+ return properties = properties ? properties : @{
266+ @"items": @"items",
267+ };
268+}
269+
270++ (instancetype)fromJSONDictionary:(NSDictionary *)dict
271+{
272+ return dict ? [[QTGridConfig alloc] initWithJSONDictionary:dict] : nil;
273+}
274+
275+- (instancetype)initWithJSONDictionary:(NSDictionary *)dict
276+{
277+ if (self = [super init]) {
278+ [self setValuesForKeysWithDictionary:dict];
279+ _items = map(_items, λ(id x, [QTComponentRef fromJSONDictionary:x]));
280+ }
281+ return self;
282+}
283+
284+- (void)setValue:(nullable id)value forKey:(NSString *)key
285+{
286+ id resolved = QTGridConfig.properties[key];
287+ if (resolved) [super setValue:value forKey:resolved];
288+}
289+
290+- (void)setNilValueForKey:(NSString *)key
291+{
292+ id resolved = QTGridConfig.properties[key];
293+ if (resolved) [super setValue:@(0) forKey:resolved];
294+}
295+
296+- (NSDictionary *)JSONDictionary
297+{
298+ id dict = [[self dictionaryWithValuesForKeys:QTGridConfig.properties.allValues] mutableCopy];
299+
300+ [dict addEntriesFromDictionary:@{
301+ @"items": NSNullify(map(_items, λ(id x, NSNullify([x JSONDictionary])))),
302+ }];
303+
304+ return dict;
305+}
306+@end
307+
308+@implementation QTComponentRef
309++ (NSDictionary<NSString *, NSString *> *)properties
310+{
311+ static NSDictionary<NSString *, NSString *> *properties;
312+ return properties = properties ? properties : @{
313+ @"id": @"identifier",
314+ };
315+}
316+
317++ (instancetype)fromJSONDictionary:(NSDictionary *)dict
318+{
319+ return dict ? [[QTComponentRef alloc] initWithJSONDictionary:dict] : nil;
320+}
321+
322+- (instancetype)initWithJSONDictionary:(NSDictionary *)dict
323+{
324+ if (self = [super init]) {
325+ [self setValuesForKeysWithDictionary:dict];
326+ }
327+ return self;
328+}
329+
330+- (void)setValue:(nullable id)value forKey:(NSString *)key
331+{
332+ id resolved = QTComponentRef.properties[key];
333+ if (resolved) [super setValue:value forKey:resolved];
334+}
335+
336+- (void)setNilValueForKey:(NSString *)key
337+{
338+ id resolved = QTComponentRef.properties[key];
339+ if (resolved) [super setValue:@(0) forKey:resolved];
340+}
341+
342+- (NSDictionary *)JSONDictionary
343+{
344+ id dict = [[self dictionaryWithValuesForKeys:QTComponentRef.properties.allValues] mutableCopy];
345+
346+ for (id jsonName in QTComponentRef.properties) {
347+ id propertyName = QTComponentRef.properties[jsonName];
348+ if (![jsonName isEqualToString:propertyName]) {
349+ dict[jsonName] = dict[propertyName];
350+ [dict removeObjectForKey:propertyName];
351+ }
352+ }
353+
354+ return dict;
355+}
356+@end
357+
358+@implementation QTGridProps
359++ (NSDictionary<NSString *, NSString *> *)properties
360+{
361+ static NSDictionary<NSString *, NSString *> *properties;
362+ return properties = properties ? properties : @{
363+ @"items": @"items",
364+ };
365+}
366+
367++ (instancetype)fromJSONDictionary:(NSDictionary *)dict
368+{
369+ return dict ? [[QTGridProps alloc] initWithJSONDictionary:dict] : nil;
370+}
371+
372+- (instancetype)initWithJSONDictionary:(NSDictionary *)dict
373+{
374+ if (self = [super init]) {
375+ [self setValuesForKeysWithDictionary:dict];
376+ _items = map(_items, λ(id x, [QTComponentRef fromJSONDictionary:x]));
377+ }
378+ return self;
379+}
380+
381+- (void)setValue:(nullable id)value forKey:(NSString *)key
382+{
383+ id resolved = QTGridProps.properties[key];
384+ if (resolved) [super setValue:value forKey:resolved];
385+}
386+
387+- (void)setNilValueForKey:(NSString *)key
388+{
389+ id resolved = QTGridProps.properties[key];
390+ if (resolved) [super setValue:@(0) forKey:resolved];
391+}
392+
393+- (NSDictionary *)JSONDictionary
394+{
395+ id dict = [[self dictionaryWithValuesForKeys:QTGridProps.properties.allValues] mutableCopy];
396+
397+ [dict addEntriesFromDictionary:@{
398+ @"items": NSNullify(map(_items, λ(id x, NSNullify([x JSONDictionary])))),
399+ }];
400+
401+ return dict;
402+}
403+@end
404+
405+@implementation QTError
406++ (NSDictionary<NSString *, NSString *> *)properties
407+{
408+ static NSDictionary<NSString *, NSString *> *properties;
409+ return properties = properties ? properties : @{
410+ @"message": @"message",
411+ };
412+}
413+
414++ (instancetype)fromJSONDictionary:(NSDictionary *)dict
415+{
416+ return dict ? [[QTError alloc] initWithJSONDictionary:dict] : nil;
417+}
418+
419+- (instancetype)initWithJSONDictionary:(NSDictionary *)dict
420+{
421+ if (self = [super init]) {
422+ [self setValuesForKeysWithDictionary:dict];
423+ }
424+ return self;
425+}
426+
427+- (void)setValue:(nullable id)value forKey:(NSString *)key
428+{
429+ id resolved = QTError.properties[key];
430+ if (resolved) [super setValue:value forKey:resolved];
431+}
432+
433+- (void)setNilValueForKey:(NSString *)key
434+{
435+ id resolved = QTError.properties[key];
436+ if (resolved) [super setValue:@(0) forKey:resolved];
437+}
438+
439+- (NSDictionary *)JSONDictionary
440+{
441+ return [self dictionaryWithValuesForKeys:QTError.properties.allValues];
442+}
443+@end
444+
445+NS_ASSUME_NONNULL_END
Agraphql-phpdefault / TopLevel.php+936 −0
@@ -0,0 +1,936 @@
1+<?php
2+declare(strict_types=1);
3+
4+// This is an autogenerated file:TopLevel
5+
6+class TopLevel {
7+ private ?Data $data; // json:data Optional
8+ private ?array $errors; // json:errors Optional
9+
10+ /**
11+ * @param Data|null $data
12+ * @param array|null $errors
13+ */
14+ public function __construct(?Data $data, ?array $errors) {
15+ $this->data = $data;
16+ $this->errors = $errors;
17+ }
18+
19+ /**
20+ * @param ?stdClass $value
21+ * @throws Exception
22+ * @return ?Data
23+ */
24+ public static function fromData(?stdClass $value): ?Data {
25+ if (!is_null($value)) {
26+ return Data::from($value); /*class*/
27+ } else {
28+ return null;
29+ }
30+ }
31+
32+ /**
33+ * @throws Exception
34+ * @return ?stdClass
35+ */
36+ public function toData(): ?stdClass {
37+ if (TopLevel::validateData($this->data)) {
38+ if (!is_null($this->data)) {
39+ return $this->data->to(); /*class*/
40+ } else {
41+ return null;
42+ }
43+ }
44+ throw new Exception('never get to this TopLevel::data');
45+ }
46+
47+ /**
48+ * @param Data|null
49+ * @return bool
50+ * @throws Exception
51+ */
52+ public static function validateData(?Data $value): bool {
53+ if (!is_null($value)) {
54+ $value->validate();
55+ }
56+ return true;
57+ }
58+
59+ /**
60+ * @throws Exception
61+ * @return ?Data
62+ */
63+ public function getData(): ?Data {
64+ if (TopLevel::validateData($this->data)) {
65+ return $this->data;
66+ }
67+ throw new Exception('never get to getData TopLevel::data');
68+ }
69+
70+ /**
71+ * @return ?Data
72+ */
73+ public static function sampleData(): ?Data {
74+ return Data::sample(); /*31:data*/
75+ }
76+
77+ /**
78+ * @param ?array $value
79+ * @throws Exception
80+ * @return ?array
81+ */
82+ public static function fromErrors(?array $value): ?array {
83+ if (!is_null($value)) {
84+ return array_map(function ($value) {
85+ return Error::from($value); /*class*/
86+ }, $value);
87+ } else {
88+ return null;
89+ }
90+ }
91+
92+ /**
93+ * @throws Exception
94+ * @return ?array
95+ */
96+ public function toErrors(): ?array {
97+ if (TopLevel::validateErrors($this->errors)) {
98+ if (!is_null($this->errors)) {
99+ return array_map(function ($value) {
100+ return $value->to(); /*class*/
101+ }, $this->errors);
102+ } else {
103+ return null;
104+ }
105+ }
106+ throw new Exception('never get to this TopLevel::errors');
107+ }
108+
109+ /**
110+ * @param array|null
111+ * @return bool
112+ * @throws Exception
113+ */
114+ public static function validateErrors(?array $value): bool {
115+ if (!is_null($value)) {
116+ if (!is_array($value)) {
117+ throw new Exception("Attribute Error:TopLevel::errors");
118+ }
119+ array_walk($value, function($value_v) {
120+ $value_v->validate();
121+ });
122+ }
123+ return true;
124+ }
125+
126+ /**
127+ * @throws Exception
128+ * @return ?array
129+ */
130+ public function getErrors(): ?array {
131+ if (TopLevel::validateErrors($this->errors)) {
132+ return $this->errors;
133+ }
134+ throw new Exception('never get to getErrors TopLevel::errors');
135+ }
136+
137+ /**
138+ * @return ?array
139+ */
140+ public static function sampleErrors(): ?array {
141+ return array(
142+ Error::sample() /*32:*/
143+ ); /* 32:errors*/
144+ }
145+
146+ /**
147+ * @throws Exception
148+ * @return bool
149+ */
150+ public function validate(): bool {
151+ return TopLevel::validateData($this->data)
152+ || TopLevel::validateErrors($this->errors);
153+ }
154+
155+ /**
156+ * @return stdClass
157+ * @throws Exception
158+ */
159+ public function to(): stdClass {
160+ $out = new stdClass();
161+ $out->{'data'} = $this->toData();
162+ $out->{'errors'} = $this->toErrors();
163+ return $out;
164+ }
165+
166+ /**
167+ * @param stdClass $obj
168+ * @return TopLevel
169+ * @throws Exception
170+ */
171+ public static function from(stdClass $obj): TopLevel {
172+ return new TopLevel(
173+ TopLevel::fromData($obj->{'data'})
174+ ,TopLevel::fromErrors($obj->{'errors'})
175+ );
176+ }
177+
178+ /**
179+ * @return TopLevel
180+ */
181+ public static function sample(): TopLevel {
182+ return new TopLevel(
183+ TopLevel::sampleData()
184+ ,TopLevel::sampleErrors()
185+ );
186+ }
187+}
188+
189+// This is an autogenerated file:Data
190+
191+class Data {
192+ private ?Grid $grid; // json:grid Optional
193+
194+ /**
195+ * @param Grid|null $grid
196+ */
197+ public function __construct(?Grid $grid) {
198+ $this->grid = $grid;
199+ }
200+
201+ /**
202+ * @param ?stdClass $value
203+ * @throws Exception
204+ * @return ?Grid
205+ */
206+ public static function fromGrid(?stdClass $value): ?Grid {
207+ if (!is_null($value)) {
208+ return Grid::from($value); /*class*/
209+ } else {
210+ return null;
211+ }
212+ }
213+
214+ /**
215+ * @throws Exception
216+ * @return ?stdClass
217+ */
218+ public function toGrid(): ?stdClass {
219+ if (Data::validateGrid($this->grid)) {
220+ if (!is_null($this->grid)) {
221+ return $this->grid->to(); /*class*/
222+ } else {
223+ return null;
224+ }
225+ }
226+ throw new Exception('never get to this Data::grid');
227+ }
228+
229+ /**
230+ * @param Grid|null
231+ * @return bool
232+ * @throws Exception
233+ */
234+ public static function validateGrid(?Grid $value): bool {
235+ if (!is_null($value)) {
236+ $value->validate();
237+ }
238+ return true;
239+ }
240+
241+ /**
242+ * @throws Exception
243+ * @return ?Grid
244+ */
245+ public function getGrid(): ?Grid {
246+ if (Data::validateGrid($this->grid)) {
247+ return $this->grid;
248+ }
249+ throw new Exception('never get to getGrid Data::grid');
250+ }
251+
252+ /**
253+ * @return ?Grid
254+ */
255+ public static function sampleGrid(): ?Grid {
256+ return Grid::sample(); /*31:grid*/
257+ }
258+
259+ /**
260+ * @throws Exception
261+ * @return bool
262+ */
263+ public function validate(): bool {
264+ return Data::validateGrid($this->grid);
265+ }
266+
267+ /**
268+ * @return stdClass
269+ * @throws Exception
270+ */
271+ public function to(): stdClass {
272+ $out = new stdClass();
273+ $out->{'grid'} = $this->toGrid();
274+ return $out;
275+ }
276+
277+ /**
278+ * @param stdClass $obj
279+ * @return Data
280+ * @throws Exception
281+ */
282+ public static function from(stdClass $obj): Data {
283+ return new Data(
284+ Data::fromGrid($obj->{'grid'})
285+ );
286+ }
287+
288+ /**
289+ * @return Data
290+ */
291+ public static function sample(): Data {
292+ return new Data(
293+ Data::sampleGrid()
294+ );
295+ }
296+}
297+
298+// This is an autogenerated file:Grid
299+
300+class Grid {
301+ private ?GridConfig $config; // json:config Optional
302+ private ?GridProps $props; // json:props Optional
303+
304+ /**
305+ * @param GridConfig|null $config
306+ * @param GridProps|null $props
307+ */
308+ public function __construct(?GridConfig $config, ?GridProps $props) {
309+ $this->config = $config;
310+ $this->props = $props;
311+ }
312+
313+ /**
314+ * @param ?stdClass $value
315+ * @throws Exception
316+ * @return ?GridConfig
317+ */
318+ public static function fromConfig(?stdClass $value): ?GridConfig {
319+ if (!is_null($value)) {
320+ return GridConfig::from($value); /*class*/
321+ } else {
322+ return null;
323+ }
324+ }
325+
326+ /**
327+ * @throws Exception
328+ * @return ?stdClass
329+ */
330+ public function toConfig(): ?stdClass {
331+ if (Grid::validateConfig($this->config)) {
332+ if (!is_null($this->config)) {
333+ return $this->config->to(); /*class*/
334+ } else {
335+ return null;
336+ }
337+ }
338+ throw new Exception('never get to this Grid::config');
339+ }
340+
341+ /**
342+ * @param GridConfig|null
343+ * @return bool
344+ * @throws Exception
345+ */
346+ public static function validateConfig(?GridConfig $value): bool {
347+ if (!is_null($value)) {
348+ $value->validate();
349+ }
350+ return true;
351+ }
352+
353+ /**
354+ * @throws Exception
355+ * @return ?GridConfig
356+ */
357+ public function getConfig(): ?GridConfig {
358+ if (Grid::validateConfig($this->config)) {
359+ return $this->config;
360+ }
361+ throw new Exception('never get to getConfig Grid::config');
362+ }
363+
364+ /**
365+ * @return ?GridConfig
366+ */
367+ public static function sampleConfig(): ?GridConfig {
368+ return GridConfig::sample(); /*31:config*/
369+ }
370+
371+ /**
372+ * @param ?stdClass $value
373+ * @throws Exception
374+ * @return ?GridProps
375+ */
376+ public static function fromProps(?stdClass $value): ?GridProps {
377+ if (!is_null($value)) {
378+ return GridProps::from($value); /*class*/
379+ } else {
380+ return null;
381+ }
382+ }
383+
384+ /**
385+ * @throws Exception
386+ * @return ?stdClass
387+ */
388+ public function toProps(): ?stdClass {
389+ if (Grid::validateProps($this->props)) {
390+ if (!is_null($this->props)) {
391+ return $this->props->to(); /*class*/
392+ } else {
393+ return null;
394+ }
395+ }
396+ throw new Exception('never get to this Grid::props');
397+ }
398+
399+ /**
400+ * @param GridProps|null
401+ * @return bool
402+ * @throws Exception
403+ */
404+ public static function validateProps(?GridProps $value): bool {
405+ if (!is_null($value)) {
406+ $value->validate();
407+ }
408+ return true;
409+ }
410+
411+ /**
412+ * @throws Exception
413+ * @return ?GridProps
414+ */
415+ public function getProps(): ?GridProps {
416+ if (Grid::validateProps($this->props)) {
417+ return $this->props;
418+ }
419+ throw new Exception('never get to getProps Grid::props');
420+ }
421+
422+ /**
423+ * @return ?GridProps
424+ */
425+ public static function sampleProps(): ?GridProps {
426+ return GridProps::sample(); /*32:props*/
427+ }
428+
429+ /**
430+ * @throws Exception
431+ * @return bool
432+ */
433+ public function validate(): bool {
434+ return Grid::validateConfig($this->config)
435+ || Grid::validateProps($this->props);
436+ }
437+
438+ /**
439+ * @return stdClass
440+ * @throws Exception
441+ */
442+ public function to(): stdClass {
443+ $out = new stdClass();
444+ $out->{'config'} = $this->toConfig();
445+ $out->{'props'} = $this->toProps();
446+ return $out;
447+ }
448+
449+ /**
450+ * @param stdClass $obj
451+ * @return Grid
452+ * @throws Exception
453+ */
454+ public static function from(stdClass $obj): Grid {
455+ return new Grid(
456+ Grid::fromConfig($obj->{'config'})
457+ ,Grid::fromProps($obj->{'props'})
458+ );
459+ }
460+
461+ /**
462+ * @return Grid
463+ */
464+ public static function sample(): Grid {
465+ return new Grid(
466+ Grid::sampleConfig()
467+ ,Grid::sampleProps()
468+ );
469+ }
470+}
471+
472+// This is an autogenerated file:GridConfig
473+
474+class GridConfig {
475+ private ?array $items; // json:items Optional
476+
477+ /**
478+ * @param array|null $items
479+ */
480+ public function __construct(?array $items) {
481+ $this->items = $items;
482+ }
483+
484+ /**
485+ * @param ?array $value
486+ * @throws Exception
487+ * @return ?array
488+ */
489+ public static function fromItems(?array $value): ?array {
490+ if (!is_null($value)) {
491+ return array_map(function ($value) {
492+ if (!is_null($value)) {
493+ return ComponentRef::from($value); /*class*/
494+ } else {
495+ return null;
496+ }
497+ }, $value);
498+ } else {
499+ return null;
500+ }
501+ }
502+
503+ /**
504+ * @throws Exception
505+ * @return ?array
506+ */
507+ public function toItems(): ?array {
508+ if (GridConfig::validateItems($this->items)) {
509+ if (!is_null($this->items)) {
510+ return array_map(function ($value) {
511+ if (!is_null($value)) {
512+ return $value->to(); /*class*/
513+ } else {
514+ return null;
515+ }
516+ }, $this->items);
517+ } else {
518+ return null;
519+ }
520+ }
521+ throw new Exception('never get to this GridConfig::items');
522+ }
523+
524+ /**
525+ * @param array|null
526+ * @return bool
527+ * @throws Exception
528+ */
529+ public static function validateItems(?array $value): bool {
530+ if (!is_null($value)) {
531+ if (!is_array($value)) {
532+ throw new Exception("Attribute Error:GridConfig::items");
533+ }
534+ array_walk($value, function($value_v) {
535+ if (!is_null($value_v)) {
536+ $value_v->validate();
537+ }
538+ });
539+ }
540+ return true;
541+ }
542+
543+ /**
544+ * @throws Exception
545+ * @return ?array
546+ */
547+ public function getItems(): ?array {
548+ if (GridConfig::validateItems($this->items)) {
549+ return $this->items;
550+ }
551+ throw new Exception('never get to getItems GridConfig::items');
552+ }
553+
554+ /**
555+ * @return ?array
556+ */
557+ public static function sampleItems(): ?array {
558+ return array(
559+ ComponentRef::sample() /*31:*/
560+ ); /* 31:items*/
561+ }
562+
563+ /**
564+ * @throws Exception
565+ * @return bool
566+ */
567+ public function validate(): bool {
568+ return GridConfig::validateItems($this->items);
569+ }
570+
571+ /**
572+ * @return stdClass
573+ * @throws Exception
574+ */
575+ public function to(): stdClass {
576+ $out = new stdClass();
577+ $out->{'items'} = $this->toItems();
578+ return $out;
579+ }
580+
581+ /**
582+ * @param stdClass $obj
583+ * @return GridConfig
584+ * @throws Exception
585+ */
586+ public static function from(stdClass $obj): GridConfig {
587+ return new GridConfig(
588+ GridConfig::fromItems($obj->{'items'})
589+ );
590+ }
591+
592+ /**
593+ * @return GridConfig
594+ */
595+ public static function sample(): GridConfig {
596+ return new GridConfig(
597+ GridConfig::sampleItems()
598+ );
599+ }
600+}
601+
602+// This is an autogenerated file:ComponentRef
603+
604+class ComponentRef {
605+ private ?string $id; // json:id Optional
606+
607+ /**
608+ * @param string|null $id
609+ */
610+ public function __construct(?string $id) {
611+ $this->id = $id;
612+ }
613+
614+ /**
615+ * @param ?string $value
616+ * @throws Exception
617+ * @return ?string
618+ */
619+ public static function fromID(?string $value): ?string {
620+ if (!is_null($value)) {
621+ return $value; /*string*/
622+ } else {
623+ return null;
624+ }
625+ }
626+
627+ /**
628+ * @throws Exception
629+ * @return ?string
630+ */
631+ public function toID(): ?string {
632+ if (ComponentRef::validateID($this->id)) {
633+ if (!is_null($this->id)) {
634+ return $this->id; /*string*/
635+ } else {
636+ return null;
637+ }
638+ }
639+ throw new Exception('never get to this ComponentRef::id');
640+ }
641+
642+ /**
643+ * @param string|null
644+ * @return bool
645+ * @throws Exception
646+ */
647+ public static function validateID(?string $value): bool {
648+ if (!is_null($value)) {
649+ }
650+ return true;
651+ }
652+
653+ /**
654+ * @throws Exception
655+ * @return ?string
656+ */
657+ public function getID(): ?string {
658+ if (ComponentRef::validateID($this->id)) {
659+ return $this->id;
660+ }
661+ throw new Exception('never get to getID ComponentRef::id');
662+ }
663+
664+ /**
665+ * @return ?string
666+ */
667+ public static function sampleID(): ?string {
668+ return 'ComponentRef::id::31'; /*31:id*/
669+ }
670+
671+ /**
672+ * @throws Exception
673+ * @return bool
674+ */
675+ public function validate(): bool {
676+ return ComponentRef::validateID($this->id);
677+ }
678+
679+ /**
680+ * @return stdClass
681+ * @throws Exception
682+ */
683+ public function to(): stdClass {
684+ $out = new stdClass();
685+ $out->{'id'} = $this->toID();
686+ return $out;
687+ }
688+
689+ /**
690+ * @param stdClass $obj
691+ * @return ComponentRef
692+ * @throws Exception
693+ */
694+ public static function from(stdClass $obj): ComponentRef {
695+ return new ComponentRef(
696+ ComponentRef::fromID($obj->{'id'})
697+ );
698+ }
699+
700+ /**
701+ * @return ComponentRef
702+ */
703+ public static function sample(): ComponentRef {
704+ return new ComponentRef(
705+ ComponentRef::sampleID()
706+ );
707+ }
708+}
709+
710+// This is an autogenerated file:GridProps
711+
712+class GridProps {
713+ private ?array $items; // json:items Optional
714+
715+ /**
716+ * @param array|null $items
717+ */
718+ public function __construct(?array $items) {
719+ $this->items = $items;
720+ }
721+
722+ /**
723+ * @param ?array $value
724+ * @throws Exception
725+ * @return ?array
726+ */
727+ public static function fromItems(?array $value): ?array {
728+ if (!is_null($value)) {
729+ return array_map(function ($value) {
730+ if (!is_null($value)) {
731+ return ComponentRef::from($value); /*class*/
732+ } else {
733+ return null;
734+ }
735+ }, $value);
736+ } else {
737+ return null;
738+ }
739+ }
740+
741+ /**
742+ * @throws Exception
743+ * @return ?array
744+ */
745+ public function toItems(): ?array {
746+ if (GridProps::validateItems($this->items)) {
747+ if (!is_null($this->items)) {
748+ return array_map(function ($value) {
749+ if (!is_null($value)) {
750+ return $value->to(); /*class*/
751+ } else {
752+ return null;
753+ }
754+ }, $this->items);
755+ } else {
756+ return null;
757+ }
758+ }
759+ throw new Exception('never get to this GridProps::items');
760+ }
761+
762+ /**
763+ * @param array|null
764+ * @return bool
765+ * @throws Exception
766+ */
767+ public static function validateItems(?array $value): bool {
768+ if (!is_null($value)) {
769+ if (!is_array($value)) {
770+ throw new Exception("Attribute Error:GridProps::items");
771+ }
772+ array_walk($value, function($value_v) {
773+ if (!is_null($value_v)) {
774+ $value_v->validate();
775+ }
776+ });
777+ }
778+ return true;
779+ }
780+
781+ /**
782+ * @throws Exception
783+ * @return ?array
784+ */
785+ public function getItems(): ?array {
786+ if (GridProps::validateItems($this->items)) {
787+ return $this->items;
788+ }
789+ throw new Exception('never get to getItems GridProps::items');
790+ }
791+
792+ /**
793+ * @return ?array
794+ */
795+ public static function sampleItems(): ?array {
796+ return array(
797+ ComponentRef::sample() /*31:*/
798+ ); /* 31:items*/
799+ }
800+
801+ /**
802+ * @throws Exception
803+ * @return bool
804+ */
805+ public function validate(): bool {
806+ return GridProps::validateItems($this->items);
807+ }
808+
809+ /**
810+ * @return stdClass
811+ * @throws Exception
812+ */
813+ public function to(): stdClass {
814+ $out = new stdClass();
815+ $out->{'items'} = $this->toItems();
816+ return $out;
817+ }
818+
819+ /**
820+ * @param stdClass $obj
821+ * @return GridProps
822+ * @throws Exception
823+ */
824+ public static function from(stdClass $obj): GridProps {
825+ return new GridProps(
826+ GridProps::fromItems($obj->{'items'})
827+ );
828+ }
829+
830+ /**
831+ * @return GridProps
832+ */
833+ public static function sample(): GridProps {
834+ return new GridProps(
835+ GridProps::sampleItems()
836+ );
837+ }
838+}
839+
840+// This is an autogenerated file:Error
841+
842+class Error {
843+ private string $message; // json:message Required
844+
845+ /**
846+ * @param string $message
847+ */
848+ public function __construct(string $message) {
849+ $this->message = $message;
850+ }
851+
852+ /**
853+ * @param string $value
854+ * @throws Exception
855+ * @return string
856+ */
857+ public static function fromMessage(string $value): string {
858+ return $value; /*string*/
859+ }
860+
861+ /**
862+ * @throws Exception
863+ * @return string
864+ */
865+ public function toMessage(): string {
866+ if (Error::validateMessage($this->message)) {
867+ return $this->message; /*string*/
868+ }
869+ throw new Exception('never get to this Error::message');
870+ }
871+
872+ /**
873+ * @param string
874+ * @return bool
875+ * @throws Exception
876+ */
877+ public static function validateMessage(string $value): bool {
878+ return true;
879+ }
880+
881+ /**
882+ * @throws Exception
883+ * @return string
884+ */
885+ public function getMessage(): string {
886+ if (Error::validateMessage($this->message)) {
887+ return $this->message;
888+ }
889+ throw new Exception('never get to getMessage Error::message');
890+ }
891+
892+ /**
893+ * @return string
894+ */
895+ public static function sampleMessage(): string {
896+ return 'Error::message::31'; /*31:message*/
897+ }
898+
899+ /**
900+ * @throws Exception
901+ * @return bool
902+ */
903+ public function validate(): bool {
904+ return Error::validateMessage($this->message);
905+ }
906+
907+ /**
908+ * @return stdClass
909+ * @throws Exception
910+ */
911+ public function to(): stdClass {
912+ $out = new stdClass();
913+ $out->{'message'} = $this->toMessage();
914+ return $out;
915+ }
916+
917+ /**
918+ * @param stdClass $obj
919+ * @return Error
920+ * @throws Exception
921+ */
922+ public static function from(stdClass $obj): Error {
923+ return new Error(
924+ Error::fromMessage($obj->{'message'})
925+ );
926+ }
927+
928+ /**
929+ * @return Error
930+ */
931+ public static function sample(): Error {
932+ return new Error(
933+ Error::sampleMessage()
934+ );
935+ }
936+}
Agraphql-pikedefault / TopLevel.pmod+159 −0
@@ -0,0 +1,159 @@
1+// This source has been automatically generated by quicktype.
2+// ( https://github.com/quicktype/quicktype )
3+//
4+// To use this code, simply import it into your project as a Pike module.
5+// To JSON-encode your object, you can pass it to `Standards.JSON.encode`
6+// or call `encode_json` on it.
7+//
8+// To decode a JSON string, first pass it to `Standards.JSON.decode`,
9+// and then pass the result to `<YourClass>_from_JSON`.
10+// It will return an instance of <YourClass>.
11+// Bear in mind that these functions have unexpected behavior,
12+// and will likely throw an error, if the JSON string does not
13+// match the expected interface, even if the JSON itself is valid.
14+
15+class TopLevel {
16+ Data|mixed data; // json: "data"
17+ array(Error)|mixed errors; // json: "errors"
18+
19+ string encode_json() {
20+ mapping(string:mixed) json = ([
21+ "data" : data,
22+ "errors" : errors,
23+ ]);
24+
25+ return Standards.JSON.encode(json);
26+ }
27+}
28+
29+TopLevel TopLevel_from_JSON(mixed json) {
30+ TopLevel retval = TopLevel();
31+
32+ retval.data = json["data"];
33+ retval.errors = json["errors"];
34+
35+ return retval;
36+}
37+
38+class Data {
39+ Grid|mixed grid; // json: "grid"
40+
41+ string encode_json() {
42+ mapping(string:mixed) json = ([
43+ "grid" : grid,
44+ ]);
45+
46+ return Standards.JSON.encode(json);
47+ }
48+}
49+
50+Data Data_from_JSON(mixed json) {
51+ Data retval = Data();
52+
53+ retval.grid = json["grid"];
54+
55+ return retval;
56+}
57+
58+class Grid {
59+ GridConfig|mixed config; // json: "config"
60+ GridProps|mixed props; // json: "props"
61+
62+ string encode_json() {
63+ mapping(string:mixed) json = ([
64+ "config" : config,
65+ "props" : props,
66+ ]);
67+
68+ return Standards.JSON.encode(json);
69+ }
70+}
71+
72+Grid Grid_from_JSON(mixed json) {
73+ Grid retval = Grid();
74+
75+ retval.config = json["config"];
76+ retval.props = json["props"];
77+
78+ return retval;
79+}
80+
81+class GridConfig {
82+ array(ComponentRef|mixed)|mixed items; // json: "items"
83+
84+ string encode_json() {
85+ mapping(string:mixed) json = ([
86+ "items" : items,
87+ ]);
88+
89+ return Standards.JSON.encode(json);
90+ }
91+}
92+
93+GridConfig GridConfig_from_JSON(mixed json) {
94+ GridConfig retval = GridConfig();
95+
96+ retval.items = json["items"];
97+
98+ return retval;
99+}
100+
101+class ComponentRef {
102+ mixed|string id; // json: "id"
103+
104+ string encode_json() {
105+ mapping(string:mixed) json = ([
106+ "id" : id,
107+ ]);
108+
109+ return Standards.JSON.encode(json);
110+ }
111+}
112+
113+ComponentRef ComponentRef_from_JSON(mixed json) {
114+ ComponentRef retval = ComponentRef();
115+
116+ retval.id = json["id"];
117+
118+ return retval;
119+}
120+
121+class GridProps {
122+ array(ComponentRef|mixed)|mixed items; // json: "items"
123+
124+ string encode_json() {
125+ mapping(string:mixed) json = ([
126+ "items" : items,
127+ ]);
128+
129+ return Standards.JSON.encode(json);
130+ }
131+}
132+
133+GridProps GridProps_from_JSON(mixed json) {
134+ GridProps retval = GridProps();
135+
136+ retval.items = json["items"];
137+
138+ return retval;
139+}
140+
141+class Error {
142+ string message; // json: "message"
143+
144+ string encode_json() {
145+ mapping(string:mixed) json = ([
146+ "message" : message,
147+ ]);
148+
149+ return Standards.JSON.encode(json);
150+ }
151+}
152+
153+Error Error_from_JSON(mixed json) {
154+ Error retval = Error();
155+
156+ retval.message = json["message"];
157+
158+ return retval;
159+}
Agraphql-pythondefault / quicktype.py+161 −0
@@ -0,0 +1,161 @@
1+from dataclasses import dataclass
2+from typing import Any, TypeVar, Callable, Type, cast
3+
4+
5+T = TypeVar("T")
6+
7+
8+def from_str(x: Any) -> str:
9+ assert isinstance(x, str)
10+ return x
11+
12+
13+def from_none(x: Any) -> Any:
14+ assert x is None
15+ return x
16+
17+
18+def from_union(fs, x):
19+ for f in fs:
20+ try:
21+ return f(x)
22+ except:
23+ pass
24+ assert False
25+
26+
27+def from_list(f: Callable[[Any], T], x: Any) -> list[T]:
28+ assert isinstance(x, list)
29+ return [f(y) for y in x]
30+
31+
32+def to_class(c: Type[T], x: Any) -> dict:
33+ assert isinstance(x, c)
34+ return cast(Any, x).to_dict()
35+
36+
37+@dataclass
38+class ComponentRef:
39+ id: str | None = None
40+
41+ @staticmethod
42+ def from_dict(obj: Any) -> 'ComponentRef':
43+ assert isinstance(obj, dict)
44+ id = from_union([from_str, from_none], obj.get("id"))
45+ return ComponentRef(id)
46+
47+ def to_dict(self) -> dict:
48+ result: dict = {}
49+ result["id"] = from_union([from_str, from_none], self.id)
50+ return result
51+
52+
53+@dataclass
54+class GridConfig:
55+ items: list[ComponentRef | None] | None = None
56+
57+ @staticmethod
58+ def from_dict(obj: Any) -> 'GridConfig':
59+ assert isinstance(obj, dict)
60+ items = from_union([lambda x: from_list(lambda x: from_union([ComponentRef.from_dict, from_none], x), x), from_none], obj.get("items"))
61+ return GridConfig(items)
62+
63+ def to_dict(self) -> dict:
64+ result: dict = {}
65+ result["items"] = from_union([lambda x: from_list(lambda x: from_union([lambda x: to_class(ComponentRef, x), from_none], x), x), from_none], self.items)
66+ return result
67+
68+
69+@dataclass
70+class GridProps:
71+ items: list[ComponentRef | None] | None = None
72+
73+ @staticmethod
74+ def from_dict(obj: Any) -> 'GridProps':
75+ assert isinstance(obj, dict)
76+ items = from_union([lambda x: from_list(lambda x: from_union([ComponentRef.from_dict, from_none], x), x), from_none], obj.get("items"))
77+ return GridProps(items)
78+
79+ def to_dict(self) -> dict:
80+ result: dict = {}
81+ result["items"] = from_union([lambda x: from_list(lambda x: from_union([lambda x: to_class(ComponentRef, x), from_none], x), x), from_none], self.items)
82+ return result
83+
84+
85+@dataclass
86+class Grid:
87+ config: GridConfig | None = None
88+ props: GridProps | None = None
89+
90+ @staticmethod
91+ def from_dict(obj: Any) -> 'Grid':
92+ assert isinstance(obj, dict)
93+ config = from_union([GridConfig.from_dict, from_none], obj.get("config"))
94+ props = from_union([GridProps.from_dict, from_none], obj.get("props"))
95+ return Grid(config, props)
96+
97+ def to_dict(self) -> dict:
98+ result: dict = {}
99+ result["config"] = from_union([lambda x: to_class(GridConfig, x), from_none], self.config)
100+ result["props"] = from_union([lambda x: to_class(GridProps, x), from_none], self.props)
101+ return result
102+
103+
104+@dataclass
105+class Data:
106+ grid: Grid | None = None
107+
108+ @staticmethod
109+ def from_dict(obj: Any) -> 'Data':
110+ assert isinstance(obj, dict)
111+ grid = from_union([Grid.from_dict, from_none], obj.get("grid"))
112+ return Data(grid)
113+
114+ def to_dict(self) -> dict:
115+ result: dict = {}
116+ result["grid"] = from_union([lambda x: to_class(Grid, x), from_none], self.grid)
117+ return result
118+
119+
120+@dataclass
121+class Error:
122+ message: str
123+
124+ @staticmethod
125+ def from_dict(obj: Any) -> 'Error':
126+ assert isinstance(obj, dict)
127+ message = from_str(obj.get("message"))
128+ return Error(message)
129+
130+ def to_dict(self) -> dict:
131+ result: dict = {}
132+ result["message"] = from_str(self.message)
133+ return result
134+
135+
136+@dataclass
137+class TopLevel:
138+ data: Data | None = None
139+ errors: list[Error] | None = None
140+
141+ @staticmethod
142+ def from_dict(obj: Any) -> 'TopLevel':
143+ assert isinstance(obj, dict)
144+ data = from_union([Data.from_dict, from_none], obj.get("data"))
145+ errors = from_union([lambda x: from_list(Error.from_dict, x), from_none], obj.get("errors"))
146+ return TopLevel(data, errors)
147+
148+ def to_dict(self) -> dict:
149+ result: dict = {}
150+ result["data"] = from_union([lambda x: to_class(Data, x), from_none], self.data)
151+ if self.errors is not None:
152+ result["errors"] = from_union([lambda x: from_list(lambda x: to_class(Error, x), x), from_none], self.errors)
153+ return result
154+
155+
156+def top_level_from_dict(s: Any) -> TopLevel:
157+ return TopLevel.from_dict(s)
158+
159+
160+def top_level_to_dict(x: TopLevel) -> Any:
161+ return to_class(TopLevel, x)
Agraphql-swiftdefault / quicktype.swift+358 −0
@@ -0,0 +1,358 @@
1+// This file was generated from JSON Schema using quicktype, do not modify it directly.
2+// To parse the JSON, add this file to your project and do:
3+//
4+// let topLevel = try TopLevel(json)
5+
6+import Foundation
7+
8+// MARK: - TopLevel
9+struct TopLevel: Codable {
10+ let data: DataClass?
11+ let errors: [Error]?
12+
13+ enum CodingKeys: String, CodingKey {
14+ case data = "data"
15+ case errors = "errors"
16+ }
17+}
18+
19+// MARK: TopLevel convenience initializers and mutators
20+
21+extension TopLevel {
22+ init(data: Data) throws {
23+ self = try newJSONDecoder().decode(TopLevel.self, from: data)
24+ }
25+
26+ init(_ json: String, using encoding: String.Encoding = .utf8) throws {
27+ guard let data = json.data(using: encoding) else {
28+ throw NSError(domain: "JSONDecoding", code: 0, userInfo: nil)
29+ }
30+ try self.init(data: data)
31+ }
32+
33+ init(fromURL url: URL) throws {
34+ try self.init(data: try Data(contentsOf: url))
35+ }
36+
37+ func with(
38+ data: DataClass?? = nil,
39+ errors: [Error]?? = nil
40+ ) -> TopLevel {
41+ return TopLevel(
42+ data: data ?? self.data,
43+ errors: errors ?? self.errors
44+ )
45+ }
46+
47+ func jsonData() throws -> Data {
48+ return try newJSONEncoder().encode(self)
49+ }
50+
51+ func jsonString(encoding: String.Encoding = .utf8) throws -> String? {
52+ return String(data: try self.jsonData(), encoding: encoding)
53+ }
54+}
55+
56+// MARK: - DataClass
57+struct DataClass: Codable {
58+ let grid: Grid?
59+
60+ enum CodingKeys: String, CodingKey {
61+ case grid = "grid"
62+ }
63+}
64+
65+// MARK: DataClass convenience initializers and mutators
66+
67+extension DataClass {
68+ init(data: Data) throws {
69+ self = try newJSONDecoder().decode(DataClass.self, from: data)
70+ }
71+
72+ init(_ json: String, using encoding: String.Encoding = .utf8) throws {
73+ guard let data = json.data(using: encoding) else {
74+ throw NSError(domain: "JSONDecoding", code: 0, userInfo: nil)
75+ }
76+ try self.init(data: data)
77+ }
78+
79+ init(fromURL url: URL) throws {
80+ try self.init(data: try Data(contentsOf: url))
81+ }
82+
83+ func with(
84+ grid: Grid?? = nil
85+ ) -> DataClass {
86+ return DataClass(
87+ grid: grid ?? self.grid
88+ )
89+ }
90+
91+ func jsonData() throws -> Data {
92+ return try newJSONEncoder().encode(self)
93+ }
94+
95+ func jsonString(encoding: String.Encoding = .utf8) throws -> String? {
96+ return String(data: try self.jsonData(), encoding: encoding)
97+ }
98+}
99+
100+// MARK: - Grid
101+struct Grid: Codable {
102+ let config: GridConfig?
103+ let props: GridProps?
104+
105+ enum CodingKeys: String, CodingKey {
106+ case config = "config"
107+ case props = "props"
108+ }
109+}
110+
111+// MARK: Grid convenience initializers and mutators
112+
113+extension Grid {
114+ init(data: Data) throws {
115+ self = try newJSONDecoder().decode(Grid.self, from: data)
116+ }
117+
118+ init(_ json: String, using encoding: String.Encoding = .utf8) throws {
119+ guard let data = json.data(using: encoding) else {
120+ throw NSError(domain: "JSONDecoding", code: 0, userInfo: nil)
121+ }
122+ try self.init(data: data)
123+ }
124+
125+ init(fromURL url: URL) throws {
126+ try self.init(data: try Data(contentsOf: url))
127+ }
128+
129+ func with(
130+ config: GridConfig?? = nil,
131+ props: GridProps?? = nil
132+ ) -> Grid {
133+ return Grid(
134+ config: config ?? self.config,
135+ props: props ?? self.props
136+ )
137+ }
138+
139+ func jsonData() throws -> Data {
140+ return try newJSONEncoder().encode(self)
141+ }
142+
143+ func jsonString(encoding: String.Encoding = .utf8) throws -> String? {
144+ return String(data: try self.jsonData(), encoding: encoding)
145+ }
146+}
147+
148+// MARK: - GridConfig
149+struct GridConfig: Codable {
150+ let items: [ComponentRef?]?
151+
152+ enum CodingKeys: String, CodingKey {
153+ case items = "items"
154+ }
155+}
156+
157+// MARK: GridConfig convenience initializers and mutators
158+
159+extension GridConfig {
160+ init(data: Data) throws {
161+ self = try newJSONDecoder().decode(GridConfig.self, from: data)
162+ }
163+
164+ init(_ json: String, using encoding: String.Encoding = .utf8) throws {
165+ guard let data = json.data(using: encoding) else {
166+ throw NSError(domain: "JSONDecoding", code: 0, userInfo: nil)
167+ }
168+ try self.init(data: data)
169+ }
170+
171+ init(fromURL url: URL) throws {
172+ try self.init(data: try Data(contentsOf: url))
173+ }
174+
175+ func with(
176+ items: [ComponentRef?]?? = nil
177+ ) -> GridConfig {
178+ return GridConfig(
179+ items: items ?? self.items
180+ )
181+ }
182+
183+ func jsonData() throws -> Data {
184+ return try newJSONEncoder().encode(self)
185+ }
186+
187+ func jsonString(encoding: String.Encoding = .utf8) throws -> String? {
188+ return String(data: try self.jsonData(), encoding: encoding)
189+ }
190+}
191+
192+// MARK: - ComponentRef
193+struct ComponentRef: Codable {
194+ let id: String?
195+
196+ enum CodingKeys: String, CodingKey {
197+ case id = "id"
198+ }
199+}
200+
201+// MARK: ComponentRef convenience initializers and mutators
202+
203+extension ComponentRef {
204+ init(data: Data) throws {
205+ self = try newJSONDecoder().decode(ComponentRef.self, from: data)
206+ }
207+
208+ init(_ json: String, using encoding: String.Encoding = .utf8) throws {
209+ guard let data = json.data(using: encoding) else {
210+ throw NSError(domain: "JSONDecoding", code: 0, userInfo: nil)
211+ }
212+ try self.init(data: data)
213+ }
214+
215+ init(fromURL url: URL) throws {
216+ try self.init(data: try Data(contentsOf: url))
217+ }
218+
219+ func with(
220+ id: String?? = nil
221+ ) -> ComponentRef {
222+ return ComponentRef(
223+ id: id ?? self.id
224+ )
225+ }
226+
227+ func jsonData() throws -> Data {
228+ return try newJSONEncoder().encode(self)
229+ }
230+
231+ func jsonString(encoding: String.Encoding = .utf8) throws -> String? {
232+ return String(data: try self.jsonData(), encoding: encoding)
233+ }
234+}
235+
236+// MARK: - GridProps
237+struct GridProps: Codable {
238+ let items: [ComponentRef?]?
239+
240+ enum CodingKeys: String, CodingKey {
241+ case items = "items"
242+ }
243+}
244+
245+// MARK: GridProps convenience initializers and mutators
246+
247+extension GridProps {
248+ init(data: Data) throws {
249+ self = try newJSONDecoder().decode(GridProps.self, from: data)
250+ }
251+
252+ init(_ json: String, using encoding: String.Encoding = .utf8) throws {
253+ guard let data = json.data(using: encoding) else {
254+ throw NSError(domain: "JSONDecoding", code: 0, userInfo: nil)
255+ }
256+ try self.init(data: data)
257+ }
258+
259+ init(fromURL url: URL) throws {
260+ try self.init(data: try Data(contentsOf: url))
261+ }
262+
263+ func with(
264+ items: [ComponentRef?]?? = nil
265+ ) -> GridProps {
266+ return GridProps(
267+ items: items ?? self.items
268+ )
269+ }
270+
271+ func jsonData() throws -> Data {
272+ return try newJSONEncoder().encode(self)
273+ }
274+
275+ func jsonString(encoding: String.Encoding = .utf8) throws -> String? {
276+ return String(data: try self.jsonData(), encoding: encoding)
277+ }
278+}
279+
280+// MARK: - Error
281+struct Error: Codable {
282+ let message: String
283+
284+ enum CodingKeys: String, CodingKey {
285+ case message = "message"
286+ }
287+}
288+
289+// MARK: Error convenience initializers and mutators
290+
291+extension Error {
292+ init(data: Data) throws {
293+ self = try newJSONDecoder().decode(Error.self, from: data)
294+ }
295+
296+ init(_ json: String, using encoding: String.Encoding = .utf8) throws {
297+ guard let data = json.data(using: encoding) else {
298+ throw NSError(domain: "JSONDecoding", code: 0, userInfo: nil)
299+ }
300+ try self.init(data: data)
301+ }
302+
303+ init(fromURL url: URL) throws {
304+ try self.init(data: try Data(contentsOf: url))
305+ }
306+
307+ func with(
308+ message: String? = nil
309+ ) -> Error {
310+ return Error(
311+ message: message ?? self.message
312+ )
313+ }
314+
315+ func jsonData() throws -> Data {
316+ return try newJSONEncoder().encode(self)
317+ }
318+
319+ func jsonString(encoding: String.Encoding = .utf8) throws -> String? {
320+ return String(data: try self.jsonData(), encoding: encoding)
321+ }
322+}
323+
324+// MARK: - Helper functions for creating encoders and decoders
325+
326+func newJSONDecoder() -> JSONDecoder {
327+ let decoder = JSONDecoder()
328+ decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in
329+ let container = try decoder.singleValueContainer()
330+ let dateStr = try container.decode(String.self)
331+
332+ let formatter = DateFormatter()
333+ formatter.calendar = Calendar(identifier: .iso8601)
334+ formatter.locale = Locale(identifier: "en_US_POSIX")
335+ formatter.timeZone = TimeZone(secondsFromGMT: 0)
336+ formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX"
337+ if let date = formatter.date(from: dateStr) {
338+ return date
339+ }
340+ formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssXXXXX"
341+ if let date = formatter.date(from: dateStr) {
342+ return date
343+ }
344+ throw DecodingError.typeMismatch(Date.self, DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Could not decode date"))
345+ })
346+ return decoder
347+}
348+
349+func newJSONEncoder() -> JSONEncoder {
350+ let encoder = JSONEncoder()
351+ let formatter = DateFormatter()
352+ formatter.calendar = Calendar(identifier: .iso8601)
353+ formatter.locale = Locale(identifier: "en_US_POSIX")
354+ formatter.timeZone = TimeZone(secondsFromGMT: 0)
355+ formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssXXXXX"
356+ encoder.dateEncodingStrategy = .formatted(formatter)
357+ return encoder
358+}
Agraphql-typescriptdefault / TopLevel.ts+229 −0
@@ -0,0 +1,229 @@
1+// To parse this data:
2+//
3+// import { Convert, TopLevel } from "./TopLevel";
4+//
5+// const topLevel = Convert.toTopLevel(json);
6+//
7+// These functions will throw an error if the JSON doesn't
8+// match the expected interface, even if the JSON is valid.
9+
10+export interface TopLevel {
11+ data: Data | null;
12+ errors?: Error[];
13+}
14+
15+export interface Data {
16+ grid: Grid | null;
17+}
18+
19+export interface Grid {
20+ config: GridConfig | null;
21+ props: GridProps | null;
22+}
23+
24+export interface GridConfig {
25+ items: (ComponentRef | null)[] | null;
26+}
27+
28+export interface ComponentRef {
29+ id: null | string;
30+}
31+
32+export interface GridProps {
33+ items: (ComponentRef | null)[] | null;
34+}
35+
36+export interface Error {
37+ message: string;
38+}
39+
40+// Converts JSON strings to/from your types
41+// and asserts the results of JSON.parse at runtime
42+export class Convert {
43+ public static toTopLevel(json: string): TopLevel {
44+ return cast(JSON.parse(json), r("TopLevel"));
45+ }
46+
47+ public static topLevelToJson(value: TopLevel): string {
48+ return JSON.stringify(uncast(value, r("TopLevel")), null, 2);
49+ }
50+}
51+
52+function invalidValue(typ: any, val: any, key: any, parent: any = ''): never {
53+ const prettyTyp = prettyTypeName(typ);
54+ const parentText = parent ? ` on ${parent}` : '';
55+ const keyText = key ? ` for key "${key}"` : '';
56+ throw Error(`Invalid value${keyText}${parentText}. Expected ${prettyTyp} but got ${JSON.stringify(val)}`);
57+}
58+
59+function prettyTypeName(typ: any): string {
60+ if (Array.isArray(typ)) {
61+ if (typ.length === 2 && typ[0] === undefined) {
62+ return `an optional ${prettyTypeName(typ[1])}`;
63+ } else {
64+ return `one of [${typ.map(a => { return prettyTypeName(a); }).join(", ")}]`;
65+ }
66+ } else if (typeof typ === "object" && typ.literal !== undefined) {
67+ return typ.literal;
68+ } else {
69+ return typeof typ;
70+ }
71+}
72+
73+function jsonToJSProps(typ: any): any {
74+ if (typ.jsonToJS === undefined) {
75+ const map: any = {};
76+ typ.props.forEach((p: any) => map[p.json] = { key: p.js, typ: p.typ });
77+ typ.jsonToJS = map;
78+ }
79+ return typ.jsonToJS;
80+}
81+
82+function jsToJSONProps(typ: any): any {
83+ if (typ.jsToJSON === undefined) {
84+ const map: any = {};
85+ typ.props.forEach((p: any) => map[p.js] = { key: p.json, typ: p.typ });
86+ typ.jsToJSON = map;
87+ }
88+ return typ.jsToJSON;
89+}
90+
91+function transform(val: any, typ: any, getProps: any, key: any = '', parent: any = ''): any {
92+ function transformPrimitive(typ: string, val: any): any {
93+ if (typeof typ === typeof val) return val;
94+ return invalidValue(typ, val, key, parent);
95+ }
96+
97+ function transformUnion(typs: any[], val: any): any {
98+ // val must validate against one typ in typs
99+ const l = typs.length;
100+ for (let i = 0; i < l; i++) {
101+ const typ = typs[i];
102+ try {
103+ return transform(val, typ, getProps);
104+ } catch (_) {}
105+ }
106+ return invalidValue(typs, val, key, parent);
107+ }
108+
109+ function transformEnum(cases: string[], val: any): any {
110+ if (cases.indexOf(val) !== -1) return val;
111+ return invalidValue(cases.map(a => { return l(a); }), val, key, parent);
112+ }
113+
114+ function transformArray(typ: any, val: any): any {
115+ // val must be an array with no invalid elements
116+ if (!Array.isArray(val)) return invalidValue(l("array"), val, key, parent);
117+ return val.map(el => transform(el, typ, getProps));
118+ }
119+
120+ function transformDate(val: any): any {
121+ if (val === null) {
122+ return null;
123+ }
124+ const d = new Date(val);
125+ if (isNaN(d.valueOf())) {
126+ return invalidValue(l("Date"), val, key, parent);
127+ }
128+ return d;
129+ }
130+
131+ function transformObject(props: { [k: string]: any }, additional: any, val: any): any {
132+ if (val === null || typeof val !== "object" || Array.isArray(val)) {
133+ return invalidValue(l(ref || "object"), val, key, parent);
134+ }
135+ const result: any = {};
136+ Object.getOwnPropertyNames(props).forEach(key => {
137+ const prop = props[key];
138+ const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
139+ result[prop.key] = transform(v, prop.typ, getProps, key, ref);
140+ });
141+ Object.getOwnPropertyNames(val).forEach(key => {
142+ if (!Object.prototype.hasOwnProperty.call(props, key)) {
143+ result[key] = transform(val[key], additional, getProps, key, ref);
144+ }
145+ });
146+ return result;
147+ }
148+
149+ if (typ === "any") return val;
150+ if (typ === null) {
151+ if (val === null) return val;
152+ return invalidValue(typ, val, key, parent);
153+ }
154+ if (typ === false) return invalidValue(typ, val, key, parent);
155+ let ref: any = undefined;
156+ while (typeof typ === "object" && typ.ref !== undefined) {
157+ ref = typ.ref;
158+ typ = typeMap[typ.ref];
159+ }
160+ if (Array.isArray(typ)) return transformEnum(typ, val);
161+ if (typeof typ === "object") {
162+ return typ.hasOwnProperty("unionMembers") ? transformUnion(typ.unionMembers, val)
163+ : typ.hasOwnProperty("arrayItems") ? transformArray(typ.arrayItems, val)
164+ : typ.hasOwnProperty("props") ? transformObject(getProps(typ), typ.additional, val)
165+ : invalidValue(typ, val, key, parent);
166+ }
167+ // Numbers can be parsed by Date but shouldn't be.
168+ if (typ === Date && typeof val !== "number") return transformDate(val);
169+ return transformPrimitive(typ, val);
170+}
171+
172+function cast<T>(val: any, typ: any): T {
173+ return transform(val, typ, jsonToJSProps);
174+}
175+
176+function uncast<T>(val: T, typ: any): any {
177+ return transform(val, typ, jsToJSONProps);
178+}
179+
180+function l(typ: any) {
181+ return { literal: typ };
182+}
183+
184+function a(typ: any) {
185+ return { arrayItems: typ };
186+}
187+
188+function u(...typs: any[]) {
189+ return { unionMembers: typs };
190+}
191+
192+function o(props: any[], additional: any) {
193+ return { props, additional };
194+}
195+
196+function m(additional: any) {
197+ const props: any[] = [];
198+ return { props, additional };
199+}
200+
201+function r(name: string) {
202+ return { ref: name };
203+}
204+
205+const typeMap: any = {
206+ "TopLevel": o([
207+ { json: "data", js: "data", typ: u(r("Data"), null) },
208+ { json: "errors", js: "errors", typ: u(undefined, a(r("Error"))) },
209+ ], false),
210+ "Data": o([
211+ { json: "grid", js: "grid", typ: u(r("Grid"), null) },
212+ ], false),
213+ "Grid": o([
214+ { json: "config", js: "config", typ: u(r("GridConfig"), null) },
215+ { json: "props", js: "props", typ: u(r("GridProps"), null) },
216+ ], false),
217+ "GridConfig": o([
218+ { json: "items", js: "items", typ: u(a(u(r("ComponentRef"), null)), null) },
219+ ], false),
220+ "ComponentRef": o([
221+ { json: "id", js: "id", typ: u(null, "") },
222+ ], false),
223+ "GridProps": o([
224+ { json: "items", js: "items", typ: u(a(u(r("ComponentRef"), null)), null) },
225+ ], false),
226+ "Error": o([
227+ { json: "message", js: "message", typ: "" },
228+ ], false),
229+};
No generated files match these filters.