@depup/graphql-codegen__typescript-operations 5.0.9-depup.0 → 6.1.2-depup.0
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/LICENSE +21 -0
- package/README.md +5 -6
- package/changes.json +4 -8
- package/cjs/index.js +65 -28
- package/cjs/ts-operation-variables-to-object.js +47 -2
- package/cjs/ts-selection-set-processor.js +4 -10
- package/cjs/visitor.js +502 -31
- package/esm/index.js +48 -21
- package/esm/ts-operation-variables-to-object.js +47 -2
- package/esm/ts-selection-set-processor.js +4 -10
- package/esm/visitor.js +503 -32
- package/package.json +17 -19
- package/typings/config.d.cts +184 -89
- package/typings/config.d.ts +184 -89
- package/typings/index.d.cts +1 -2
- package/typings/index.d.ts +1 -2
- package/typings/ts-operation-variables-to-object.d.cts +16 -2
- package/typings/ts-operation-variables-to-object.d.ts +16 -2
- package/typings/ts-selection-set-processor.d.cts +1 -1
- package/typings/ts-selection-set-processor.d.ts +1 -1
- package/typings/visitor.d.cts +50 -5
- package/typings/visitor.d.ts +50 -5
package/typings/config.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RawDocumentsConfig, type ConvertSchemaEnumToDeclarationBlockString, type EnumValuesMap } from '@graphql-codegen/visitor-plugin-common';
|
|
2
2
|
/**
|
|
3
3
|
* @description This plugin generates TypeScript types based on your GraphQLSchema _and_ your GraphQL operations and fragments.
|
|
4
4
|
* It generates types for your GraphQL documents: Query, Mutation, Subscription and Fragment.
|
|
5
|
-
*
|
|
6
|
-
* Note: In most configurations, this plugin requires you to use `typescript as well, because it depends on its base types.
|
|
7
5
|
*/
|
|
8
6
|
export interface TypeScriptDocumentsPluginConfig extends RawDocumentsConfig {
|
|
9
7
|
/**
|
|
@@ -22,7 +20,7 @@ export interface TypeScriptDocumentsPluginConfig extends RawDocumentsConfig {
|
|
|
22
20
|
* // ...
|
|
23
21
|
* generates: {
|
|
24
22
|
* 'path/to/file.ts': {
|
|
25
|
-
* plugins: ['typescript'],
|
|
23
|
+
* plugins: ['typescript-operations'],
|
|
26
24
|
* config: {
|
|
27
25
|
* arrayInputCoercion: false
|
|
28
26
|
* },
|
|
@@ -33,57 +31,6 @@ export interface TypeScriptDocumentsPluginConfig extends RawDocumentsConfig {
|
|
|
33
31
|
* ```
|
|
34
32
|
*/
|
|
35
33
|
arrayInputCoercion?: boolean;
|
|
36
|
-
/**
|
|
37
|
-
* @description This will cause the generator to avoid using TypeScript optionals (`?`) on types,
|
|
38
|
-
* so the following definition: `type A { myField: String }` will output `myField: Maybe<string>`
|
|
39
|
-
* instead of `myField?: Maybe<string>`.
|
|
40
|
-
* @default false
|
|
41
|
-
*
|
|
42
|
-
* @exampleMarkdown
|
|
43
|
-
* ## Override all definition types
|
|
44
|
-
*
|
|
45
|
-
* ```ts filename="codegen.ts"
|
|
46
|
-
* import type { CodegenConfig } from '@graphql-codegen/cli';
|
|
47
|
-
*
|
|
48
|
-
* const config: CodegenConfig = {
|
|
49
|
-
* // ...
|
|
50
|
-
* generates: {
|
|
51
|
-
* 'path/to/file.ts': {
|
|
52
|
-
* plugins: ['typescript'],
|
|
53
|
-
* config: {
|
|
54
|
-
* avoidOptionals: true
|
|
55
|
-
* },
|
|
56
|
-
* },
|
|
57
|
-
* },
|
|
58
|
-
* };
|
|
59
|
-
* export default config;
|
|
60
|
-
* ```
|
|
61
|
-
*
|
|
62
|
-
* ## Override only specific definition types
|
|
63
|
-
*
|
|
64
|
-
* ```ts filename="codegen.ts"
|
|
65
|
-
* import type { CodegenConfig } from '@graphql-codegen/cli';
|
|
66
|
-
*
|
|
67
|
-
* const config: CodegenConfig = {
|
|
68
|
-
* // ...
|
|
69
|
-
* generates: {
|
|
70
|
-
* 'path/to/file.ts': {
|
|
71
|
-
* plugins: ['typescript'],
|
|
72
|
-
* config: {
|
|
73
|
-
* avoidOptionals: {
|
|
74
|
-
* field: true
|
|
75
|
-
* inputValue: true
|
|
76
|
-
* object: true
|
|
77
|
-
* defaultValue: true
|
|
78
|
-
* }
|
|
79
|
-
* },
|
|
80
|
-
* },
|
|
81
|
-
* },
|
|
82
|
-
* };
|
|
83
|
-
* export default config;
|
|
84
|
-
* ```
|
|
85
|
-
*/
|
|
86
|
-
avoidOptionals?: boolean | AvoidOptionalsConfig;
|
|
87
34
|
/**
|
|
88
35
|
* @description Generates immutable types by adding `readonly` to properties and uses `ReadonlyArray`.
|
|
89
36
|
* @default false
|
|
@@ -96,7 +43,7 @@ export interface TypeScriptDocumentsPluginConfig extends RawDocumentsConfig {
|
|
|
96
43
|
* // ...
|
|
97
44
|
* generates: {
|
|
98
45
|
* 'path/to/file.ts': {
|
|
99
|
-
* plugins: ['typescript'],
|
|
46
|
+
* plugins: ['typescript-operations'],
|
|
100
47
|
* config: {
|
|
101
48
|
* immutableTypes: true
|
|
102
49
|
* },
|
|
@@ -119,7 +66,7 @@ export interface TypeScriptDocumentsPluginConfig extends RawDocumentsConfig {
|
|
|
119
66
|
* // ...
|
|
120
67
|
* generates: {
|
|
121
68
|
* 'path/to/file.ts': {
|
|
122
|
-
* plugins: ['typescript
|
|
69
|
+
* plugins: ['typescript-operations'],
|
|
123
70
|
* config: {
|
|
124
71
|
* flattenGeneratedTypes: true
|
|
125
72
|
* },
|
|
@@ -142,7 +89,7 @@ export interface TypeScriptDocumentsPluginConfig extends RawDocumentsConfig {
|
|
|
142
89
|
* // ...
|
|
143
90
|
* generates: {
|
|
144
91
|
* 'path/to/file.ts': {
|
|
145
|
-
* plugins: ['typescript
|
|
92
|
+
* plugins: ['typescript-operations'],
|
|
146
93
|
* config: {
|
|
147
94
|
* flattenGeneratedTypes: true,
|
|
148
95
|
* flattenGeneratedTypesIncludeFragments: true
|
|
@@ -167,7 +114,7 @@ export interface TypeScriptDocumentsPluginConfig extends RawDocumentsConfig {
|
|
|
167
114
|
* // ...
|
|
168
115
|
* generates: {
|
|
169
116
|
* 'path/to/file.ts': {
|
|
170
|
-
* plugins: ['typescript'],
|
|
117
|
+
* plugins: ['typescript-operations'],
|
|
171
118
|
* config: {
|
|
172
119
|
* noExport: true
|
|
173
120
|
* },
|
|
@@ -178,7 +125,6 @@ export interface TypeScriptDocumentsPluginConfig extends RawDocumentsConfig {
|
|
|
178
125
|
* ```
|
|
179
126
|
*/
|
|
180
127
|
noExport?: boolean;
|
|
181
|
-
globalNamespace?: boolean;
|
|
182
128
|
/**
|
|
183
129
|
* @name addOperationExport
|
|
184
130
|
* @type boolean
|
|
@@ -199,23 +145,19 @@ export interface TypeScriptDocumentsPluginConfig extends RawDocumentsConfig {
|
|
|
199
145
|
* const config: CodegenConfig = {
|
|
200
146
|
* // ...
|
|
201
147
|
* generates: {
|
|
202
|
-
* "./
|
|
203
|
-
* "plugins": [
|
|
204
|
-
* "typescript"
|
|
205
|
-
* ]
|
|
206
|
-
* },
|
|
207
|
-
* "./": {
|
|
148
|
+
* "./": {
|
|
208
149
|
* "preset": "near-operation-file",
|
|
209
150
|
* "presetConfig": {
|
|
210
|
-
*
|
|
211
|
-
*
|
|
151
|
+
* "baseTypesPath": "./typings/api.ts",
|
|
152
|
+
* "extension": ".gql.d.ts"
|
|
212
153
|
* },
|
|
213
154
|
* "plugins": [
|
|
214
|
-
*
|
|
155
|
+
* "typescript-operations"
|
|
215
156
|
* ],
|
|
216
157
|
* "config": {
|
|
217
|
-
*
|
|
158
|
+
* "addOperationExport": true
|
|
218
159
|
* }
|
|
160
|
+
* }
|
|
219
161
|
* }
|
|
220
162
|
* };
|
|
221
163
|
* export default config;
|
|
@@ -223,11 +165,13 @@ export interface TypeScriptDocumentsPluginConfig extends RawDocumentsConfig {
|
|
|
223
165
|
*/
|
|
224
166
|
addOperationExport?: boolean;
|
|
225
167
|
/**
|
|
226
|
-
* @description
|
|
168
|
+
* @description Allows overriding the type value of nullable fields to match GraphQL client's runtime behaviour.
|
|
227
169
|
* @default T | null
|
|
228
170
|
*
|
|
229
171
|
* @exampleMarkdown
|
|
230
172
|
* ## Allow undefined
|
|
173
|
+
* By default, a GraphQL server will return either the expected type or `null` for a nullable field.
|
|
174
|
+
* `maybeValue` option could be used to change this behaviour if your GraphQL client does something different such as returning `undefined`.
|
|
231
175
|
* ```ts filename="codegen.ts"
|
|
232
176
|
* import type { CodegenConfig } from '@graphql-codegen/cli';
|
|
233
177
|
*
|
|
@@ -235,7 +179,7 @@ export interface TypeScriptDocumentsPluginConfig extends RawDocumentsConfig {
|
|
|
235
179
|
* // ...
|
|
236
180
|
* generates: {
|
|
237
181
|
* 'path/to/file.ts': {
|
|
238
|
-
* plugins: ['typescript'],
|
|
182
|
+
* plugins: ['typescript-operations'],
|
|
239
183
|
* config: {
|
|
240
184
|
* maybeValue: 'T | null | undefined'
|
|
241
185
|
* },
|
|
@@ -244,26 +188,37 @@ export interface TypeScriptDocumentsPluginConfig extends RawDocumentsConfig {
|
|
|
244
188
|
* };
|
|
245
189
|
* export default config;
|
|
246
190
|
* ```
|
|
191
|
+
*/
|
|
192
|
+
maybeValue?: string;
|
|
193
|
+
/**
|
|
194
|
+
* @description Allows overriding the type of Input and Variables nullable types.
|
|
195
|
+
* @default T | null | undefined
|
|
196
|
+
*
|
|
197
|
+
* @exampleMarkdown
|
|
198
|
+
* ## Disallow `undefined`
|
|
199
|
+
* Disallowing `undefined` is useful if you want to force explicit null to be passed in as Variables to the server. Use `inputMaybeValue: 'T | null'` with `avoidOptionals.inputValue: true` to achieve this.
|
|
247
200
|
*
|
|
248
|
-
* ## Allow `null` in resolvers:
|
|
249
201
|
* ```ts filename="codegen.ts"
|
|
250
|
-
*
|
|
202
|
+
* import type { CodegenConfig } from '@graphql-codegen/cli'
|
|
251
203
|
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
204
|
+
* const config: CodegenConfig = {
|
|
205
|
+
* // ...
|
|
206
|
+
* generates: {
|
|
207
|
+
* 'path/to/file.ts': {
|
|
208
|
+
* plugins: ['typescript-operations'],
|
|
209
|
+
* config: {
|
|
210
|
+
* avoidOptionals: {
|
|
211
|
+
* inputValue: true,
|
|
212
|
+
* },
|
|
213
|
+
* inputMaybeValue: 'T | null'
|
|
214
|
+
* }
|
|
215
|
+
* }
|
|
216
|
+
* }
|
|
217
|
+
* }
|
|
218
|
+
* export default config
|
|
264
219
|
* ```
|
|
265
220
|
*/
|
|
266
|
-
|
|
221
|
+
inputMaybeValue?: string;
|
|
267
222
|
/**
|
|
268
223
|
* @description Adds undefined as a possible type for query variables
|
|
269
224
|
* @default false
|
|
@@ -276,7 +231,7 @@ export interface TypeScriptDocumentsPluginConfig extends RawDocumentsConfig {
|
|
|
276
231
|
* // ...
|
|
277
232
|
* generates: {
|
|
278
233
|
* 'path/to/file.ts': {
|
|
279
|
-
* plugins: ['typescript'],
|
|
234
|
+
* plugins: ['typescript-operations'],
|
|
280
235
|
* config: {
|
|
281
236
|
* allowUndefinedQueryVariables: true
|
|
282
237
|
* },
|
|
@@ -315,7 +270,7 @@ export interface TypeScriptDocumentsPluginConfig extends RawDocumentsConfig {
|
|
|
315
270
|
* // ...
|
|
316
271
|
* generates: {
|
|
317
272
|
* 'path/to/file.ts': {
|
|
318
|
-
* plugins: ['typescript
|
|
273
|
+
* plugins: ['typescript-operations'],
|
|
319
274
|
* config: {
|
|
320
275
|
* nullability: {
|
|
321
276
|
* errorHandlingClient: true
|
|
@@ -330,4 +285,144 @@ export interface TypeScriptDocumentsPluginConfig extends RawDocumentsConfig {
|
|
|
330
285
|
nullability?: {
|
|
331
286
|
errorHandlingClient: boolean;
|
|
332
287
|
};
|
|
288
|
+
/**
|
|
289
|
+
* @description Controls the enum output type. Options: `string-literal` | `native-numeric` | `const` | `native-const` | `native`;
|
|
290
|
+
* @default `string-literal`
|
|
291
|
+
*
|
|
292
|
+
* @exampleMarkdown
|
|
293
|
+
* ```ts filename="codegen.ts"
|
|
294
|
+
* import type { CodegenConfig } from '@graphql-codegen/cli'
|
|
295
|
+
*
|
|
296
|
+
* const config: CodegenConfig = {
|
|
297
|
+
* // ...
|
|
298
|
+
* generates: {
|
|
299
|
+
* 'path/to/file.ts': {
|
|
300
|
+
* plugins: ['typescript-operations'],
|
|
301
|
+
* config: {
|
|
302
|
+
* enumType: 'string-literal',
|
|
303
|
+
* }
|
|
304
|
+
* }
|
|
305
|
+
* }
|
|
306
|
+
* }
|
|
307
|
+
* export default config
|
|
308
|
+
* ```
|
|
309
|
+
*/
|
|
310
|
+
enumType?: ConvertSchemaEnumToDeclarationBlockString['outputType'];
|
|
311
|
+
/**
|
|
312
|
+
* @description Overrides the default value of enum values declared in your GraphQL schema.
|
|
313
|
+
* You can also map the entire enum to an external type by providing a string that of `module#type`.
|
|
314
|
+
*
|
|
315
|
+
* @exampleMarkdown
|
|
316
|
+
* ## With Custom Values
|
|
317
|
+
* ```ts filename="codegen.ts"
|
|
318
|
+
* import type { CodegenConfig } from '@graphql-codegen/cli';
|
|
319
|
+
*
|
|
320
|
+
* const config: CodegenConfig = {
|
|
321
|
+
* // ...
|
|
322
|
+
* generates: {
|
|
323
|
+
* 'path/to/file': {
|
|
324
|
+
* // plugins...
|
|
325
|
+
* config: {
|
|
326
|
+
* enumValues: {
|
|
327
|
+
* MyEnum: {
|
|
328
|
+
* A: 'foo'
|
|
329
|
+
* }
|
|
330
|
+
* }
|
|
331
|
+
* },
|
|
332
|
+
* },
|
|
333
|
+
* },
|
|
334
|
+
* };
|
|
335
|
+
* export default config;
|
|
336
|
+
* ```
|
|
337
|
+
*
|
|
338
|
+
* ## With External Enum
|
|
339
|
+
* ```ts filename="codegen.ts"
|
|
340
|
+
* import type { CodegenConfig } from '@graphql-codegen/cli';
|
|
341
|
+
*
|
|
342
|
+
* const config: CodegenConfig = {
|
|
343
|
+
* // ...
|
|
344
|
+
* generates: {
|
|
345
|
+
* 'path/to/file': {
|
|
346
|
+
* // plugins...
|
|
347
|
+
* config: {
|
|
348
|
+
* enumValues: {
|
|
349
|
+
* MyEnum: './my-file#MyCustomEnum',
|
|
350
|
+
* }
|
|
351
|
+
* },
|
|
352
|
+
* },
|
|
353
|
+
* },
|
|
354
|
+
* };
|
|
355
|
+
* export default config;
|
|
356
|
+
* ```
|
|
357
|
+
*
|
|
358
|
+
* ## Import All Enums from a file
|
|
359
|
+
* ```ts filename="codegen.ts"
|
|
360
|
+
* import type { CodegenConfig } from '@graphql-codegen/cli';
|
|
361
|
+
*
|
|
362
|
+
* const config: CodegenConfig = {
|
|
363
|
+
* // ...
|
|
364
|
+
* generates: {
|
|
365
|
+
* 'path/to/file': {
|
|
366
|
+
* // plugins...
|
|
367
|
+
* config: {
|
|
368
|
+
* enumValues: {
|
|
369
|
+
* MyEnum: './my-file',
|
|
370
|
+
* }
|
|
371
|
+
* },
|
|
372
|
+
* },
|
|
373
|
+
* },
|
|
374
|
+
* };
|
|
375
|
+
* export default config;
|
|
376
|
+
* ```
|
|
377
|
+
*/
|
|
378
|
+
enumValues?: EnumValuesMap;
|
|
379
|
+
/**
|
|
380
|
+
* @description This will cause the generator to ignore enum values defined in GraphQLSchema
|
|
381
|
+
* @default false
|
|
382
|
+
*
|
|
383
|
+
* @exampleMarkdown
|
|
384
|
+
* ## Ignore enum values from schema
|
|
385
|
+
*
|
|
386
|
+
* ```ts filename="codegen.ts"
|
|
387
|
+
* import type { CodegenConfig } from '@graphql-codegen/cli';
|
|
388
|
+
*
|
|
389
|
+
* const config: CodegenConfig = {
|
|
390
|
+
* // ...
|
|
391
|
+
* generates: {
|
|
392
|
+
* 'path/to/file': {
|
|
393
|
+
* // plugins...
|
|
394
|
+
* config: {
|
|
395
|
+
* ignoreEnumValuesFromSchema: true,
|
|
396
|
+
* },
|
|
397
|
+
* },
|
|
398
|
+
* },
|
|
399
|
+
* };
|
|
400
|
+
* export default config;
|
|
401
|
+
* ```
|
|
402
|
+
*/
|
|
403
|
+
ignoreEnumValuesFromSchema?: boolean;
|
|
404
|
+
/**
|
|
405
|
+
* @description This option controls whether or not a catch-all entry is added to enum type definitions for values that may be added in the future.
|
|
406
|
+
* This is useful if you are using `relay`.
|
|
407
|
+
* @default false
|
|
408
|
+
*
|
|
409
|
+
* @exampleMarkdown
|
|
410
|
+
* ```ts filename="codegen.ts"
|
|
411
|
+
* import type { CodegenConfig } from '@graphql-codegen/cli'
|
|
412
|
+
*
|
|
413
|
+
* const config: CodegenConfig = {
|
|
414
|
+
* // ...
|
|
415
|
+
* generates: {
|
|
416
|
+
* 'path/to/file.ts': {
|
|
417
|
+
* plugins: ['typescript-operations'],
|
|
418
|
+
* config: {
|
|
419
|
+
* futureProofEnums: true
|
|
420
|
+
* }
|
|
421
|
+
* }
|
|
422
|
+
* }
|
|
423
|
+
* }
|
|
424
|
+
* export default config
|
|
425
|
+
* ```
|
|
426
|
+
*/
|
|
427
|
+
futureProofEnums?: boolean;
|
|
333
428
|
}
|
package/typings/index.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { PluginFunction, Types } from '@graphql-codegen/plugin-helpers';
|
|
2
2
|
import { TypeScriptDocumentsPluginConfig } from './config.cjs';
|
|
3
3
|
import { TypeScriptDocumentsVisitor } from './visitor.cjs';
|
|
4
|
-
export { TypeScriptDocumentsPluginConfig } from './config.cjs';
|
|
5
4
|
export declare const plugin: PluginFunction<TypeScriptDocumentsPluginConfig, Types.ComplexPluginOutput>;
|
|
6
|
-
export { TypeScriptDocumentsVisitor };
|
|
5
|
+
export { TypeScriptDocumentsVisitor, type TypeScriptDocumentsPluginConfig };
|
package/typings/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { PluginFunction, Types } from '@graphql-codegen/plugin-helpers';
|
|
2
2
|
import { TypeScriptDocumentsPluginConfig } from './config.js';
|
|
3
3
|
import { TypeScriptDocumentsVisitor } from './visitor.js';
|
|
4
|
-
export { TypeScriptDocumentsPluginConfig } from './config.js';
|
|
5
4
|
export declare const plugin: PluginFunction<TypeScriptDocumentsPluginConfig, Types.ComplexPluginOutput>;
|
|
6
|
-
export { TypeScriptDocumentsVisitor };
|
|
5
|
+
export { TypeScriptDocumentsVisitor, type TypeScriptDocumentsPluginConfig };
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { TypeNode } from 'graphql';
|
|
2
|
+
import { ConvertNameFn, NormalizedScalarsMap, OperationVariablesToObject, ParsedEnumValuesMap, type NormalizedOperationAvoidOptionalsConfig } from '@graphql-codegen/visitor-plugin-common';
|
|
3
|
+
export declare class TypeScriptOperationVariablesToObject extends OperationVariablesToObject {
|
|
4
|
+
private _config;
|
|
5
|
+
constructor(_config: {
|
|
6
|
+
avoidOptionals: NormalizedOperationAvoidOptionalsConfig;
|
|
7
|
+
immutableTypes: boolean;
|
|
8
|
+
inputMaybeValue: string;
|
|
9
|
+
}, _scalars: NormalizedScalarsMap, _convertName: ConvertNameFn, _namespacedImportName: string | null, _enumNames: string[], _enumPrefix: boolean, _enumSuffix: boolean, _enumValues: ParsedEnumValuesMap, _applyCoercion: boolean);
|
|
10
|
+
protected formatFieldString(fieldName: string, isNonNullType: boolean, hasDefaultValue: boolean): string;
|
|
3
11
|
protected formatTypeString(fieldType: string, _isNonNullType: boolean, _hasDefaultValue: boolean): string;
|
|
12
|
+
protected clearOptional(str: string): string;
|
|
13
|
+
protected getAvoidOption(isNonNullType: boolean, hasDefaultValue: boolean): boolean;
|
|
14
|
+
protected getScalar(name: string): string;
|
|
15
|
+
protected getPunctuation(): string;
|
|
16
|
+
wrapAstTypeWithModifiers(baseType: string, typeNode: TypeNode, applyCoercion?: boolean): string;
|
|
17
|
+
protected wrapMaybe(type: string): string;
|
|
4
18
|
}
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { TypeNode } from 'graphql';
|
|
2
|
+
import { ConvertNameFn, NormalizedScalarsMap, OperationVariablesToObject, ParsedEnumValuesMap, type NormalizedOperationAvoidOptionalsConfig } from '@graphql-codegen/visitor-plugin-common';
|
|
3
|
+
export declare class TypeScriptOperationVariablesToObject extends OperationVariablesToObject {
|
|
4
|
+
private _config;
|
|
5
|
+
constructor(_config: {
|
|
6
|
+
avoidOptionals: NormalizedOperationAvoidOptionalsConfig;
|
|
7
|
+
immutableTypes: boolean;
|
|
8
|
+
inputMaybeValue: string;
|
|
9
|
+
}, _scalars: NormalizedScalarsMap, _convertName: ConvertNameFn, _namespacedImportName: string | null, _enumNames: string[], _enumPrefix: boolean, _enumSuffix: boolean, _enumValues: ParsedEnumValuesMap, _applyCoercion: boolean);
|
|
10
|
+
protected formatFieldString(fieldName: string, isNonNullType: boolean, hasDefaultValue: boolean): string;
|
|
3
11
|
protected formatTypeString(fieldType: string, _isNonNullType: boolean, _hasDefaultValue: boolean): string;
|
|
12
|
+
protected clearOptional(str: string): string;
|
|
13
|
+
protected getAvoidOption(isNonNullType: boolean, hasDefaultValue: boolean): boolean;
|
|
14
|
+
protected getScalar(name: string): string;
|
|
15
|
+
protected getPunctuation(): string;
|
|
16
|
+
wrapAstTypeWithModifiers(baseType: string, typeNode: TypeNode, applyCoercion?: boolean): string;
|
|
17
|
+
protected wrapMaybe(type: string): string;
|
|
4
18
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseSelectionSetProcessor, LinkField, PrimitiveAliasedFields, PrimitiveField, ProcessResult, SelectionSetProcessorConfig } from '@graphql-codegen/visitor-plugin-common';
|
|
2
1
|
import { GraphQLInterfaceType, GraphQLObjectType } from 'graphql';
|
|
2
|
+
import { BaseSelectionSetProcessor, LinkField, PrimitiveAliasedFields, PrimitiveField, ProcessResult, SelectionSetProcessorConfig } from '@graphql-codegen/visitor-plugin-common';
|
|
3
3
|
export declare class TypeScriptSelectionSetProcessor extends BaseSelectionSetProcessor<SelectionSetProcessorConfig> {
|
|
4
4
|
transformPrimitiveFields(schemaType: GraphQLObjectType | GraphQLInterfaceType, fields: PrimitiveField[], unsetTypes?: boolean): ProcessResult;
|
|
5
5
|
transformTypenameField(type: string, name: string): ProcessResult;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseSelectionSetProcessor, LinkField, PrimitiveAliasedFields, PrimitiveField, ProcessResult, SelectionSetProcessorConfig } from '@graphql-codegen/visitor-plugin-common';
|
|
2
1
|
import { GraphQLInterfaceType, GraphQLObjectType } from 'graphql';
|
|
2
|
+
import { BaseSelectionSetProcessor, LinkField, PrimitiveAliasedFields, PrimitiveField, ProcessResult, SelectionSetProcessorConfig } from '@graphql-codegen/visitor-plugin-common';
|
|
3
3
|
export declare class TypeScriptSelectionSetProcessor extends BaseSelectionSetProcessor<SelectionSetProcessorConfig> {
|
|
4
4
|
transformPrimitiveFields(schemaType: GraphQLObjectType | GraphQLInterfaceType, fields: PrimitiveField[], unsetTypes?: boolean): ProcessResult;
|
|
5
5
|
transformTypenameField(type: string, name: string): ProcessResult;
|
package/typings/visitor.d.cts
CHANGED
|
@@ -1,17 +1,62 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { TypeScriptDocumentsPluginConfig } from './config.cjs';
|
|
1
|
+
import { EnumTypeDefinitionNode, GraphQLEnumType, GraphQLInputObjectType, GraphQLScalarType, InputObjectTypeDefinitionNode, InputValueDefinitionNode, type DocumentNode, type GraphQLSchema, type TypeDefinitionNode } from 'graphql';
|
|
2
|
+
import { BaseDocumentsVisitor, DeclarationKind, ParsedDocumentsConfig, type ConvertSchemaEnumToDeclarationBlockString, type ParsedEnumValuesMap } from '@graphql-codegen/visitor-plugin-common';
|
|
3
|
+
import type { TypeScriptDocumentsPluginConfig } from './config.cjs';
|
|
4
4
|
export interface TypeScriptDocumentsParsedConfig extends ParsedDocumentsConfig {
|
|
5
5
|
arrayInputCoercion: boolean;
|
|
6
|
-
avoidOptionals: NormalizedAvoidOptionalsConfig;
|
|
7
6
|
immutableTypes: boolean;
|
|
8
7
|
noExport: boolean;
|
|
9
8
|
maybeValue: string;
|
|
9
|
+
inputMaybeValue: string;
|
|
10
10
|
allowUndefinedQueryVariables: boolean;
|
|
11
|
+
enumType: ConvertSchemaEnumToDeclarationBlockString['outputType'];
|
|
12
|
+
enumValues: ParsedEnumValuesMap;
|
|
13
|
+
ignoreEnumValuesFromSchema: boolean;
|
|
14
|
+
futureProofEnums: boolean;
|
|
11
15
|
}
|
|
16
|
+
type UsedSchemaTypes = Record<string, {
|
|
17
|
+
type: 'GraphQLScalarType';
|
|
18
|
+
node: GraphQLScalarType;
|
|
19
|
+
tsType: string;
|
|
20
|
+
useCases: {
|
|
21
|
+
input: boolean;
|
|
22
|
+
output: boolean;
|
|
23
|
+
variables: boolean;
|
|
24
|
+
};
|
|
25
|
+
} | {
|
|
26
|
+
type: 'GraphQLEnumType';
|
|
27
|
+
node: GraphQLEnumType;
|
|
28
|
+
tsType: string;
|
|
29
|
+
} | {
|
|
30
|
+
type: 'GraphQLInputObjectType';
|
|
31
|
+
node: GraphQLInputObjectType;
|
|
32
|
+
tsType: string;
|
|
33
|
+
}>;
|
|
12
34
|
export declare class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor<TypeScriptDocumentsPluginConfig, TypeScriptDocumentsParsedConfig> {
|
|
13
|
-
|
|
35
|
+
protected _usedSchemaTypes: UsedSchemaTypes;
|
|
36
|
+
protected _needsExactUtilityType: boolean;
|
|
37
|
+
private _outputPath;
|
|
38
|
+
constructor(schema: GraphQLSchema, config: TypeScriptDocumentsPluginConfig, documentNode: DocumentNode, outputPath: string);
|
|
39
|
+
EnumTypeDefinition(node: EnumTypeDefinitionNode): string | null;
|
|
40
|
+
InputObjectTypeDefinition(node: InputObjectTypeDefinitionNode): string | null;
|
|
41
|
+
InputValueDefinition(node: InputValueDefinitionNode, _key?: number | string, _parent?: any, _path?: Array<string | number>, ancestors?: Array<TypeDefinitionNode>): string;
|
|
14
42
|
getImports(): Array<string>;
|
|
43
|
+
getExternalSchemaTypeImports(): Array<string>;
|
|
44
|
+
getEnumsImports(): string[];
|
|
45
|
+
getScalarsImports(): string[];
|
|
15
46
|
protected getPunctuation(_declarationKind: DeclarationKind): string;
|
|
16
47
|
protected applyVariablesWrapper(variablesBlock: string, operationType: string): string;
|
|
48
|
+
private collectInnerTypesRecursively;
|
|
49
|
+
/**
|
|
50
|
+
* @description collects schema types used in operations:
|
|
51
|
+
* - used Enums for Variables
|
|
52
|
+
* - used Scalars for Variables
|
|
53
|
+
* - used Input for Variables (recursively)
|
|
54
|
+
*
|
|
55
|
+
* - used Enums for Result
|
|
56
|
+
* - used Scalars for Result
|
|
57
|
+
*/
|
|
58
|
+
private collectUsedSchemaTypesToGenerate;
|
|
59
|
+
getExactUtilityType(): string | null;
|
|
60
|
+
getIncrementalUtilityType(): string | null;
|
|
17
61
|
}
|
|
62
|
+
export {};
|
package/typings/visitor.d.ts
CHANGED
|
@@ -1,17 +1,62 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { TypeScriptDocumentsPluginConfig } from './config.js';
|
|
1
|
+
import { EnumTypeDefinitionNode, GraphQLEnumType, GraphQLInputObjectType, GraphQLScalarType, InputObjectTypeDefinitionNode, InputValueDefinitionNode, type DocumentNode, type GraphQLSchema, type TypeDefinitionNode } from 'graphql';
|
|
2
|
+
import { BaseDocumentsVisitor, DeclarationKind, ParsedDocumentsConfig, type ConvertSchemaEnumToDeclarationBlockString, type ParsedEnumValuesMap } from '@graphql-codegen/visitor-plugin-common';
|
|
3
|
+
import type { TypeScriptDocumentsPluginConfig } from './config.js';
|
|
4
4
|
export interface TypeScriptDocumentsParsedConfig extends ParsedDocumentsConfig {
|
|
5
5
|
arrayInputCoercion: boolean;
|
|
6
|
-
avoidOptionals: NormalizedAvoidOptionalsConfig;
|
|
7
6
|
immutableTypes: boolean;
|
|
8
7
|
noExport: boolean;
|
|
9
8
|
maybeValue: string;
|
|
9
|
+
inputMaybeValue: string;
|
|
10
10
|
allowUndefinedQueryVariables: boolean;
|
|
11
|
+
enumType: ConvertSchemaEnumToDeclarationBlockString['outputType'];
|
|
12
|
+
enumValues: ParsedEnumValuesMap;
|
|
13
|
+
ignoreEnumValuesFromSchema: boolean;
|
|
14
|
+
futureProofEnums: boolean;
|
|
11
15
|
}
|
|
16
|
+
type UsedSchemaTypes = Record<string, {
|
|
17
|
+
type: 'GraphQLScalarType';
|
|
18
|
+
node: GraphQLScalarType;
|
|
19
|
+
tsType: string;
|
|
20
|
+
useCases: {
|
|
21
|
+
input: boolean;
|
|
22
|
+
output: boolean;
|
|
23
|
+
variables: boolean;
|
|
24
|
+
};
|
|
25
|
+
} | {
|
|
26
|
+
type: 'GraphQLEnumType';
|
|
27
|
+
node: GraphQLEnumType;
|
|
28
|
+
tsType: string;
|
|
29
|
+
} | {
|
|
30
|
+
type: 'GraphQLInputObjectType';
|
|
31
|
+
node: GraphQLInputObjectType;
|
|
32
|
+
tsType: string;
|
|
33
|
+
}>;
|
|
12
34
|
export declare class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor<TypeScriptDocumentsPluginConfig, TypeScriptDocumentsParsedConfig> {
|
|
13
|
-
|
|
35
|
+
protected _usedSchemaTypes: UsedSchemaTypes;
|
|
36
|
+
protected _needsExactUtilityType: boolean;
|
|
37
|
+
private _outputPath;
|
|
38
|
+
constructor(schema: GraphQLSchema, config: TypeScriptDocumentsPluginConfig, documentNode: DocumentNode, outputPath: string);
|
|
39
|
+
EnumTypeDefinition(node: EnumTypeDefinitionNode): string | null;
|
|
40
|
+
InputObjectTypeDefinition(node: InputObjectTypeDefinitionNode): string | null;
|
|
41
|
+
InputValueDefinition(node: InputValueDefinitionNode, _key?: number | string, _parent?: any, _path?: Array<string | number>, ancestors?: Array<TypeDefinitionNode>): string;
|
|
14
42
|
getImports(): Array<string>;
|
|
43
|
+
getExternalSchemaTypeImports(): Array<string>;
|
|
44
|
+
getEnumsImports(): string[];
|
|
45
|
+
getScalarsImports(): string[];
|
|
15
46
|
protected getPunctuation(_declarationKind: DeclarationKind): string;
|
|
16
47
|
protected applyVariablesWrapper(variablesBlock: string, operationType: string): string;
|
|
48
|
+
private collectInnerTypesRecursively;
|
|
49
|
+
/**
|
|
50
|
+
* @description collects schema types used in operations:
|
|
51
|
+
* - used Enums for Variables
|
|
52
|
+
* - used Scalars for Variables
|
|
53
|
+
* - used Input for Variables (recursively)
|
|
54
|
+
*
|
|
55
|
+
* - used Enums for Result
|
|
56
|
+
* - used Scalars for Result
|
|
57
|
+
*/
|
|
58
|
+
private collectUsedSchemaTypesToGenerate;
|
|
59
|
+
getExactUtilityType(): string | null;
|
|
60
|
+
getIncrementalUtilityType(): string | null;
|
|
17
61
|
}
|
|
62
|
+
export {};
|