joist-graphql-codegen 2.3.0-next.2 → 2.3.0-next.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/generateEnumDetailResolvers.d.ts +0 -1
- package/build/generateEnumsGraphql.d.ts +0 -1
- package/build/generateGraphqlCodegen.d.ts +0 -1
- package/build/generateGraphqlSchemaFiles.d.ts +0 -1
- package/build/generateObjectResolvers.d.ts +0 -1
- package/build/generateQueryPageResolvers.d.ts +0 -1
- package/build/generateQueryResolvers.d.ts +0 -1
- package/build/generateResolverUtils.d.ts +0 -1
- package/build/generateSaveResolvers.d.ts +0 -1
- package/build/graphqlUtils.d.ts +0 -1
- package/build/history.d.ts +0 -1
- package/build/index.d.ts +0 -1
- package/build/testUtils.d.ts +0 -1
- package/build/utils.d.ts +0 -1
- package/package.json +3 -3
- package/build/generateEnumDetailResolvers.d.ts.map +0 -1
- package/build/generateEnumDetailResolvers.test.d.ts +0 -2
- package/build/generateEnumDetailResolvers.test.d.ts.map +0 -1
- package/build/generateEnumDetailResolvers.test.js +0 -34
- package/build/generateEnumDetailResolvers.test.js.map +0 -1
- package/build/generateEnumsGraphql.d.ts.map +0 -1
- package/build/generateGraphqlCodegen.d.ts.map +0 -1
- package/build/generateGraphqlCodegen.test.d.ts +0 -2
- package/build/generateGraphqlCodegen.test.d.ts.map +0 -1
- package/build/generateGraphqlCodegen.test.js +0 -44
- package/build/generateGraphqlCodegen.test.js.map +0 -1
- package/build/generateGraphqlSchemaFiles.d.ts.map +0 -1
- package/build/generateGraphqlSchemaFiles.test.d.ts +0 -2
- package/build/generateGraphqlSchemaFiles.test.d.ts.map +0 -1
- package/build/generateGraphqlSchemaFiles.test.js +0 -1008
- package/build/generateGraphqlSchemaFiles.test.js.map +0 -1
- package/build/generateObjectResolvers.d.ts.map +0 -1
- package/build/generateQueryPageResolvers.d.ts.map +0 -1
- package/build/generateQueryPageResolvers.test.d.ts +0 -2
- package/build/generateQueryPageResolvers.test.d.ts.map +0 -1
- package/build/generateQueryPageResolvers.test.js +0 -46
- package/build/generateQueryPageResolvers.test.js.map +0 -1
- package/build/generateQueryResolvers.d.ts.map +0 -1
- package/build/generateQueryResolvers.test.d.ts +0 -2
- package/build/generateQueryResolvers.test.d.ts.map +0 -1
- package/build/generateQueryResolvers.test.js +0 -45
- package/build/generateQueryResolvers.test.js.map +0 -1
- package/build/generateResolverUtils.d.ts.map +0 -1
- package/build/generateResolverUtils.test.d.ts +0 -2
- package/build/generateResolverUtils.test.d.ts.map +0 -1
- package/build/generateResolverUtils.test.js +0 -53
- package/build/generateResolverUtils.test.js.map +0 -1
- package/build/generateSaveResolvers.d.ts.map +0 -1
- package/build/generateSaveResolvers.test.d.ts +0 -2
- package/build/generateSaveResolvers.test.d.ts.map +0 -1
- package/build/generateSaveResolvers.test.js +0 -49
- package/build/generateSaveResolvers.test.js.map +0 -1
- package/build/graphqlUtils.d.ts.map +0 -1
- package/build/history.d.ts.map +0 -1
- package/build/index.d.ts.map +0 -1
- package/build/testUtils.d.ts.map +0 -1
- package/build/utils.d.ts.map +0 -1
|
@@ -1,1008 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const utils_1 = require("joist-codegen/build/utils");
|
|
4
|
-
const joist_utils_1 = require("joist-utils");
|
|
5
|
-
const generateGraphqlSchemaFiles_1 = require("./generateGraphqlSchemaFiles");
|
|
6
|
-
const testUtils_1 = require("./testUtils");
|
|
7
|
-
describe("generateGraphqlSchemaFiles", () => {
|
|
8
|
-
it("creates a new file", async () => {
|
|
9
|
-
// Given an author
|
|
10
|
-
const entities = [(0, testUtils_1.newEntityMetadata)("Author")];
|
|
11
|
-
// And no existing graphql file
|
|
12
|
-
const fs = (0, testUtils_1.newFs)({});
|
|
13
|
-
// When ran
|
|
14
|
-
await generate(fs, entities);
|
|
15
|
-
// We now have a graphql file
|
|
16
|
-
expect(await fs.load("author.graphql")).toMatchInlineSnapshot(`
|
|
17
|
-
"extend type Query {
|
|
18
|
-
author(id: ID!): Author!
|
|
19
|
-
authors(filter: AuthorFilter, first: Int, after: String, last: Int, before: String): AuthorsConnection!
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
extend type Mutation {
|
|
23
|
-
saveAuthor(input: SaveAuthorInput!): SaveAuthorResult!
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
type AuthorsConnection {
|
|
27
|
-
edges: [AuthorsEdge!]!
|
|
28
|
-
nodes: [Author!]!
|
|
29
|
-
pageInfo: PageInfo!
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
type AuthorsEdge {
|
|
33
|
-
node: Author!
|
|
34
|
-
cursor: String!
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
type Author {
|
|
38
|
-
id: ID!
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
input AuthorFilter {
|
|
42
|
-
id: [ID!]
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
input SaveAuthorInput {
|
|
46
|
-
id: ID
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
type SaveAuthorResult {
|
|
50
|
-
author: Author!
|
|
51
|
-
}
|
|
52
|
-
"
|
|
53
|
-
`);
|
|
54
|
-
expect(await fs.load("pageInfo.graphql")).toMatchInlineSnapshot(`
|
|
55
|
-
"type PageInfo {
|
|
56
|
-
hasNextPage: Boolean!
|
|
57
|
-
hasPreviousPage: Boolean!
|
|
58
|
-
totalCount: Int!
|
|
59
|
-
startCursor: String
|
|
60
|
-
endCursor: String
|
|
61
|
-
}
|
|
62
|
-
"
|
|
63
|
-
`);
|
|
64
|
-
});
|
|
65
|
-
it("generates cursor query fields by default", async () => {
|
|
66
|
-
const entities = [(0, testUtils_1.newEntityMetadata)("Author")];
|
|
67
|
-
const fs = (0, testUtils_1.newFs)({});
|
|
68
|
-
await generate(fs, entities);
|
|
69
|
-
expect(await fs.load("author.graphql")).toMatchInlineSnapshot(`
|
|
70
|
-
"extend type Query {
|
|
71
|
-
author(id: ID!): Author!
|
|
72
|
-
authors(filter: AuthorFilter, first: Int, after: String, last: Int, before: String): AuthorsConnection!
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
extend type Mutation {
|
|
76
|
-
saveAuthor(input: SaveAuthorInput!): SaveAuthorResult!
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
type AuthorsConnection {
|
|
80
|
-
edges: [AuthorsEdge!]!
|
|
81
|
-
nodes: [Author!]!
|
|
82
|
-
pageInfo: PageInfo!
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
type AuthorsEdge {
|
|
86
|
-
node: Author!
|
|
87
|
-
cursor: String!
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
type Author {
|
|
91
|
-
id: ID!
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
input AuthorFilter {
|
|
95
|
-
id: [ID!]
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
input SaveAuthorInput {
|
|
99
|
-
id: ID
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
type SaveAuthorResult {
|
|
103
|
-
author: Author!
|
|
104
|
-
}
|
|
105
|
-
"
|
|
106
|
-
`);
|
|
107
|
-
});
|
|
108
|
-
it("generates limit query fields", async () => {
|
|
109
|
-
const entities = [(0, testUtils_1.newEntityMetadata)("Author")];
|
|
110
|
-
const fs = (0, testUtils_1.newFs)({});
|
|
111
|
-
await generate(fs, entities, { paginationStyle: "limit" });
|
|
112
|
-
expect(await fs.load("author.graphql")).toMatchInlineSnapshot(`
|
|
113
|
-
"extend type Query {
|
|
114
|
-
author(id: ID!): Author!
|
|
115
|
-
authors(filter: AuthorFilter, limit: Int, offset: Int): AuthorsPage!
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
extend type Mutation {
|
|
119
|
-
saveAuthor(input: SaveAuthorInput!): SaveAuthorResult!
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
type AuthorsPage {
|
|
123
|
-
entities: [Author!]!
|
|
124
|
-
pageInfo: PageInfo!
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
type Author {
|
|
128
|
-
id: ID!
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
input AuthorFilter {
|
|
132
|
-
id: [ID!]
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
input SaveAuthorInput {
|
|
136
|
-
id: ID
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
type SaveAuthorResult {
|
|
140
|
-
author: Author!
|
|
141
|
-
}
|
|
142
|
-
"
|
|
143
|
-
`);
|
|
144
|
-
expect(await fs.load("pageInfo.graphql")).toMatchInlineSnapshot(`
|
|
145
|
-
"type PageInfo {
|
|
146
|
-
hasNextPage: Boolean!
|
|
147
|
-
hasPreviousPage: Boolean!
|
|
148
|
-
totalCount: Int!
|
|
149
|
-
nextPage: Int
|
|
150
|
-
currentPage: Int
|
|
151
|
-
}
|
|
152
|
-
"
|
|
153
|
-
`);
|
|
154
|
-
});
|
|
155
|
-
it("generates filter fields", async () => {
|
|
156
|
-
const entities = [
|
|
157
|
-
(0, testUtils_1.newEntityMetadata)("Publisher"),
|
|
158
|
-
(0, testUtils_1.newEntityMetadata)("Book"),
|
|
159
|
-
(0, testUtils_1.newEntityMetadata)("Author", {
|
|
160
|
-
primitives: [
|
|
161
|
-
(0, testUtils_1.newPrimitiveField)("firstName"),
|
|
162
|
-
(0, testUtils_1.newPrimitiveField)("nickNames", { isArray: true }),
|
|
163
|
-
(0, testUtils_1.newPrimitiveField)("numberOfAtoms", { columnType: "bigint", fieldType: "bigint", rawFieldType: "bigint" }),
|
|
164
|
-
],
|
|
165
|
-
enums: [(0, testUtils_1.newEnumField)("color")],
|
|
166
|
-
manyToOnes: [(0, testUtils_1.newManyToOneField)("publisher", "Publisher")],
|
|
167
|
-
polymorphics: [(0, testUtils_1.newPolymorphicField)("favorite", ["Book", "Publisher"])],
|
|
168
|
-
}),
|
|
169
|
-
];
|
|
170
|
-
const fs = (0, testUtils_1.newFs)({});
|
|
171
|
-
await generate(fs, entities);
|
|
172
|
-
expect(await fs.load("author.graphql")).toMatchInlineSnapshot(`
|
|
173
|
-
"extend type Query {
|
|
174
|
-
author(id: ID!): Author!
|
|
175
|
-
authors(filter: AuthorFilter, first: Int, after: String, last: Int, before: String): AuthorsConnection!
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
extend type Mutation {
|
|
179
|
-
saveAuthor(input: SaveAuthorInput!): SaveAuthorResult!
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
type AuthorsConnection {
|
|
183
|
-
edges: [AuthorsEdge!]!
|
|
184
|
-
nodes: [Author!]!
|
|
185
|
-
pageInfo: PageInfo!
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
type AuthorsEdge {
|
|
189
|
-
node: Author!
|
|
190
|
-
cursor: String!
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
type Author {
|
|
194
|
-
id: ID!
|
|
195
|
-
firstName: String!
|
|
196
|
-
nickNames: [String!]!
|
|
197
|
-
numberOfAtoms: BigInt!
|
|
198
|
-
color: ColorDetail!
|
|
199
|
-
publisher: Publisher!
|
|
200
|
-
favorite: FavoriteParent
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
input AuthorFilter {
|
|
204
|
-
id: [ID!]
|
|
205
|
-
firstName: [String!]
|
|
206
|
-
nickNames: [[String!]!]
|
|
207
|
-
numberOfAtoms: [BigInt!]
|
|
208
|
-
color: [Color!]
|
|
209
|
-
publisherId: [ID!]
|
|
210
|
-
favoriteId: [ID!]
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
input SaveAuthorInput {
|
|
214
|
-
id: ID
|
|
215
|
-
firstName: String
|
|
216
|
-
nickNames: [String!]
|
|
217
|
-
numberOfAtoms: BigInt
|
|
218
|
-
color: Color
|
|
219
|
-
publisherId: ID
|
|
220
|
-
favoriteId: ID
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
type SaveAuthorResult {
|
|
224
|
-
author: Author!
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
union FavoriteParent = Book | Publisher
|
|
228
|
-
"
|
|
229
|
-
`);
|
|
230
|
-
});
|
|
231
|
-
it("adds a new field to existing file", async () => {
|
|
232
|
-
// Given an author with a primitive field
|
|
233
|
-
const entities = [
|
|
234
|
-
(0, testUtils_1.newEntityMetadata)("Author", {
|
|
235
|
-
primitives: [(0, testUtils_1.newPrimitiveField)("firstName")],
|
|
236
|
-
}),
|
|
237
|
-
];
|
|
238
|
-
// And an existing graphql file
|
|
239
|
-
const fs = (0, testUtils_1.newFs)({
|
|
240
|
-
"author.graphql": "type Author { id: ID! } input SaveAuthorInput { id: ID }",
|
|
241
|
-
// And the history file doesn't have firstName yet
|
|
242
|
-
".history.json": JSON.stringify({ Author: ["id"] }),
|
|
243
|
-
});
|
|
244
|
-
// When ran
|
|
245
|
-
await generate(fs, entities);
|
|
246
|
-
// Then we added the new field
|
|
247
|
-
expect(await fs.load("author.graphql")).toMatchInlineSnapshot(`
|
|
248
|
-
"extend type Query {
|
|
249
|
-
author(id: ID!): Author!
|
|
250
|
-
authors(filter: AuthorFilter, first: Int, after: String, last: Int, before: String): AuthorsConnection!
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
extend type Mutation {
|
|
254
|
-
saveAuthor(input: SaveAuthorInput!): SaveAuthorResult!
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
type Author {
|
|
258
|
-
id: ID!
|
|
259
|
-
firstName: String!
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
input SaveAuthorInput {
|
|
263
|
-
id: ID
|
|
264
|
-
firstName: String
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
type AuthorsConnection {
|
|
268
|
-
edges: [AuthorsEdge!]!
|
|
269
|
-
nodes: [Author!]!
|
|
270
|
-
pageInfo: PageInfo!
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
type AuthorsEdge {
|
|
274
|
-
node: Author!
|
|
275
|
-
cursor: String!
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
input AuthorFilter {
|
|
279
|
-
id: [ID!]
|
|
280
|
-
firstName: [String!]
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
type SaveAuthorResult {
|
|
284
|
-
author: Author!
|
|
285
|
-
}
|
|
286
|
-
"
|
|
287
|
-
`);
|
|
288
|
-
// And saved it in the history
|
|
289
|
-
expect(JSON.parse((await fs.load(".history.json")) || "")).toMatchInlineSnapshot(`
|
|
290
|
-
{
|
|
291
|
-
"Author": [
|
|
292
|
-
"firstName",
|
|
293
|
-
"id",
|
|
294
|
-
],
|
|
295
|
-
"AuthorFilter": [
|
|
296
|
-
"firstName",
|
|
297
|
-
"id",
|
|
298
|
-
],
|
|
299
|
-
"AuthorsConnection": [
|
|
300
|
-
"edges",
|
|
301
|
-
"nodes",
|
|
302
|
-
"pageInfo",
|
|
303
|
-
],
|
|
304
|
-
"AuthorsEdge": [
|
|
305
|
-
"cursor",
|
|
306
|
-
"node",
|
|
307
|
-
],
|
|
308
|
-
"Mutation": [
|
|
309
|
-
"saveAuthor",
|
|
310
|
-
],
|
|
311
|
-
"PageInfo": [
|
|
312
|
-
"endCursor",
|
|
313
|
-
"hasNextPage",
|
|
314
|
-
"hasPreviousPage",
|
|
315
|
-
"startCursor",
|
|
316
|
-
"totalCount",
|
|
317
|
-
],
|
|
318
|
-
"Query": [
|
|
319
|
-
"author",
|
|
320
|
-
"authors",
|
|
321
|
-
],
|
|
322
|
-
"SaveAuthorInput": [
|
|
323
|
-
"firstName",
|
|
324
|
-
"id",
|
|
325
|
-
],
|
|
326
|
-
"SaveAuthorResult": [
|
|
327
|
-
"author",
|
|
328
|
-
],
|
|
329
|
-
}
|
|
330
|
-
`);
|
|
331
|
-
});
|
|
332
|
-
it("does not overwrite existing fields", async () => {
|
|
333
|
-
// Given an author with a primitive field
|
|
334
|
-
const entities = [
|
|
335
|
-
(0, testUtils_1.newEntityMetadata)("Author", {
|
|
336
|
-
primitives: [(0, testUtils_1.newPrimitiveField)("firstName")],
|
|
337
|
-
}),
|
|
338
|
-
];
|
|
339
|
-
// And an existing graphql file with a custom field
|
|
340
|
-
const fs = (0, testUtils_1.newFs)({
|
|
341
|
-
"author.graphql": "type Author { id: ID! customField: String } input SaveAuthorInput { id: ID customField: String }",
|
|
342
|
-
});
|
|
343
|
-
// When ran
|
|
344
|
-
await generate(fs, entities);
|
|
345
|
-
// We added the new field, but did not did the custom field
|
|
346
|
-
expect(await fs.load("author.graphql")).toMatchInlineSnapshot(`
|
|
347
|
-
"extend type Query {
|
|
348
|
-
author(id: ID!): Author!
|
|
349
|
-
authors(filter: AuthorFilter, first: Int, after: String, last: Int, before: String): AuthorsConnection!
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
extend type Mutation {
|
|
353
|
-
saveAuthor(input: SaveAuthorInput!): SaveAuthorResult!
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
type Author {
|
|
357
|
-
id: ID!
|
|
358
|
-
customField: String
|
|
359
|
-
firstName: String!
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
input SaveAuthorInput {
|
|
363
|
-
id: ID
|
|
364
|
-
customField: String
|
|
365
|
-
firstName: String
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
type AuthorsConnection {
|
|
369
|
-
edges: [AuthorsEdge!]!
|
|
370
|
-
nodes: [Author!]!
|
|
371
|
-
pageInfo: PageInfo!
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
type AuthorsEdge {
|
|
375
|
-
node: Author!
|
|
376
|
-
cursor: String!
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
input AuthorFilter {
|
|
380
|
-
id: [ID!]
|
|
381
|
-
firstName: [String!]
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
type SaveAuthorResult {
|
|
385
|
-
author: Author!
|
|
386
|
-
}
|
|
387
|
-
"
|
|
388
|
-
`);
|
|
389
|
-
});
|
|
390
|
-
it("does not re-add fields from existing type extensions", async () => {
|
|
391
|
-
const entities = [(0, testUtils_1.newEntityMetadata)("Author")];
|
|
392
|
-
const fs = (0, testUtils_1.newFs)({
|
|
393
|
-
"author.graphql": "extend type Query { authors: [Author!]! author(id: ID!): Author } type Author { id: ID! }",
|
|
394
|
-
});
|
|
395
|
-
await generate(fs, entities);
|
|
396
|
-
expect(await fs.load("author.graphql")).toMatchInlineSnapshot(`
|
|
397
|
-
"extend type Query {
|
|
398
|
-
authors: [Author!]!
|
|
399
|
-
author(id: ID!): Author
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
extend type Mutation {
|
|
403
|
-
saveAuthor(input: SaveAuthorInput!): SaveAuthorResult!
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
type Author {
|
|
407
|
-
id: ID!
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
type AuthorsConnection {
|
|
411
|
-
edges: [AuthorsEdge!]!
|
|
412
|
-
nodes: [Author!]!
|
|
413
|
-
pageInfo: PageInfo!
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
type AuthorsEdge {
|
|
417
|
-
node: Author!
|
|
418
|
-
cursor: String!
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
input AuthorFilter {
|
|
422
|
-
id: [ID!]
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
input SaveAuthorInput {
|
|
426
|
-
id: ID
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
type SaveAuthorResult {
|
|
430
|
-
author: Author!
|
|
431
|
-
}
|
|
432
|
-
"
|
|
433
|
-
`);
|
|
434
|
-
});
|
|
435
|
-
it("does not re-add fields in the history file", async () => {
|
|
436
|
-
// Given an author with a firstName field
|
|
437
|
-
const entities = [
|
|
438
|
-
(0, testUtils_1.newEntityMetadata)("Author", {
|
|
439
|
-
primitives: [(0, testUtils_1.newPrimitiveField)("firstName")],
|
|
440
|
-
}),
|
|
441
|
-
];
|
|
442
|
-
const fs = (0, testUtils_1.newFs)({
|
|
443
|
-
// And an existing graphql file without the firstName
|
|
444
|
-
"author.graphql": "type Author { id: ID! }",
|
|
445
|
-
// And the history file said we've already added it
|
|
446
|
-
".history.json": JSON.stringify({ Author: ["firstName"] }),
|
|
447
|
-
});
|
|
448
|
-
// When ran
|
|
449
|
-
await generate(fs, entities);
|
|
450
|
-
// Then we did not re-add it as a new field
|
|
451
|
-
expect(await fs.load("author.graphql")).toMatchInlineSnapshot(`
|
|
452
|
-
"extend type Query {
|
|
453
|
-
author(id: ID!): Author!
|
|
454
|
-
authors(filter: AuthorFilter, first: Int, after: String, last: Int, before: String): AuthorsConnection!
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
extend type Mutation {
|
|
458
|
-
saveAuthor(input: SaveAuthorInput!): SaveAuthorResult!
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
type Author {
|
|
462
|
-
id: ID!
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
type AuthorsConnection {
|
|
466
|
-
edges: [AuthorsEdge!]!
|
|
467
|
-
nodes: [Author!]!
|
|
468
|
-
pageInfo: PageInfo!
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
type AuthorsEdge {
|
|
472
|
-
node: Author!
|
|
473
|
-
cursor: String!
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
input AuthorFilter {
|
|
477
|
-
id: [ID!]
|
|
478
|
-
firstName: [String!]
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
input SaveAuthorInput {
|
|
482
|
-
id: ID
|
|
483
|
-
firstName: String
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
type SaveAuthorResult {
|
|
487
|
-
author: Author!
|
|
488
|
-
}
|
|
489
|
-
"
|
|
490
|
-
`);
|
|
491
|
-
});
|
|
492
|
-
it("keeps comments", async () => {
|
|
493
|
-
// Given an author with a primitive field
|
|
494
|
-
const entities = [
|
|
495
|
-
(0, testUtils_1.newEntityMetadata)("Author", {
|
|
496
|
-
primitives: [(0, testUtils_1.newPrimitiveField)("firstName")],
|
|
497
|
-
}),
|
|
498
|
-
];
|
|
499
|
-
// And an existing graphql file
|
|
500
|
-
const fs = (0, testUtils_1.newFs)({
|
|
501
|
-
"author.graphql": `
|
|
502
|
-
" The author. "
|
|
503
|
-
type Author { " The id. " id: ID! }
|
|
504
|
-
input SaveAuthorInput { id: ID }
|
|
505
|
-
`,
|
|
506
|
-
});
|
|
507
|
-
// When ran
|
|
508
|
-
await generate(fs, entities);
|
|
509
|
-
// Then we added the new field
|
|
510
|
-
expect(await fs.load("author.graphql")).toMatchInlineSnapshot(`
|
|
511
|
-
"extend type Query {
|
|
512
|
-
author(id: ID!): Author!
|
|
513
|
-
authors(filter: AuthorFilter, first: Int, after: String, last: Int, before: String): AuthorsConnection!
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
extend type Mutation {
|
|
517
|
-
saveAuthor(input: SaveAuthorInput!): SaveAuthorResult!
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
" The author. "
|
|
521
|
-
type Author {
|
|
522
|
-
" The id. "
|
|
523
|
-
id: ID!
|
|
524
|
-
firstName: String!
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
input SaveAuthorInput {
|
|
528
|
-
id: ID
|
|
529
|
-
firstName: String
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
type AuthorsConnection {
|
|
533
|
-
edges: [AuthorsEdge!]!
|
|
534
|
-
nodes: [Author!]!
|
|
535
|
-
pageInfo: PageInfo!
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
type AuthorsEdge {
|
|
539
|
-
node: Author!
|
|
540
|
-
cursor: String!
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
input AuthorFilter {
|
|
544
|
-
id: [ID!]
|
|
545
|
-
firstName: [String!]
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
type SaveAuthorResult {
|
|
549
|
-
author: Author!
|
|
550
|
-
}
|
|
551
|
-
"
|
|
552
|
-
`);
|
|
553
|
-
});
|
|
554
|
-
it("does not add derived fields to inputs", async () => {
|
|
555
|
-
// Given an author
|
|
556
|
-
const entities = [
|
|
557
|
-
(0, testUtils_1.newEntityMetadata)("Author", {
|
|
558
|
-
primitives: [
|
|
559
|
-
// With a regular field
|
|
560
|
-
(0, testUtils_1.newPrimitiveField)("firstName"),
|
|
561
|
-
// And also a derived field
|
|
562
|
-
(0, testUtils_1.newPrimitiveField)("createdAt", { derived: "orm" }),
|
|
563
|
-
],
|
|
564
|
-
}),
|
|
565
|
-
];
|
|
566
|
-
// When ran
|
|
567
|
-
const fs = (0, testUtils_1.newFs)({});
|
|
568
|
-
await generate(fs, entities);
|
|
569
|
-
// Then the input does not have the createdAt field
|
|
570
|
-
expect(await fs.load("author.graphql")).toMatchInlineSnapshot(`
|
|
571
|
-
"extend type Query {
|
|
572
|
-
author(id: ID!): Author!
|
|
573
|
-
authors(filter: AuthorFilter, first: Int, after: String, last: Int, before: String): AuthorsConnection!
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
extend type Mutation {
|
|
577
|
-
saveAuthor(input: SaveAuthorInput!): SaveAuthorResult!
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
type AuthorsConnection {
|
|
581
|
-
edges: [AuthorsEdge!]!
|
|
582
|
-
nodes: [Author!]!
|
|
583
|
-
pageInfo: PageInfo!
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
type AuthorsEdge {
|
|
587
|
-
node: Author!
|
|
588
|
-
cursor: String!
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
type Author {
|
|
592
|
-
id: ID!
|
|
593
|
-
firstName: String!
|
|
594
|
-
createdAt: String!
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
input AuthorFilter {
|
|
598
|
-
id: [ID!]
|
|
599
|
-
firstName: [String!]
|
|
600
|
-
createdAt: [String!]
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
input SaveAuthorInput {
|
|
604
|
-
id: ID
|
|
605
|
-
firstName: String
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
type SaveAuthorResult {
|
|
609
|
-
author: Author!
|
|
610
|
-
}
|
|
611
|
-
"
|
|
612
|
-
`);
|
|
613
|
-
});
|
|
614
|
-
it("can output both Date and DateTime types for Temporal types", async () => {
|
|
615
|
-
// Given an author
|
|
616
|
-
const entities = [
|
|
617
|
-
(0, testUtils_1.newEntityMetadata)("Author", {
|
|
618
|
-
primitives: [
|
|
619
|
-
// With a regular field
|
|
620
|
-
(0, testUtils_1.newPrimitiveField)("firstName"),
|
|
621
|
-
// And a timestamp with time zone field
|
|
622
|
-
(0, testUtils_1.newPrimitiveField)("createdAt", { fieldType: utils_1.zonedDateTimeCode }),
|
|
623
|
-
// And a timestamp without time zone field
|
|
624
|
-
(0, testUtils_1.newPrimitiveField)("startTime", { fieldType: utils_1.plainDateTimeCode }),
|
|
625
|
-
// And also a date field
|
|
626
|
-
(0, testUtils_1.newPrimitiveField)("startDate", { fieldType: utils_1.plainDateCode }),
|
|
627
|
-
],
|
|
628
|
-
}),
|
|
629
|
-
];
|
|
630
|
-
// When ran
|
|
631
|
-
const fs = (0, testUtils_1.newFs)({});
|
|
632
|
-
await generate(fs, entities);
|
|
633
|
-
// Then the input has both types of fields as appropriate
|
|
634
|
-
expect(await fs.load("author.graphql")).toMatchInlineSnapshot(`
|
|
635
|
-
"extend type Query {
|
|
636
|
-
author(id: ID!): Author!
|
|
637
|
-
authors(filter: AuthorFilter, first: Int, after: String, last: Int, before: String): AuthorsConnection!
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
extend type Mutation {
|
|
641
|
-
saveAuthor(input: SaveAuthorInput!): SaveAuthorResult!
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
type AuthorsConnection {
|
|
645
|
-
edges: [AuthorsEdge!]!
|
|
646
|
-
nodes: [Author!]!
|
|
647
|
-
pageInfo: PageInfo!
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
type AuthorsEdge {
|
|
651
|
-
node: Author!
|
|
652
|
-
cursor: String!
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
type Author {
|
|
656
|
-
id: ID!
|
|
657
|
-
firstName: String!
|
|
658
|
-
createdAt: DateTime!
|
|
659
|
-
startTime: DateTime!
|
|
660
|
-
startDate: Date!
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
input AuthorFilter {
|
|
664
|
-
id: [ID!]
|
|
665
|
-
firstName: [String!]
|
|
666
|
-
createdAt: [DateTime!]
|
|
667
|
-
startTime: [DateTime!]
|
|
668
|
-
startDate: [Date!]
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
input SaveAuthorInput {
|
|
672
|
-
id: ID
|
|
673
|
-
firstName: String
|
|
674
|
-
createdAt: DateTime
|
|
675
|
-
startTime: DateTime
|
|
676
|
-
startDate: Date
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
type SaveAuthorResult {
|
|
680
|
-
author: Author!
|
|
681
|
-
}
|
|
682
|
-
"
|
|
683
|
-
`);
|
|
684
|
-
});
|
|
685
|
-
it("can output both Date and DateTime types for legacy Date fields", async () => {
|
|
686
|
-
// Given an author
|
|
687
|
-
const entities = [
|
|
688
|
-
(0, testUtils_1.newEntityMetadata)("Author", {
|
|
689
|
-
primitives: [
|
|
690
|
-
// With a regular field
|
|
691
|
-
(0, testUtils_1.newPrimitiveField)("firstName"),
|
|
692
|
-
// And a timestamp field with the `_at` convention
|
|
693
|
-
(0, testUtils_1.newPrimitiveField)("createdAt", { fieldType: utils_1.dateCode }),
|
|
694
|
-
// And also a date field with the `_date` convention
|
|
695
|
-
(0, testUtils_1.newPrimitiveField)("startDate", { fieldType: utils_1.dateCode }),
|
|
696
|
-
],
|
|
697
|
-
}),
|
|
698
|
-
];
|
|
699
|
-
// When ran
|
|
700
|
-
const fs = (0, testUtils_1.newFs)({});
|
|
701
|
-
await generate(fs, entities);
|
|
702
|
-
// Then the Author links to a PublisherLike
|
|
703
|
-
expect(await fs.load("author.graphql")).toMatchInlineSnapshot(`
|
|
704
|
-
"extend type Query {
|
|
705
|
-
author(id: ID!): Author!
|
|
706
|
-
authors(filter: AuthorFilter, first: Int, after: String, last: Int, before: String): AuthorsConnection!
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
extend type Mutation {
|
|
710
|
-
saveAuthor(input: SaveAuthorInput!): SaveAuthorResult!
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
type AuthorsConnection {
|
|
714
|
-
edges: [AuthorsEdge!]!
|
|
715
|
-
nodes: [Author!]!
|
|
716
|
-
pageInfo: PageInfo!
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
type AuthorsEdge {
|
|
720
|
-
node: Author!
|
|
721
|
-
cursor: String!
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
type Author {
|
|
725
|
-
id: ID!
|
|
726
|
-
firstName: String!
|
|
727
|
-
createdAt: DateTime!
|
|
728
|
-
startDate: Date!
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
input AuthorFilter {
|
|
732
|
-
id: [ID!]
|
|
733
|
-
firstName: [String!]
|
|
734
|
-
createdAt: [DateTime!]
|
|
735
|
-
startDate: [Date!]
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
input SaveAuthorInput {
|
|
739
|
-
id: ID
|
|
740
|
-
firstName: String
|
|
741
|
-
createdAt: DateTime
|
|
742
|
-
startDate: Date
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
type SaveAuthorResult {
|
|
746
|
-
author: Author!
|
|
747
|
-
}
|
|
748
|
-
"
|
|
749
|
-
`);
|
|
750
|
-
});
|
|
751
|
-
it("adds enum details", async () => {
|
|
752
|
-
// Given an author
|
|
753
|
-
const entities = [
|
|
754
|
-
(0, testUtils_1.newEntityMetadata)("Author", {
|
|
755
|
-
// With an enum array field
|
|
756
|
-
enums: [(0, testUtils_1.newEnumField)("color")],
|
|
757
|
-
}),
|
|
758
|
-
];
|
|
759
|
-
// When ran
|
|
760
|
-
const fs = (0, testUtils_1.newFs)({});
|
|
761
|
-
await generate(fs, entities);
|
|
762
|
-
// Then the input has both types of fields as appropriate
|
|
763
|
-
expect(await fs.load("author.graphql")).toMatchInlineSnapshot(`
|
|
764
|
-
"extend type Query {
|
|
765
|
-
author(id: ID!): Author!
|
|
766
|
-
authors(filter: AuthorFilter, first: Int, after: String, last: Int, before: String): AuthorsConnection!
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
extend type Mutation {
|
|
770
|
-
saveAuthor(input: SaveAuthorInput!): SaveAuthorResult!
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
type AuthorsConnection {
|
|
774
|
-
edges: [AuthorsEdge!]!
|
|
775
|
-
nodes: [Author!]!
|
|
776
|
-
pageInfo: PageInfo!
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
type AuthorsEdge {
|
|
780
|
-
node: Author!
|
|
781
|
-
cursor: String!
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
type Author {
|
|
785
|
-
id: ID!
|
|
786
|
-
color: ColorDetail!
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
input AuthorFilter {
|
|
790
|
-
id: [ID!]
|
|
791
|
-
color: [Color!]
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
input SaveAuthorInput {
|
|
795
|
-
id: ID
|
|
796
|
-
color: Color
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
type SaveAuthorResult {
|
|
800
|
-
author: Author!
|
|
801
|
-
}
|
|
802
|
-
"
|
|
803
|
-
`);
|
|
804
|
-
});
|
|
805
|
-
it("can enum array types", async () => {
|
|
806
|
-
// Given an author
|
|
807
|
-
const entities = [
|
|
808
|
-
(0, testUtils_1.newEntityMetadata)("Author", {
|
|
809
|
-
// With an enum array field
|
|
810
|
-
enums: [(0, testUtils_1.newEnumField)("color", { isArray: true })],
|
|
811
|
-
}),
|
|
812
|
-
];
|
|
813
|
-
// When ran
|
|
814
|
-
const fs = (0, testUtils_1.newFs)({});
|
|
815
|
-
await generate(fs, entities);
|
|
816
|
-
// Then the input has both types of fields as appropriate
|
|
817
|
-
expect(await fs.load("author.graphql")).toMatchInlineSnapshot(`
|
|
818
|
-
"extend type Query {
|
|
819
|
-
author(id: ID!): Author!
|
|
820
|
-
authors(filter: AuthorFilter, first: Int, after: String, last: Int, before: String): AuthorsConnection!
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
extend type Mutation {
|
|
824
|
-
saveAuthor(input: SaveAuthorInput!): SaveAuthorResult!
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
type AuthorsConnection {
|
|
828
|
-
edges: [AuthorsEdge!]!
|
|
829
|
-
nodes: [Author!]!
|
|
830
|
-
pageInfo: PageInfo!
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
type AuthorsEdge {
|
|
834
|
-
node: Author!
|
|
835
|
-
cursor: String!
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
type Author {
|
|
839
|
-
id: ID!
|
|
840
|
-
color: [Color!]!
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
input AuthorFilter {
|
|
844
|
-
id: [ID!]
|
|
845
|
-
color: [[Color!]!]
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
input SaveAuthorInput {
|
|
849
|
-
id: ID
|
|
850
|
-
color: [Color!]
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
type SaveAuthorResult {
|
|
854
|
-
author: Author!
|
|
855
|
-
}
|
|
856
|
-
"
|
|
857
|
-
`);
|
|
858
|
-
});
|
|
859
|
-
it("adds inherited fields", async () => {
|
|
860
|
-
// Given a small publisher which inherits from publisher
|
|
861
|
-
const entities = [
|
|
862
|
-
(0, testUtils_1.newEntityMetadata)("Publisher", {
|
|
863
|
-
primitives: [(0, testUtils_1.newPrimitiveField)("name")],
|
|
864
|
-
}),
|
|
865
|
-
(0, testUtils_1.newEntityMetadata)("SmallPublisher", {
|
|
866
|
-
baseClassName: "Publisher",
|
|
867
|
-
primitives: [(0, testUtils_1.newPrimitiveField)("city")],
|
|
868
|
-
}),
|
|
869
|
-
];
|
|
870
|
-
// When ran
|
|
871
|
-
const fs = (0, testUtils_1.newFs)({});
|
|
872
|
-
await generate(fs, entities);
|
|
873
|
-
// Then the input has both types of fields as appropriate
|
|
874
|
-
expect(await fs.load("smallPublisher.graphql")).toMatchInlineSnapshot(`
|
|
875
|
-
"extend type Query {
|
|
876
|
-
smallPublisher(id: ID!): SmallPublisher!
|
|
877
|
-
smallPublishers(
|
|
878
|
-
filter: SmallPublisherFilter
|
|
879
|
-
first: Int
|
|
880
|
-
after: String
|
|
881
|
-
last: Int
|
|
882
|
-
before: String
|
|
883
|
-
): SmallPublishersConnection!
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
extend type Mutation {
|
|
887
|
-
saveSmallPublisher(input: SaveSmallPublisherInput!): SaveSmallPublisherResult!
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
type SmallPublishersConnection {
|
|
891
|
-
edges: [SmallPublishersEdge!]!
|
|
892
|
-
nodes: [SmallPublisher!]!
|
|
893
|
-
pageInfo: PageInfo!
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
type SmallPublishersEdge {
|
|
897
|
-
node: SmallPublisher!
|
|
898
|
-
cursor: String!
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
type SmallPublisher {
|
|
902
|
-
id: ID!
|
|
903
|
-
name: String!
|
|
904
|
-
city: String!
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
input SmallPublisherFilter {
|
|
908
|
-
id: [ID!]
|
|
909
|
-
name: [String!]
|
|
910
|
-
city: [String!]
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
input SaveSmallPublisherInput {
|
|
914
|
-
id: ID
|
|
915
|
-
name: String
|
|
916
|
-
city: String
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
type SaveSmallPublisherResult {
|
|
920
|
-
smallPublisher: SmallPublisher!
|
|
921
|
-
}
|
|
922
|
-
"
|
|
923
|
-
`);
|
|
924
|
-
});
|
|
925
|
-
it("assumes a Like interface for subclassed & concrete base types", async () => {
|
|
926
|
-
// Given a small publisher which inherits from publisher
|
|
927
|
-
const entities = [
|
|
928
|
-
(0, testUtils_1.newEntityMetadata)("Publisher", {
|
|
929
|
-
primitives: [(0, testUtils_1.newPrimitiveField)("name")],
|
|
930
|
-
}),
|
|
931
|
-
(0, testUtils_1.newEntityMetadata)("SmallPublisher", {
|
|
932
|
-
baseClassName: "Publisher",
|
|
933
|
-
primitives: [(0, testUtils_1.newPrimitiveField)("city")],
|
|
934
|
-
}),
|
|
935
|
-
(0, testUtils_1.newEntityMetadata)("Author", {
|
|
936
|
-
manyToOnes: [(0, testUtils_1.newManyToOneField)("publisher", "Publisher")],
|
|
937
|
-
}),
|
|
938
|
-
];
|
|
939
|
-
// When ran
|
|
940
|
-
const fs = (0, testUtils_1.newFs)({});
|
|
941
|
-
await generate(fs, entities);
|
|
942
|
-
// Then the input has both types of fields as appropriate
|
|
943
|
-
expect(await fs.load("author.graphql")).toMatchInlineSnapshot(`
|
|
944
|
-
"extend type Query {
|
|
945
|
-
author(id: ID!): Author!
|
|
946
|
-
authors(filter: AuthorFilter, first: Int, after: String, last: Int, before: String): AuthorsConnection!
|
|
947
|
-
}
|
|
948
|
-
|
|
949
|
-
extend type Mutation {
|
|
950
|
-
saveAuthor(input: SaveAuthorInput!): SaveAuthorResult!
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
type AuthorsConnection {
|
|
954
|
-
edges: [AuthorsEdge!]!
|
|
955
|
-
nodes: [Author!]!
|
|
956
|
-
pageInfo: PageInfo!
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
type AuthorsEdge {
|
|
960
|
-
node: Author!
|
|
961
|
-
cursor: String!
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
type Author {
|
|
965
|
-
id: ID!
|
|
966
|
-
publisher: PublisherLike!
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
input AuthorFilter {
|
|
970
|
-
id: [ID!]
|
|
971
|
-
publisherId: [ID!]
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
input SaveAuthorInput {
|
|
975
|
-
id: ID
|
|
976
|
-
publisherId: ID
|
|
977
|
-
}
|
|
978
|
-
|
|
979
|
-
type SaveAuthorResult {
|
|
980
|
-
author: Author!
|
|
981
|
-
}
|
|
982
|
-
"
|
|
983
|
-
`);
|
|
984
|
-
});
|
|
985
|
-
});
|
|
986
|
-
async function generate(fs, opt, config = {}) {
|
|
987
|
-
const entities = Array.isArray(opt) ? opt : (opt.entities ?? []);
|
|
988
|
-
const entitiesByName = (0, joist_utils_1.keyBy)(entities, "name");
|
|
989
|
-
// Hook up baseType/subTypes
|
|
990
|
-
for (const entity of entities) {
|
|
991
|
-
if (entity.baseClassName) {
|
|
992
|
-
const baseType = entitiesByName[entity.baseClassName];
|
|
993
|
-
entity.baseType = baseType;
|
|
994
|
-
baseType.subTypes.push(entity);
|
|
995
|
-
}
|
|
996
|
-
}
|
|
997
|
-
const dbMeta = {
|
|
998
|
-
entities,
|
|
999
|
-
enums: {},
|
|
1000
|
-
pgEnums: {},
|
|
1001
|
-
joinTables: [],
|
|
1002
|
-
otherTables: [],
|
|
1003
|
-
totalTables: 10,
|
|
1004
|
-
entitiesByName,
|
|
1005
|
-
};
|
|
1006
|
-
return (0, generateGraphqlSchemaFiles_1.generateGraphqlSchemaFiles)(config, fs, dbMeta);
|
|
1007
|
-
}
|
|
1008
|
-
//# sourceMappingURL=generateGraphqlSchemaFiles.test.js.map
|