@constructive-io/graphql-server 3.1.1 → 4.0.1

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.
Files changed (77) hide show
  1. package/errors/404-message.js +1 -1
  2. package/errors/api-errors.d.ts +200 -0
  3. package/errors/api-errors.js +276 -0
  4. package/esm/errors/404-message.js +1 -1
  5. package/esm/errors/api-errors.js +261 -0
  6. package/esm/index.js +2 -0
  7. package/esm/middleware/api.js +355 -277
  8. package/esm/middleware/auth.js +25 -7
  9. package/esm/middleware/error-handler.js +86 -0
  10. package/esm/middleware/favicon.js +12 -0
  11. package/esm/middleware/graphile.js +149 -64
  12. package/esm/options.js +232 -0
  13. package/esm/schema.js +24 -11
  14. package/esm/server.js +41 -5
  15. package/index.d.ts +1 -0
  16. package/index.js +2 -0
  17. package/middleware/api.d.ts +3 -15
  18. package/middleware/api.js +359 -283
  19. package/middleware/auth.js +25 -7
  20. package/middleware/error-handler.d.ts +4 -0
  21. package/middleware/error-handler.js +94 -0
  22. package/middleware/favicon.d.ts +2 -0
  23. package/middleware/favicon.js +16 -0
  24. package/middleware/graphile.d.ts +14 -0
  25. package/middleware/graphile.js +149 -64
  26. package/options.d.ts +131 -0
  27. package/options.js +244 -0
  28. package/package.json +23 -24
  29. package/schema.d.ts +2 -2
  30. package/schema.js +23 -10
  31. package/server.d.ts +24 -2
  32. package/server.js +39 -3
  33. package/codegen/orm/client.d.ts +0 -55
  34. package/codegen/orm/client.js +0 -75
  35. package/codegen/orm/index.d.ts +0 -36
  36. package/codegen/orm/index.js +0 -59
  37. package/codegen/orm/input-types.d.ts +0 -20140
  38. package/codegen/orm/input-types.js +0 -2
  39. package/codegen/orm/models/api.d.ts +0 -42
  40. package/codegen/orm/models/api.js +0 -76
  41. package/codegen/orm/models/domain.d.ts +0 -42
  42. package/codegen/orm/models/domain.js +0 -76
  43. package/codegen/orm/models/index.d.ts +0 -7
  44. package/codegen/orm/models/index.js +0 -12
  45. package/codegen/orm/mutation/index.d.ts +0 -7
  46. package/codegen/orm/mutation/index.js +0 -7
  47. package/codegen/orm/query/index.d.ts +0 -20
  48. package/codegen/orm/query/index.js +0 -24
  49. package/codegen/orm/query-builder.d.ts +0 -81
  50. package/codegen/orm/query-builder.js +0 -496
  51. package/codegen/orm/select-types.d.ts +0 -83
  52. package/codegen/orm/select-types.js +0 -7
  53. package/codegen/orm/types.d.ts +0 -6
  54. package/codegen/orm/types.js +0 -23
  55. package/esm/codegen/orm/client.js +0 -70
  56. package/esm/codegen/orm/index.js +0 -39
  57. package/esm/codegen/orm/input-types.js +0 -1
  58. package/esm/codegen/orm/models/api.js +0 -72
  59. package/esm/codegen/orm/models/domain.js +0 -72
  60. package/esm/codegen/orm/models/index.js +0 -7
  61. package/esm/codegen/orm/mutation/index.js +0 -4
  62. package/esm/codegen/orm/query/index.js +0 -21
  63. package/esm/codegen/orm/query-builder.js +0 -452
  64. package/esm/codegen/orm/select-types.js +0 -6
  65. package/esm/codegen/orm/types.js +0 -7
  66. package/esm/middleware/gql.js +0 -116
  67. package/esm/plugins/PublicKeySignature.js +0 -114
  68. package/esm/scripts/codegen-schema.js +0 -71
  69. package/esm/scripts/create-bucket.js +0 -40
  70. package/middleware/gql.d.ts +0 -164
  71. package/middleware/gql.js +0 -121
  72. package/plugins/PublicKeySignature.d.ts +0 -11
  73. package/plugins/PublicKeySignature.js +0 -121
  74. package/scripts/codegen-schema.d.ts +0 -1
  75. package/scripts/codegen-schema.js +0 -76
  76. package/scripts/create-bucket.d.ts +0 -1
  77. package/scripts/create-bucket.js +0 -42
@@ -1,39 +0,0 @@
1
- /**
2
- * ORM Client - createClient factory
3
- * @generated by @constructive-io/graphql-codegen
4
- * DO NOT EDIT - changes will be overwritten
5
- */
6
- import { OrmClient } from './client';
7
- import { ApiModel } from './models/api';
8
- import { DomainModel } from './models/domain';
9
- import { createQueryOperations } from './query';
10
- import { createMutationOperations } from './mutation';
11
- export { GraphQLRequestError } from './client';
12
- export { QueryBuilder } from './query-builder';
13
- export * from './select-types';
14
- /**
15
- * Create an ORM client instance
16
- *
17
- * @example
18
- * ```typescript
19
- * const db = createClient({
20
- * endpoint: 'https://api.example.com/graphql',
21
- * headers: { Authorization: 'Bearer token' },
22
- * });
23
- *
24
- * // Query apis
25
- * const apis = await db.api.findMany({
26
- * select: { id: true, name: true },
27
- * first: 10,
28
- * }).execute();
29
- * ```
30
- */
31
- export function createClient(config) {
32
- const client = new OrmClient(config);
33
- return {
34
- api: new ApiModel(client),
35
- domain: new DomainModel(client),
36
- query: createQueryOperations(client),
37
- mutation: createMutationOperations(client),
38
- };
39
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,72 +0,0 @@
1
- import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateDocument, buildDeleteDocument, } from '../query-builder';
2
- export class ApiModel {
3
- client;
4
- constructor(client) {
5
- this.client = client;
6
- }
7
- findMany(args) {
8
- const { document, variables } = buildFindManyDocument('Api', 'apis', args?.select, {
9
- where: args?.where,
10
- orderBy: args?.orderBy,
11
- first: args?.first,
12
- last: args?.last,
13
- after: args?.after,
14
- before: args?.before,
15
- offset: args?.offset,
16
- }, 'ApiFilter', 'ApisOrderBy');
17
- return new QueryBuilder({
18
- client: this.client,
19
- operation: 'query',
20
- operationName: 'Api',
21
- fieldName: 'apis',
22
- document,
23
- variables,
24
- });
25
- }
26
- findFirst(args) {
27
- const { document, variables } = buildFindFirstDocument('Api', 'apis', args?.select, {
28
- where: args?.where,
29
- }, 'ApiFilter');
30
- return new QueryBuilder({
31
- client: this.client,
32
- operation: 'query',
33
- operationName: 'Api',
34
- fieldName: 'apis',
35
- document,
36
- variables,
37
- });
38
- }
39
- create(args) {
40
- const { document, variables } = buildCreateDocument('Api', 'createApi', 'api', args.select, args.data, 'CreateApiInput');
41
- return new QueryBuilder({
42
- client: this.client,
43
- operation: 'mutation',
44
- operationName: 'Api',
45
- fieldName: 'createApi',
46
- document,
47
- variables,
48
- });
49
- }
50
- update(args) {
51
- const { document, variables } = buildUpdateDocument('Api', 'updateApi', 'api', args.select, args.where, args.data, 'UpdateApiInput');
52
- return new QueryBuilder({
53
- client: this.client,
54
- operation: 'mutation',
55
- operationName: 'Api',
56
- fieldName: 'updateApi',
57
- document,
58
- variables,
59
- });
60
- }
61
- delete(args) {
62
- const { document, variables } = buildDeleteDocument('Api', 'deleteApi', 'api', args.where, 'DeleteApiInput');
63
- return new QueryBuilder({
64
- client: this.client,
65
- operation: 'mutation',
66
- operationName: 'Api',
67
- fieldName: 'deleteApi',
68
- document,
69
- variables,
70
- });
71
- }
72
- }
@@ -1,72 +0,0 @@
1
- import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateDocument, buildDeleteDocument, } from '../query-builder';
2
- export class DomainModel {
3
- client;
4
- constructor(client) {
5
- this.client = client;
6
- }
7
- findMany(args) {
8
- const { document, variables } = buildFindManyDocument('Domain', 'domains', args?.select, {
9
- where: args?.where,
10
- orderBy: args?.orderBy,
11
- first: args?.first,
12
- last: args?.last,
13
- after: args?.after,
14
- before: args?.before,
15
- offset: args?.offset,
16
- }, 'DomainFilter', 'DomainsOrderBy');
17
- return new QueryBuilder({
18
- client: this.client,
19
- operation: 'query',
20
- operationName: 'Domain',
21
- fieldName: 'domains',
22
- document,
23
- variables,
24
- });
25
- }
26
- findFirst(args) {
27
- const { document, variables } = buildFindFirstDocument('Domain', 'domains', args?.select, {
28
- where: args?.where,
29
- }, 'DomainFilter');
30
- return new QueryBuilder({
31
- client: this.client,
32
- operation: 'query',
33
- operationName: 'Domain',
34
- fieldName: 'domains',
35
- document,
36
- variables,
37
- });
38
- }
39
- create(args) {
40
- const { document, variables } = buildCreateDocument('Domain', 'createDomain', 'domain', args.select, args.data, 'CreateDomainInput');
41
- return new QueryBuilder({
42
- client: this.client,
43
- operation: 'mutation',
44
- operationName: 'Domain',
45
- fieldName: 'createDomain',
46
- document,
47
- variables,
48
- });
49
- }
50
- update(args) {
51
- const { document, variables } = buildUpdateDocument('Domain', 'updateDomain', 'domain', args.select, args.where, args.data, 'UpdateDomainInput');
52
- return new QueryBuilder({
53
- client: this.client,
54
- operation: 'mutation',
55
- operationName: 'Domain',
56
- fieldName: 'updateDomain',
57
- document,
58
- variables,
59
- });
60
- }
61
- delete(args) {
62
- const { document, variables } = buildDeleteDocument('Domain', 'deleteDomain', 'domain', args.where, 'DeleteDomainInput');
63
- return new QueryBuilder({
64
- client: this.client,
65
- operation: 'mutation',
66
- operationName: 'Domain',
67
- fieldName: 'deleteDomain',
68
- document,
69
- variables,
70
- });
71
- }
72
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * Models barrel export
3
- * @generated by @constructive-io/graphql-codegen
4
- * DO NOT EDIT - changes will be overwritten
5
- */
6
- export { ApiModel } from './api';
7
- export { DomainModel } from './domain';
@@ -1,4 +0,0 @@
1
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2
- export function createMutationOperations(client) {
3
- return {};
4
- }
@@ -1,21 +0,0 @@
1
- import { QueryBuilder, buildCustomDocument } from '../query-builder';
2
- export function createQueryOperations(client) {
3
- return {
4
- apiByDatabaseIdAndName: (args, options) => new QueryBuilder({
5
- client,
6
- operation: 'query',
7
- operationName: 'ApiByDatabaseIdAndName',
8
- fieldName: 'apiByDatabaseIdAndName',
9
- ...buildCustomDocument('query', 'ApiByDatabaseIdAndName', 'apiByDatabaseIdAndName', options?.select, args, [
10
- {
11
- name: 'databaseId',
12
- type: 'UUID!',
13
- },
14
- {
15
- name: 'name',
16
- type: 'String!',
17
- },
18
- ]),
19
- }),
20
- };
21
- }
@@ -1,452 +0,0 @@
1
- /**
2
- * Query Builder - Builds and executes GraphQL operations
3
- * @generated by @constructive-io/graphql-codegen
4
- * DO NOT EDIT - changes will be overwritten
5
- */
6
- import * as t from 'gql-ast';
7
- import { parseType, print } from 'graphql';
8
- import { GraphQLRequestError } from './client';
9
- export class QueryBuilder {
10
- config;
11
- constructor(config) {
12
- this.config = config;
13
- }
14
- /**
15
- * Execute the query and return a discriminated union result
16
- * Use result.ok to check success, or .unwrap() to throw on error
17
- */
18
- async execute() {
19
- return this.config.client.execute(this.config.document, this.config.variables);
20
- }
21
- /**
22
- * Execute and unwrap the result, throwing GraphQLRequestError on failure
23
- * @throws {GraphQLRequestError} If the query returns errors
24
- */
25
- async unwrap() {
26
- const result = await this.execute();
27
- if (!result.ok) {
28
- throw new GraphQLRequestError(result.errors, result.data);
29
- }
30
- return result.data;
31
- }
32
- /**
33
- * Execute and unwrap, returning defaultValue on error instead of throwing
34
- */
35
- async unwrapOr(defaultValue) {
36
- const result = await this.execute();
37
- if (!result.ok) {
38
- return defaultValue;
39
- }
40
- return result.data;
41
- }
42
- /**
43
- * Execute and unwrap, calling onError callback on failure
44
- */
45
- async unwrapOrElse(onError) {
46
- const result = await this.execute();
47
- if (!result.ok) {
48
- return onError(result.errors);
49
- }
50
- return result.data;
51
- }
52
- toGraphQL() {
53
- return this.config.document;
54
- }
55
- getVariables() {
56
- return this.config.variables;
57
- }
58
- }
59
- // ============================================================================
60
- // Selection Builders
61
- // ============================================================================
62
- export function buildSelections(select) {
63
- if (!select) {
64
- return [];
65
- }
66
- const fields = [];
67
- for (const [key, value] of Object.entries(select)) {
68
- if (value === false || value === undefined) {
69
- continue;
70
- }
71
- if (value === true) {
72
- fields.push(t.field({ name: key }));
73
- continue;
74
- }
75
- if (typeof value === 'object' && value !== null) {
76
- const nested = value;
77
- if (nested.select) {
78
- const nestedSelections = buildSelections(nested.select);
79
- const isConnection = nested.connection === true ||
80
- nested.first !== undefined ||
81
- nested.filter !== undefined;
82
- const args = buildArgs([
83
- buildOptionalArg('first', nested.first),
84
- nested.filter
85
- ? t.argument({
86
- name: 'filter',
87
- value: buildValueAst(nested.filter),
88
- })
89
- : null,
90
- buildEnumListArg('orderBy', nested.orderBy),
91
- ]);
92
- if (isConnection) {
93
- fields.push(t.field({
94
- name: key,
95
- args,
96
- selectionSet: t.selectionSet({
97
- selections: buildConnectionSelections(nestedSelections),
98
- }),
99
- }));
100
- }
101
- else {
102
- fields.push(t.field({
103
- name: key,
104
- args,
105
- selectionSet: t.selectionSet({ selections: nestedSelections }),
106
- }));
107
- }
108
- }
109
- }
110
- }
111
- return fields;
112
- }
113
- // ============================================================================
114
- // Document Builders
115
- // ============================================================================
116
- export function buildFindManyDocument(operationName, queryField, select, args, filterTypeName, orderByTypeName) {
117
- const selections = select
118
- ? buildSelections(select)
119
- : [t.field({ name: 'id' })];
120
- const variableDefinitions = [];
121
- const queryArgs = [];
122
- const variables = {};
123
- addVariable({
124
- varName: 'where',
125
- argName: 'filter',
126
- typeName: filterTypeName,
127
- value: args.where,
128
- }, variableDefinitions, queryArgs, variables);
129
- addVariable({
130
- varName: 'orderBy',
131
- typeName: '[' + orderByTypeName + '!]',
132
- value: args.orderBy?.length ? args.orderBy : undefined,
133
- }, variableDefinitions, queryArgs, variables);
134
- addVariable({ varName: 'first', typeName: 'Int', value: args.first }, variableDefinitions, queryArgs, variables);
135
- addVariable({ varName: 'last', typeName: 'Int', value: args.last }, variableDefinitions, queryArgs, variables);
136
- addVariable({ varName: 'after', typeName: 'Cursor', value: args.after }, variableDefinitions, queryArgs, variables);
137
- addVariable({ varName: 'before', typeName: 'Cursor', value: args.before }, variableDefinitions, queryArgs, variables);
138
- addVariable({ varName: 'offset', typeName: 'Int', value: args.offset }, variableDefinitions, queryArgs, variables);
139
- const document = t.document({
140
- definitions: [
141
- t.operationDefinition({
142
- operation: 'query',
143
- name: operationName + 'Query',
144
- variableDefinitions: variableDefinitions.length
145
- ? variableDefinitions
146
- : undefined,
147
- selectionSet: t.selectionSet({
148
- selections: [
149
- t.field({
150
- name: queryField,
151
- args: queryArgs.length ? queryArgs : undefined,
152
- selectionSet: t.selectionSet({
153
- selections: buildConnectionSelections(selections),
154
- }),
155
- }),
156
- ],
157
- }),
158
- }),
159
- ],
160
- });
161
- return { document: print(document), variables };
162
- }
163
- export function buildFindFirstDocument(operationName, queryField, select, args, filterTypeName) {
164
- const selections = select
165
- ? buildSelections(select)
166
- : [t.field({ name: 'id' })];
167
- const variableDefinitions = [];
168
- const queryArgs = [];
169
- const variables = {};
170
- // Always add first: 1 for findFirst
171
- addVariable({ varName: 'first', typeName: 'Int', value: 1 }, variableDefinitions, queryArgs, variables);
172
- addVariable({
173
- varName: 'where',
174
- argName: 'filter',
175
- typeName: filterTypeName,
176
- value: args.where,
177
- }, variableDefinitions, queryArgs, variables);
178
- const document = t.document({
179
- definitions: [
180
- t.operationDefinition({
181
- operation: 'query',
182
- name: operationName + 'Query',
183
- variableDefinitions,
184
- selectionSet: t.selectionSet({
185
- selections: [
186
- t.field({
187
- name: queryField,
188
- args: queryArgs,
189
- selectionSet: t.selectionSet({
190
- selections: [
191
- t.field({
192
- name: 'nodes',
193
- selectionSet: t.selectionSet({ selections }),
194
- }),
195
- ],
196
- }),
197
- }),
198
- ],
199
- }),
200
- }),
201
- ],
202
- });
203
- return { document: print(document), variables };
204
- }
205
- export function buildCreateDocument(operationName, mutationField, entityField, select, data, inputTypeName) {
206
- const selections = select
207
- ? buildSelections(select)
208
- : [t.field({ name: 'id' })];
209
- return {
210
- document: buildInputMutationDocument({
211
- operationName,
212
- mutationField,
213
- inputTypeName,
214
- resultSelections: [
215
- t.field({
216
- name: entityField,
217
- selectionSet: t.selectionSet({ selections }),
218
- }),
219
- ],
220
- }),
221
- variables: {
222
- input: {
223
- [entityField]: data,
224
- },
225
- },
226
- };
227
- }
228
- export function buildUpdateDocument(operationName, mutationField, entityField, select, where, data, inputTypeName) {
229
- const selections = select
230
- ? buildSelections(select)
231
- : [t.field({ name: 'id' })];
232
- return {
233
- document: buildInputMutationDocument({
234
- operationName,
235
- mutationField,
236
- inputTypeName,
237
- resultSelections: [
238
- t.field({
239
- name: entityField,
240
- selectionSet: t.selectionSet({ selections }),
241
- }),
242
- ],
243
- }),
244
- variables: {
245
- input: {
246
- id: where.id,
247
- patch: data,
248
- },
249
- },
250
- };
251
- }
252
- export function buildDeleteDocument(operationName, mutationField, entityField, where, inputTypeName) {
253
- return {
254
- document: buildInputMutationDocument({
255
- operationName,
256
- mutationField,
257
- inputTypeName,
258
- resultSelections: [
259
- t.field({
260
- name: entityField,
261
- selectionSet: t.selectionSet({
262
- selections: [t.field({ name: 'id' })],
263
- }),
264
- }),
265
- ],
266
- }),
267
- variables: {
268
- input: {
269
- id: where.id,
270
- },
271
- },
272
- };
273
- }
274
- export function buildCustomDocument(operationType, operationName, fieldName, select, args, variableDefinitions) {
275
- let actualSelect = select;
276
- let isConnection = false;
277
- if (select && typeof select === 'object' && 'select' in select) {
278
- const wrapper = select;
279
- if (wrapper.select) {
280
- actualSelect = wrapper.select;
281
- isConnection = wrapper.connection === true;
282
- }
283
- }
284
- const selections = actualSelect
285
- ? buildSelections(actualSelect)
286
- : [];
287
- const variableDefs = variableDefinitions.map((definition) => t.variableDefinition({
288
- variable: t.variable({ name: definition.name }),
289
- type: parseType(definition.type),
290
- }));
291
- const fieldArgs = variableDefinitions.map((definition) => t.argument({
292
- name: definition.name,
293
- value: t.variable({ name: definition.name }),
294
- }));
295
- const fieldSelections = isConnection
296
- ? buildConnectionSelections(selections)
297
- : selections;
298
- const document = t.document({
299
- definitions: [
300
- t.operationDefinition({
301
- operation: operationType,
302
- name: operationName,
303
- variableDefinitions: variableDefs.length ? variableDefs : undefined,
304
- selectionSet: t.selectionSet({
305
- selections: [
306
- t.field({
307
- name: fieldName,
308
- args: fieldArgs.length ? fieldArgs : undefined,
309
- selectionSet: fieldSelections.length
310
- ? t.selectionSet({ selections: fieldSelections })
311
- : undefined,
312
- }),
313
- ],
314
- }),
315
- }),
316
- ],
317
- });
318
- return {
319
- document: print(document),
320
- variables: (args ?? {}),
321
- };
322
- }
323
- // ============================================================================
324
- // Helper Functions
325
- // ============================================================================
326
- function buildArgs(args) {
327
- return args.filter((arg) => arg !== null);
328
- }
329
- function buildOptionalArg(name, value) {
330
- if (value === undefined) {
331
- return null;
332
- }
333
- const valueNode = typeof value === 'number'
334
- ? t.intValue({ value: value.toString() })
335
- : t.stringValue({ value });
336
- return t.argument({ name, value: valueNode });
337
- }
338
- function buildEnumListArg(name, values) {
339
- if (!values || values.length === 0) {
340
- return null;
341
- }
342
- return t.argument({
343
- name,
344
- value: t.listValue({
345
- values: values.map((value) => buildEnumValue(value)),
346
- }),
347
- });
348
- }
349
- function buildEnumValue(value) {
350
- return {
351
- kind: 'EnumValue',
352
- value,
353
- };
354
- }
355
- function buildPageInfoSelections() {
356
- return [
357
- t.field({ name: 'hasNextPage' }),
358
- t.field({ name: 'hasPreviousPage' }),
359
- t.field({ name: 'startCursor' }),
360
- t.field({ name: 'endCursor' }),
361
- ];
362
- }
363
- function buildConnectionSelections(nodeSelections) {
364
- return [
365
- t.field({
366
- name: 'nodes',
367
- selectionSet: t.selectionSet({ selections: nodeSelections }),
368
- }),
369
- t.field({ name: 'totalCount' }),
370
- t.field({
371
- name: 'pageInfo',
372
- selectionSet: t.selectionSet({ selections: buildPageInfoSelections() }),
373
- }),
374
- ];
375
- }
376
- function buildInputMutationDocument(config) {
377
- const document = t.document({
378
- definitions: [
379
- t.operationDefinition({
380
- operation: 'mutation',
381
- name: config.operationName + 'Mutation',
382
- variableDefinitions: [
383
- t.variableDefinition({
384
- variable: t.variable({ name: 'input' }),
385
- type: parseType(config.inputTypeName + '!'),
386
- }),
387
- ],
388
- selectionSet: t.selectionSet({
389
- selections: [
390
- t.field({
391
- name: config.mutationField,
392
- args: [
393
- t.argument({
394
- name: 'input',
395
- value: t.variable({ name: 'input' }),
396
- }),
397
- ],
398
- selectionSet: t.selectionSet({
399
- selections: config.resultSelections,
400
- }),
401
- }),
402
- ],
403
- }),
404
- }),
405
- ],
406
- });
407
- return print(document);
408
- }
409
- function addVariable(spec, definitions, args, variables) {
410
- if (spec.value === undefined)
411
- return;
412
- definitions.push(t.variableDefinition({
413
- variable: t.variable({ name: spec.varName }),
414
- type: parseType(spec.typeName),
415
- }));
416
- args.push(t.argument({
417
- name: spec.argName ?? spec.varName,
418
- value: t.variable({ name: spec.varName }),
419
- }));
420
- variables[spec.varName] = spec.value;
421
- }
422
- function buildValueAst(value) {
423
- if (value === null) {
424
- return t.nullValue();
425
- }
426
- if (typeof value === 'boolean') {
427
- return t.booleanValue({ value });
428
- }
429
- if (typeof value === 'number') {
430
- return Number.isInteger(value)
431
- ? t.intValue({ value: value.toString() })
432
- : t.floatValue({ value: value.toString() });
433
- }
434
- if (typeof value === 'string') {
435
- return t.stringValue({ value });
436
- }
437
- if (Array.isArray(value)) {
438
- return t.listValue({
439
- values: value.map((item) => buildValueAst(item)),
440
- });
441
- }
442
- if (typeof value === 'object' && value !== null) {
443
- const obj = value;
444
- return t.objectValue({
445
- fields: Object.entries(obj).map(([key, val]) => t.objectField({
446
- name: key,
447
- value: buildValueAst(val),
448
- })),
449
- });
450
- }
451
- throw new Error('Unsupported value type: ' + typeof value);
452
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * Type utilities for select inference
3
- * @generated by @constructive-io/graphql-codegen
4
- * DO NOT EDIT - changes will be overwritten
5
- */
6
- export {};
@@ -1,7 +0,0 @@
1
- /**
2
- * Types re-export
3
- * @generated by @constructive-io/graphql-codegen
4
- * DO NOT EDIT - changes will be overwritten
5
- */
6
- // Re-export all types from input-types
7
- export * from './input-types';