@revojs/graphql 0.1.32 → 0.1.34

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.
@@ -0,0 +1,730 @@
1
+ import { Mergeable, Module } from "revojs";
2
+ import { BuildSchemaOptions, DocumentNode, GraphQLSchema } from "graphql";
3
+
4
+ //#region ../../node_modules/@graphql-tools/utils/typings/loaders.d.cts
5
+ interface Source {
6
+ document?: DocumentNode;
7
+ schema?: GraphQLSchema;
8
+ rawSDL?: string;
9
+ location?: string;
10
+ }
11
+ //#endregion
12
+ //#region ../../node_modules/@graphql-tools/utils/typings/errors.d.cts
13
+ declare module 'graphql' {
14
+ interface GraphQLError {
15
+ /**
16
+ * An optional schema coordinate (e.g. "MyType.myField") associated with this error.
17
+ */
18
+ readonly coordinate?: string;
19
+ }
20
+ }
21
+ //#endregion
22
+ //#region ../../node_modules/@graphql-tools/apollo-engine-loader/node_modules/@graphql-tools/utils/typings/Interfaces.d.cts
23
+ interface GraphQLParseOptions {
24
+ noLocation?: boolean;
25
+ allowLegacySDLEmptyFields?: boolean;
26
+ allowLegacySDLImplementsInterfaces?: boolean;
27
+ experimentalFragmentVariables?: boolean;
28
+ /**
29
+ * Set to `true` in order to convert all GraphQL comments (marked with # sign) to descriptions (""")
30
+ * GraphQL has built-in support for transforming descriptions to comments (with `print`), but not while
31
+ * parsing. Turning the flag on will support the other way as well (`parse`)
32
+ */
33
+ commentDescriptions?: boolean;
34
+ }
35
+ //#endregion
36
+ //#region ../../node_modules/@graphql-tools/apollo-engine-loader/node_modules/@graphql-tools/utils/typings/loaders.d.cts
37
+ type BaseLoaderOptions = GraphQLParseOptions & BuildSchemaOptions & {
38
+ cwd?: string;
39
+ ignore?: string | string[];
40
+ includeSources?: boolean;
41
+ };
42
+ //#endregion
43
+ //#region ../../node_modules/@graphql-tools/apollo-engine-loader/node_modules/@graphql-tools/utils/typings/errors.d.cts
44
+ declare module 'graphql' {
45
+ interface GraphQLError {
46
+ /**
47
+ * An optional schema coordinate (e.g. "MyType.myField") associated with this error.
48
+ */
49
+ readonly coordinate?: string;
50
+ }
51
+ }
52
+ //#endregion
53
+ //#region ../../node_modules/@graphql-tools/apollo-engine-loader/typings/index.d.cts
54
+ /**
55
+ * Additional options for loading from Apollo Engine
56
+ */
57
+ interface ApolloEngineOptions extends BaseLoaderOptions {
58
+ engine: {
59
+ endpoint?: string;
60
+ apiKey: string;
61
+ };
62
+ graph: string;
63
+ variant: string;
64
+ headers?: Record<string, string>;
65
+ }
66
+ //#endregion
67
+ //#region ../../node_modules/@graphql-codegen/plugin-helpers/typings/profiler.d.cts
68
+ interface ProfilerEvent {
69
+ /** The name of the event, as displayed in Trace Viewer */
70
+ name: string;
71
+ /** The event categories. This is a comma separated list of categories for the event. The categories can be used to hide events in the Trace Viewer UI. */
72
+ cat: string;
73
+ /** The event type. This is a single character which changes depending on the type of event being output. The valid values are listed in the table below. We will discuss each phase type below. */
74
+ ph: string;
75
+ /** The tracing clock timestamp of the event. The timestamps are provided at microsecond granularity. */
76
+ ts: number;
77
+ /** Optional. The thread clock timestamp of the event. The timestamps are provided at microsecond granularity. */
78
+ tts?: string;
79
+ /** The process ID for the process that output this event. */
80
+ pid: number;
81
+ /** The thread ID for the thread that output this event. */
82
+ tid: number;
83
+ /** Any arguments provided for the event. Some of the event types have required argument fields, otherwise, you can put any information you wish in here. The arguments are displayed in Trace Viewer when you view an event in the analysis section. */
84
+ args?: any;
85
+ /** duration */
86
+ dur: number;
87
+ /** A fixed color name to associate with the event. If provided, cname must be one of the names listed in trace-viewer's base color scheme's reserved color names list */
88
+ cname?: string;
89
+ }
90
+ interface Profiler {
91
+ run<T>(fn: () => Promise<T>, name: string, cat?: string): Promise<T>;
92
+ collect(): ProfilerEvent[];
93
+ }
94
+ //#endregion
95
+ //#region ../../node_modules/@graphql-codegen/plugin-helpers/typings/types.d.cts
96
+ declare namespace Types {
97
+ interface GenerateOptions {
98
+ filename: string;
99
+ plugins: Types.ConfiguredPlugin[];
100
+ schema: DocumentNode;
101
+ schemaAst?: GraphQLSchema;
102
+ documents: Types.DocumentFile[];
103
+ config: {
104
+ [key: string]: any;
105
+ };
106
+ pluginMap: {
107
+ [name: string]: CodegenPlugin;
108
+ };
109
+ skipDocumentsValidation?: Types.SkipDocumentsValidationOptions;
110
+ pluginContext?: {
111
+ [key: string]: any;
112
+ };
113
+ profiler?: Profiler;
114
+ cache?<T>(namespace: string, key: string, factory: () => Promise<T>): Promise<T>;
115
+ documentTransforms?: ConfiguredDocumentTransform[];
116
+ emitLegacyCommonJSImports?: boolean;
117
+ importExtension?: '' | `.${string}`;
118
+ }
119
+ type FileOutput = {
120
+ filename: string;
121
+ content: string;
122
+ hooks?: {
123
+ beforeOneFileWrite?: LifecycleHooksDefinition['beforeOneFileWrite'];
124
+ afterOneFileWrite?: LifecycleHooksDefinition['afterOneFileWrite'];
125
+ };
126
+ };
127
+ interface DocumentFile extends Source {
128
+ hash?: string;
129
+ }
130
+ type Promisable<T> = T | Promise<T>;
131
+ type InstanceOrArray<T> = T | T[];
132
+ /**
133
+ * @additionalProperties false
134
+ * @description Loads schema using a pointer, with a custom loader (code file).
135
+ */
136
+ interface SchemaWithLoaderOptions {
137
+ /**
138
+ * @description Specify a path to a custom code file (local or module) that will handle the schema loading.
139
+ */
140
+ loader: string;
141
+ }
142
+ interface SchemaWithLoader {
143
+ [pointer: string]: SchemaWithLoaderOptions;
144
+ }
145
+ /**
146
+ * @additionalProperties false
147
+ * @description Loads schema using a pointer, without using `require` while looking for schemas in code files.
148
+ */
149
+ interface SchemaFromCodeFileOptions {
150
+ /**
151
+ * @description Set this to `true` in order to tell codegen not to try to `require` files in order to find schema/docs
152
+ */
153
+ noRequire?: boolean;
154
+ /**
155
+ * @description Set this to `true` in order to tell codegen not to try to extract GraphQL AST strings schema/docs
156
+ */
157
+ noPluck?: boolean;
158
+ /**
159
+ * @description Set this to `true` in order to tell codegen to skip documents validation.
160
+ */
161
+ assumeValid?: boolean;
162
+ }
163
+ interface SchemaFromCodeFile {
164
+ [path: string]: SchemaFromCodeFileOptions;
165
+ }
166
+ /**
167
+ * @description A function to use for fetching the schema.
168
+ * @see fetch
169
+ */
170
+ type CustomSchemaFetcher = (url: string, options?: RequestInit) => Promise<Response>;
171
+ /**
172
+ * @additionalProperties false
173
+ * @description Loads a schema from remote endpoint, with custom http options.
174
+ */
175
+ interface UrlSchemaOptions {
176
+ /**
177
+ * @description HTTP headers you wish to add to the HTTP request sent by codegen to fetch your GraphQL remote schema.
178
+ */
179
+ headers?: {
180
+ [headerName: string]: string;
181
+ };
182
+ /**
183
+ * @description Specify a Node module name, a custom file, or a function, to be used instead of a standard `fetch`.
184
+ */
185
+ customFetch?: string | CustomSchemaFetcher;
186
+ /**
187
+ * @description HTTP Method to use, either POST (default) or GET.
188
+ */
189
+ method?: string;
190
+ /**
191
+ * @description Handling the response as SDL will allow you to load schema from remote server that doesn't return a JSON introspection.
192
+ */
193
+ handleAsSDL?: boolean;
194
+ }
195
+ interface UrlSchemaWithOptions {
196
+ [url: string]: UrlSchemaOptions;
197
+ }
198
+ /**
199
+ * @additionalProperties false
200
+ * @description Loads a schema a local file or files, with customized options for parsing/loading.
201
+ */
202
+ interface LocalSchemaPathOptions {
203
+ /**
204
+ * @description Skips checks for graphql-import syntax and loads the file as-is, without imports support.
205
+ * @default true
206
+ */
207
+ skipGraphQLImport?: boolean;
208
+ /**
209
+ * @description Converts all GraphQL comments (`#` sign) to descriptions during the parse phase, to make it available
210
+ * for plugins later.
211
+ * @default false
212
+ */
213
+ commentDescriptions?: boolean;
214
+ /**
215
+ * Set to true to assume the SDL is valid.
216
+ *
217
+ * @default false
218
+ */
219
+ assumeValidSDL?: boolean;
220
+ /**
221
+ * By default, the parser creates AST nodes that know the location
222
+ * in the source that they correspond to. This configuration flag
223
+ * disables that behavior for performance or testing.
224
+ *
225
+ * @default false
226
+ */
227
+ noLocation?: boolean;
228
+ /**
229
+ * If enabled, the parser will parse empty fields sets in the Schema
230
+ * Definition Language. Otherwise, the parser will follow the current
231
+ * specification.
232
+ *
233
+ * This option is provided to ease adoption of the final SDL specification
234
+ * and will be removed in v16.
235
+ *
236
+ * @default false
237
+ */
238
+ allowLegacySDLEmptyFields?: boolean;
239
+ /**
240
+ * If enabled, the parser will parse implemented interfaces with no `&`
241
+ * character between each interface. Otherwise, the parser will follow the
242
+ * current specification.
243
+ *
244
+ * This option is provided to ease adoption of the final SDL specification
245
+ * and will be removed in v16.
246
+ *
247
+ * @default false
248
+ */
249
+ allowLegacySDLImplementsInterfaces?: boolean;
250
+ /**
251
+ * EXPERIMENTAL:
252
+ *
253
+ * If enabled, the parser will understand and parse variable definitions
254
+ * contained in a fragment definition. They'll be represented in the
255
+ * `variableDefinitions` field of the FragmentDefinitionNode.
256
+ *
257
+ * The syntax is identical to normal, query-defined variables. For example:
258
+ *
259
+ * fragment A($var: Boolean = false) on T {
260
+ * ...
261
+ * }
262
+ *
263
+ * Note: this feature is experimental and may change or be removed in the
264
+ * future.
265
+ *
266
+ * @default false
267
+ */
268
+ experimentalFragmentVariables?: boolean;
269
+ }
270
+ interface LocalSchemaPathWithOptions {
271
+ [globPath: string]: LocalSchemaPathOptions;
272
+ }
273
+ interface ApolloEngineSchemaOptions {
274
+ 'apollo-engine': ApolloEngineOptions;
275
+ }
276
+ interface GitHubSchemaOptions {
277
+ [githubProtocol: string]: {
278
+ token: string;
279
+ };
280
+ }
281
+ type SchemaGlobPath = string;
282
+ /**
283
+ * @description A URL to your GraphQL endpoint, a local path to `.graphql` file, a glob pattern to your GraphQL schema files, or a JavaScript file that exports the schema to generate code from. This can also be an array which specifies multiple schemas to generate code from. You can read more about the supported formats [here](schema-field#available-formats).
284
+ */
285
+ type Schema = string | UrlSchemaWithOptions | ApolloEngineSchemaOptions | GitHubSchemaOptions | LocalSchemaPathWithOptions | SchemaGlobPath | SchemaWithLoader | SchemaFromCodeFile;
286
+ type OperationDocumentGlobPath = string;
287
+ /**
288
+ * @additionalProperties false
289
+ * @description Specify a path to a custom loader for your GraphQL documents.
290
+ */
291
+ interface CustomDocumentLoaderOptions {
292
+ /**
293
+ * @description Specify a path to a custom code file (local or module) that will handle the documents loading.
294
+ */
295
+ loader: string;
296
+ }
297
+ interface CustomDocumentLoader {
298
+ [path: string]: CustomDocumentLoaderOptions;
299
+ }
300
+ type OperationDocument = OperationDocumentGlobPath | CustomDocumentLoader;
301
+ type PluginConfig<T = any> = {
302
+ [key: string]: T;
303
+ };
304
+ interface ConfiguredPlugin {
305
+ [name: string]: PluginConfig;
306
+ }
307
+ type NamedPlugin = string;
308
+ type NamedPreset = string;
309
+ type OutputConfig = NamedPlugin | ConfiguredPlugin;
310
+ type PresetNamesBase = 'client' | 'near-operation-file' | 'gql-tag-operations' | 'graphql-modules' | 'import-types';
311
+ type PresetNames = `${PresetNamesBase}-preset` | PresetNamesBase;
312
+ /**
313
+ * @additionalProperties false
314
+ */
315
+ interface ConfiguredOutput {
316
+ /**
317
+ * @type array
318
+ * @items { "$ref": "#/definitions/GeneratedPluginsMap" }
319
+ * @description List of plugins to apply to this current output file.
320
+ *
321
+ * You can either specify plugins from the community using the NPM package name (after you installed it in your project), or you can use a path to a local file for custom plugins.
322
+ *
323
+ * You can find a list of available plugins here: https://the-guild.dev/graphql/codegen/docs/plugins/index
324
+ * Need a custom plugin? read this: https://the-guild.dev/graphql/codegen/docs/custom-codegen/index
325
+ */
326
+ plugins?: OutputConfig[];
327
+ /**
328
+ * @description If your setup uses Preset to have a more dynamic setup and output, set the name of your preset here.
329
+ *
330
+ * Presets are a way to have more than one file output, for example: https://the-guild.dev/graphql/codegen/docs/presets/near-operation-file
331
+ *
332
+ * You can either specify a preset from the community using the NPM package name (after you installed it in your project), or you can use a path to a local file for a custom preset.
333
+ *
334
+ * List of available presets: https://graphql-code-generator.com/docs/presets/presets-index
335
+ */
336
+ preset?: PresetNames | OutputPreset;
337
+ /**
338
+ * @description If your setup uses Preset to have a more dynamic setup and output, set the configuration object of your preset here.
339
+ *
340
+ * List of available presets: https://graphql-code-generator.com/docs/presets/presets-index
341
+ */
342
+ presetConfig?: {
343
+ [key: string]: any;
344
+ };
345
+ /**
346
+ * @description A flag to overwrite files if they already exist when generating code (`true` by default).
347
+ *
348
+ * For more details: https://graphql-code-generator.com/docs/config-reference/codegen-config
349
+ */
350
+ overwrite?: boolean;
351
+ /**
352
+ * @description A pointer(s) to your GraphQL documents: query, mutation, subscription and fragment. These documents will be loaded into for all your output files.
353
+ * You can use one of the following:
354
+ *
355
+ * - Path to a local `.graphql` file
356
+ * - Path to a code file (for example: `.js` or `.tsx`) containing GraphQL operation strings.
357
+ * - Glob expression pointing to multiple `.graphql` files
358
+ * - Glob expression pointing to multiple code files
359
+ * - Inline string containing GraphQL SDL operation definition
360
+ *
361
+ * You can specify either a single file, or multiple.
362
+ *
363
+ * For more details: https://graphql-code-generator.com/docs/config-reference/documents-field
364
+ */
365
+ documents?: InstanceOrArray<OperationDocument>;
366
+ /**
367
+ * @description A pointer(s) to your GraphQL schema. This schema will be available only for this specific `generates` record.
368
+ * You can use one of the following:
369
+ *
370
+ * - URL pointing to a GraphQL endpoint
371
+ * - Path to a local `.json` file
372
+ * - Path to a local `.graphql` file
373
+ * - Glob expression pointing to multiple `.graphql` files
374
+ * - Path to a local code file (for example: `.js`) that exports `GraphQLSchema` object
375
+ * - Inline string containing GraphQL SDL schema definition
376
+ *
377
+ * You can specify either a single schema, or multiple, and GraphQL Code Generator will merge the schemas into a single schema.
378
+ *
379
+ * For more details: https://graphql-code-generator.com/docs/config-reference/schema-field
380
+ */
381
+ schema?: InstanceOrArray<Schema>;
382
+ /**
383
+ * @description Configuration object containing key => value that will be passed to the plugins.
384
+ * Specifying configuration in this level of your configuration file will pass it to all plugins, in all outputs.
385
+ *
386
+ * The options may vary depends on what plugins you are using.
387
+ *
388
+ * For more details: https://graphql-code-generator.com/docs/config-reference/config-field
389
+ */
390
+ config?: PluginConfig;
391
+ /**
392
+ * @description Specifies scripts to run when events are happening in the codegen core.
393
+ * Hooks defined on that level will effect only the current output files.
394
+ *
395
+ * For more details: https://graphql-code-generator.com/docs/config-reference/lifecycle-hooks
396
+ */
397
+ hooks?: Partial<LifecycleHooksDefinition>;
398
+ /**
399
+ * @description DocumentTransform changes documents before executing plugins.
400
+ */
401
+ documentTransforms?: OutputDocumentTransform[];
402
+ /**
403
+ * @description: Additional file pattern to watch when using watch mode
404
+ */
405
+ watchPattern?: string | string[];
406
+ }
407
+ type PresetFnArgs<Config = any, PluginConfig = {
408
+ [key: string]: any;
409
+ }> = {
410
+ presetConfig: Config;
411
+ baseOutputDir: string;
412
+ plugins: Types.ConfiguredPlugin[];
413
+ schema: DocumentNode;
414
+ schemaAst?: GraphQLSchema;
415
+ documents: Types.DocumentFile[];
416
+ config: PluginConfig;
417
+ pluginMap: {
418
+ [name: string]: CodegenPlugin;
419
+ };
420
+ pluginContext?: {
421
+ [name: string]: any;
422
+ };
423
+ profiler?: Profiler;
424
+ cache?<T>(namespace: string, key: string, factory: () => Promise<T>): Promise<T>;
425
+ documentTransforms?: ConfiguredDocumentTransform[];
426
+ };
427
+ type OutputPreset<TPresetConfig = any> = {
428
+ buildGeneratesSection: (options: PresetFnArgs<TPresetConfig>) => Promisable<GenerateOptions[]>;
429
+ prepareDocuments?: (outputFilePath: string, outputSpecificDocuments: Types.OperationDocument[]) => Promisable<Types.OperationDocument[]>;
430
+ };
431
+ type RequireExtension = InstanceOrArray<string>;
432
+ type PackageLoaderFn<TExpectedResult> = (name: string) => Promisable<TExpectedResult>;
433
+ /**
434
+ * @description Represents the root YAML schema for the config file.
435
+ * @additionalProperties false
436
+ */
437
+ interface Config {
438
+ /**
439
+ * @description A pointer(s) to your GraphQL schema. This schema will be the base schema for all your outputs.
440
+ * You can use one of the following:
441
+ *
442
+ * - URL pointing to a GraphQL endpoint
443
+ * - Path to a local `.json` file
444
+ * - Path to a local `.graphql` file
445
+ * - Glob expression pointing to multiple `.graphql` files
446
+ * - Path to a local code file (for example: `.js`) that exports `GraphQLSchema` object
447
+ * - Inline string containing GraphQL SDL schema definition
448
+ *
449
+ * You can specify either a single schema, or multiple, and GraphQL Code Generator will merge the schemas into a single schema.
450
+ *
451
+ * For more details: https://graphql-code-generator.com/docs/config-reference/schema-field
452
+ */
453
+ schema?: InstanceOrArray<Schema>;
454
+ /**
455
+ * @description A path to a file which defines custom Node.JS require() handlers for custom file extensions.
456
+ * This is essential if the code generator has to go through files which require other files in an unsupported format (by default).
457
+ *
458
+ * For more details: https://graphql-code-generator.com/docs/config-reference/require-field
459
+ * See more information about require.extensions: https://gist.github.com/jamestalmage/df922691475cff66c7e6.
460
+ *
461
+ * Note: values that specified in your .yml file will get loaded after loading the config .yml file.
462
+ */
463
+ require?: RequireExtension;
464
+ /**
465
+ * @description Specify a Node module name, a custom file, or a function, to be used instead of a standard `fetch`.
466
+ */
467
+ customFetch?: string | CustomSchemaFetcher;
468
+ /**
469
+ * @description A pointer(s) to your GraphQL documents: query, mutation, subscription and fragment. These documents will be loaded into for all your output files.
470
+ * You can use one of the following:
471
+ *
472
+ * - Path to a local `.graphql` file
473
+ * - Path to a code file (for example: `.js` or `.tsx`) containing GraphQL operation strings.
474
+ * - Glob expression pointing to multiple `.graphql` files
475
+ * - Glob expression pointing to multiple code files
476
+ * - Inline string containing GraphQL SDL operation definition
477
+ *
478
+ * You can specify either a single file, or multiple.
479
+ *
480
+ * For more details: https://graphql-code-generator.com/docs/config-reference/documents-field
481
+ */
482
+ documents?: InstanceOrArray<OperationDocument>;
483
+ /**
484
+ * @type object
485
+ * @additionalProperties true
486
+ * @description Configuration object containing key => value that will be passed to the plugins.
487
+ * Specifying configuration in this level of your configuration file will pass it to all plugins, in all outputs.
488
+ *
489
+ * The options may vary depends on what plugins you are using.
490
+ *
491
+ * For more details: https://graphql-code-generator.com/docs/config-reference/config-field
492
+ */
493
+ config?: PluginConfig;
494
+ /**
495
+ * @description A map where the key represents an output path for the generated code and the value represents a set of options which are relevant for that specific file.
496
+ *
497
+ * For more details: https://graphql-code-generator.com/docs/config-reference/codegen-config
498
+ */
499
+ generates: {
500
+ [outputPath: string]: ConfiguredOutput | ConfiguredPlugin[];
501
+ };
502
+ /**
503
+ * @description A flag to overwrite files if they already exist when generating code (`true` by default).
504
+ *
505
+ * For more details: https://graphql-code-generator.com/docs/config-reference/codegen-config
506
+ */
507
+ overwrite?: boolean;
508
+ /**
509
+ * @description A flag to trigger codegen when there are changes in the specified GraphQL schemas.
510
+ *
511
+ * You can either specify a boolean to turn it on/off or specify an array of glob patterns to add custom files to the watch.
512
+ *
513
+ * For more details: https://graphql-code-generator.com/docs/getting-started/development-workflow#watch-mode
514
+ */
515
+ watch?: boolean | string | string[];
516
+ /**
517
+ * @description A flag to suppress non-zero exit code when there are no documents to generate.
518
+ */
519
+ ignoreNoDocuments?: boolean;
520
+ /**
521
+ * @deprecated Please use `importExtension` instead.
522
+ * @description A flag to disable adding `.js` extension to the output file. Default: `true`.
523
+ */
524
+ emitLegacyCommonJSImports?: boolean;
525
+ /**
526
+ * @description Append this extension to all imports.
527
+ * Useful for ESM environments that require file extensions in import statements.
528
+ */
529
+ importExtension?: '' | `.${string}`;
530
+ /**
531
+ * @description A flag to suppress printing errors when they occur.
532
+ */
533
+ silent?: boolean;
534
+ /**
535
+ * @description A flag to output more detailed information about tasks
536
+ */
537
+ verbose?: boolean;
538
+ /**
539
+ * @description A flag to output debug logs
540
+ */
541
+ debug?: boolean;
542
+ /**
543
+ * @description A flag to print only errors.
544
+ */
545
+ errorsOnly?: boolean;
546
+ /**
547
+ * @description If you are using the programmatic API in a browser environment, you can override this configuration to load your plugins in a way different than require.
548
+ */
549
+ pluginLoader?: PackageLoaderFn<CodegenPlugin>;
550
+ /**
551
+ * @description Additional context passed to plugins
552
+ */
553
+ pluginContext?: {
554
+ [key: string]: any;
555
+ };
556
+ /**
557
+ * @description Allows you to override the configuration for `@graphql-tools/graphql-tag-pluck`, the tool that extracts your GraphQL operations from your code files.
558
+ *
559
+ * For more details: https://graphql-code-generator.com/docs/config-reference/documents-field#graphql-tag-pluck
560
+ */
561
+ pluckConfig?: {
562
+ /**
563
+ * @description An array of package name and identifier that will be used to track down your gql usages and imports. Use this if your code files imports gql from another library or you have a custom gql tag. identifier is the named export, so don't provide it if the tag function is imported as default.
564
+ */
565
+ modules?: Array<{
566
+ /**
567
+ * @description the name of the NPM package name you wish to look for
568
+ */
569
+ name: string;
570
+ /**
571
+ * @description the tag identifier name you wish to look for
572
+ */
573
+ identifier?: string;
574
+ }>;
575
+ /**
576
+ * @description Configures the magic GraphQL comments to look for. The default is `GraphQL`.
577
+ */
578
+ gqlMagicComment?: string;
579
+ /**
580
+ * @description Overrides the name of the default GraphQL name identifier.
581
+ */
582
+ globalIdentifier?: string;
583
+ /**
584
+ * @description Allows to use a global identifier instead of a module import.
585
+ */
586
+ globalGqlIdentifierName?: string | string[];
587
+ };
588
+ /**
589
+ * @description Specifies scripts to run when events are happening in the codegen core.
590
+ * Hooks defined on that level will effect all output files.
591
+ *
592
+ * For more details: https://graphql-code-generator.com/docs/config-reference/lifecycle-hooks
593
+ */
594
+ hooks?: Partial<LifecycleHooksDefinition>;
595
+ /**
596
+ * @description Alows to raise errors if any matched files are not valid GraphQL. Default: false.
597
+ */
598
+ noSilentErrors?: boolean;
599
+ /**
600
+ * @description If `true`, write to files whichever `generates` block succeeds. If `false`, one failed `generates` means no output is written to files. Default: false
601
+ */
602
+ allowPartialOutputs?: boolean;
603
+ }
604
+ type ComplexPluginOutput<M = Record<string, unknown>> = {
605
+ content: string;
606
+ prepend?: string[];
607
+ append?: string[];
608
+ meta?: M;
609
+ };
610
+ type PluginOutput = string | ComplexPluginOutput;
611
+ type HookFunction = (...args: any[]) => void | Promise<void>;
612
+ type HookAlterFunction = (...args: any[]) => void | string | Promise<void | string>;
613
+ type LifeCycleHookValue = string | HookFunction | (string | HookFunction)[];
614
+ type LifeCycleAlterHookValue = string | HookFunction | HookAlterFunction | (string | HookFunction | HookAlterFunction)[];
615
+ /**
616
+ * @description All available lifecycle hooks
617
+ * @additionalProperties false
618
+ */
619
+ type LifecycleHooksDefinition = {
620
+ /**
621
+ * @description Triggered with no arguments when the codegen starts (after the `codegen.yml` has beed parsed).
622
+ *
623
+ * Specify a shell command to run.
624
+ */
625
+ afterStart: LifeCycleHookValue;
626
+ /**
627
+ * @description Triggered with no arguments, right before the codegen closes, or when watch mode is stopped.
628
+ *
629
+ * Specify a shell command to run.
630
+ */
631
+ beforeDone: LifeCycleHookValue;
632
+ /**
633
+ * @description Triggered every time a file changes when using watch mode.
634
+ * Triggered with two arguments: the type of the event (for example, `changed`) and the path of the file.
635
+ */
636
+ onWatchTriggered: LifeCycleHookValue;
637
+ /**
638
+ * @description Triggered in case of a general error in the codegen. The argument is a string containing the error.
639
+ */
640
+ onError: LifeCycleHookValue;
641
+ /**
642
+ * @description Triggered after a file is written to the file-system. Executed with the path for the file.
643
+ * If the content of the file hasn't changed since last execution - this hooks won't be triggered.
644
+ *
645
+ * > This is a very useful hook, you can use it for integration with Prettier or other linters.
646
+ */
647
+ afterOneFileWrite: LifeCycleHookValue;
648
+ /**
649
+ * @description Executed after writing all the files to the file-system.
650
+ * Triggered with multiple arguments - paths for all files.
651
+ */
652
+ afterAllFileWrite: LifeCycleHookValue;
653
+ /**
654
+ * @description Triggered before a file is written to the file-system.
655
+ * Executed with the path and content for the file.
656
+ *
657
+ * Returning a string will override the content of the file.
658
+ *
659
+ * If the content of the file hasn't changed since last execution - this hooks won't be triggered.
660
+ */
661
+ beforeOneFileWrite: LifeCycleAlterHookValue;
662
+ /**
663
+ * @description Executed after the codegen has done creating the output and before writing the files to the file-system.
664
+ *
665
+ * Triggered with multiple arguments - paths for all relevant files.
666
+ *
667
+ * > Not all the files will be actually written to the file-system, because this is triggered before checking if the file has changed since last execution.
668
+ */
669
+ beforeAllFileWrite: LifeCycleHookValue;
670
+ };
671
+ type SkipDocumentsValidationOptions = {
672
+ /**
673
+ * @description Allows you to skip specific rules while validating the documents.
674
+ * See all the rules; https://github.com/graphql/graphql-js/tree/main/src/validation/rules
675
+ */
676
+ ignoreRules?: string[];
677
+ /**
678
+ * @description Ignore duplicate documents validation
679
+ */
680
+ skipDuplicateValidation?: boolean;
681
+ /**
682
+ * @description Skip document validation entirely against the schema
683
+ */
684
+ skipValidationAgainstSchema?: boolean;
685
+ } | boolean;
686
+ type DocumentTransformFunction<Config = object> = (options: {
687
+ documents: Types.DocumentFile[];
688
+ schema: DocumentNode;
689
+ config: Config;
690
+ pluginContext?: {
691
+ [key: string]: any;
692
+ };
693
+ }) => Types.Promisable<Types.DocumentFile[]>;
694
+ type DocumentTransformObject<T = object> = {
695
+ transform: DocumentTransformFunction<T>;
696
+ };
697
+ type DocumentTransformFileName = string;
698
+ type DocumentTransformFileConfig<T = object> = {
699
+ [name: DocumentTransformFileName]: T;
700
+ };
701
+ type DocumentTransformFile<T> = DocumentTransformFileName | DocumentTransformFileConfig<T>;
702
+ type OutputDocumentTransform<T = object> = DocumentTransformObject<T> | DocumentTransformFile<T>;
703
+ type ConfiguredDocumentTransform<T = object> = {
704
+ name: string;
705
+ transformObject: DocumentTransformObject<T>;
706
+ config?: T;
707
+ };
708
+ }
709
+ type PluginFunction<T = any, TOutput extends Types.PluginOutput = Types.PluginOutput> = (schema: GraphQLSchema, documents: Types.DocumentFile[], config: T, info?: {
710
+ outputFile?: string;
711
+ allPlugins?: Types.ConfiguredPlugin[];
712
+ pluginContext?: {
713
+ [key: string]: any;
714
+ };
715
+ [key: string]: any;
716
+ }) => Types.Promisable<TOutput>;
717
+ type PluginValidateFn<T = any> = (schema: GraphQLSchema, documents: Types.DocumentFile[], config: T, outputFile: string, allPlugins: Types.ConfiguredPlugin[], pluginContext?: {
718
+ [key: string]: any;
719
+ }) => Types.Promisable<void>;
720
+ type AddToSchemaResult = string | DocumentNode | undefined;
721
+ interface CodegenPlugin<T = any> {
722
+ plugin: PluginFunction<T>;
723
+ addToSchema?: AddToSchemaResult | ((config: T) => AddToSchemaResult);
724
+ validate?: PluginValidateFn;
725
+ }
726
+ //#endregion
727
+ //#region src/index.d.ts
728
+ declare function graphql(config: Mergeable<Types.Config>): Module;
729
+ //#endregion
730
+ export { graphql };
@@ -1,12 +1,11 @@
1
1
  import { generate } from "@graphql-codegen/cli";
2
- import { DocumentMode } from "@graphql-codegen/visitor-plugin-common";
3
2
  import { mergeObjects } from "revojs";
4
- import { addTemplate } from "revojs/kit";
3
+ import { addTypes, addVirtual } from "revojs/kit";
5
4
 
6
5
  //#region src/index.ts
7
6
  function graphql(config) {
8
7
  return { async setup(app) {
9
- const output = await generate(mergeObjects({
8
+ const content = (await generate(mergeObjects({
10
9
  documents: "./graphql/**/*.{gql,graphql}",
11
10
  generates: { "./graphql/index.ts": {
12
11
  plugins: [
@@ -16,12 +15,12 @@ function graphql(config) {
16
15
  ],
17
16
  config: {
18
17
  maybeValue: "T | undefined",
19
- useTypeImports: true,
20
- documentMode: DocumentMode.string
18
+ useTypeImports: true
21
19
  }
22
20
  } }
23
- }, config), false);
24
- addTemplate(app, "graphql.ts", () => output.at(0)?.content ?? "");
21
+ }, config), false)).at(0)?.content ?? "";
22
+ addVirtual(app, "graphql", () => content);
23
+ addTypes(app, "graphql", () => `declare module "#virtual/graphql" { ${content} }`);
25
24
  } };
26
25
  }
27
26
 
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@revojs/graphql",
3
- "version": "0.1.32",
3
+ "version": "0.1.34",
4
4
  "type": "module",
5
5
  "repository": "coverbase/revojs",
6
6
  "license": "MIT",
7
7
  "exports": {
8
8
  ".": {
9
- "types": "./dist/index.d.ts",
10
- "import": "./dist/index.js"
9
+ "types": "./dist/index.d.mts",
10
+ "import": "./dist/index.mjs"
11
11
  }
12
12
  },
13
- "types": "./dist/index.d.ts",
14
- "module": "./dist/index.js",
15
- "main": "./dist/index.js",
13
+ "types": "./dist/index.d.mts",
14
+ "module": "./dist/index.mjs",
15
+ "main": "./dist/index.mjs",
16
16
  "files": [
17
17
  "dist"
18
18
  ],
@@ -24,12 +24,11 @@
24
24
  "@graphql-codegen/cli": "^6.1.1",
25
25
  "@graphql-codegen/typescript": "^5.0.7",
26
26
  "@graphql-codegen/typescript-operations": "^5.0.7",
27
- "@graphql-codegen/visitor-plugin-common": "^6.2.2",
28
27
  "graphql": "^16.12.0",
29
28
  "revojs": "*"
30
29
  },
31
30
  "devDependencies": {
32
31
  "@revojs/tsconfig": "*",
33
- "tsdown": "^0.15.1"
32
+ "tsdown": "^0.20.3"
34
33
  }
35
34
  }
package/dist/index.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import { Mergeable, Module } from "revojs";
2
- import { Types } from "@graphql-codegen/plugin-helpers";
3
-
4
- //#region src/index.d.ts
5
- declare function graphql(config: Mergeable<Types.Config>): Module;
6
- //#endregion
7
- export { graphql };