1 | import { NormalizedScalarsMap } from './types.js';
|
2 | import { DeclarationBlockConfig } from './utils.js';
|
3 | import { GraphQLSchema, FragmentDefinitionNode, OperationDefinitionNode } from 'graphql';
|
4 | import { SelectionSetToObject } from './selection-set-to-object.js';
|
5 | import { OperationVariablesToObject } from './variables-to-object.js';
|
6 | import { BaseVisitor } from './base-visitor.js';
|
7 | import { ParsedTypesConfig, RawTypesConfig } from './base-types-visitor.js';
|
8 | export interface ParsedDocumentsConfig extends ParsedTypesConfig {
|
9 | addTypename: boolean;
|
10 | preResolveTypes: boolean;
|
11 | globalNamespace: boolean;
|
12 | operationResultSuffix: string;
|
13 | dedupeOperationSuffix: boolean;
|
14 | omitOperationSuffix: boolean;
|
15 | namespacedImportName: string | null;
|
16 | exportFragmentSpreadSubTypes: boolean;
|
17 | skipTypeNameForRoot: boolean;
|
18 | experimentalFragmentVariables: boolean;
|
19 | mergeFragmentTypes: boolean;
|
20 | }
|
21 | export interface RawDocumentsConfig extends RawTypesConfig {
|
22 | /**
|
23 | * @default true
|
24 | * @description Uses primitive types where possible.
|
25 | * Set to `false` in order to use `Pick` and take use the types generated by `typescript` plugin.
|
26 | *
|
27 | * @exampleMarkdown
|
28 | * ```ts filename="codegen.ts"
|
29 | * import type { CodegenConfig } from '@graphql-codegen/cli';
|
30 | *
|
31 | * const config: CodegenConfig = {
|
32 | * // ...
|
33 | * generates: {
|
34 | * 'path/to/file': {
|
35 | * // plugins...
|
36 | * config: {
|
37 | * preResolveTypes: false
|
38 | * },
|
39 | * },
|
40 | * },
|
41 | * };
|
42 | * export default config;
|
43 | * ```
|
44 | */
|
45 | preResolveTypes?: boolean;
|
46 | /**
|
47 | * @default false
|
48 | * @description Avoid adding `__typename` for root types. This is ignored when a selection explicitly specifies `__typename`.
|
49 | *
|
50 | * @exampleMarkdown
|
51 | * ```ts filename="codegen.ts"
|
52 | * import type { CodegenConfig } from '@graphql-codegen/cli';
|
53 | *
|
54 | * const config: CodegenConfig = {
|
55 | * // ...
|
56 | * generates: {
|
57 | * 'path/to/file': {
|
58 | * // plugins...
|
59 | * config: {
|
60 | * skipTypeNameForRoot: true
|
61 | * },
|
62 | * },
|
63 | * },
|
64 | * };
|
65 | * export default config;
|
66 | * ```
|
67 | */
|
68 | skipTypeNameForRoot?: boolean;
|
69 | /**
|
70 | * @default false
|
71 | * @description Puts all generated code under `global` namespace. Useful for Stencil integration.
|
72 | *
|
73 | * @exampleMarkdown
|
74 | * ```ts filename="codegen.ts"
|
75 | * import type { CodegenConfig } from '@graphql-codegen/cli';
|
76 | *
|
77 | * const config: CodegenConfig = {
|
78 | * // ...
|
79 | * generates: {
|
80 | * 'path/to/file': {
|
81 | * // plugins...
|
82 | * config: {
|
83 | * globalNamespace: true
|
84 | * },
|
85 | * },
|
86 | * },
|
87 | * };
|
88 | * export default config;
|
89 | * ```
|
90 | */
|
91 | globalNamespace?: boolean;
|
92 | /**
|
93 | * @default ""
|
94 | * @description Adds a suffix to generated operation result type names
|
95 | */
|
96 | operationResultSuffix?: string;
|
97 | /**
|
98 | * @default false
|
99 | * @description Set this configuration to `true` if you wish to make sure to remove duplicate operation name suffix.
|
100 | */
|
101 | dedupeOperationSuffix?: boolean;
|
102 | /**
|
103 | * @default false
|
104 | * @description Set this configuration to `true` if you wish to disable auto add suffix of operation name, like `Query`, `Mutation`, `Subscription`, `Fragment`.
|
105 | */
|
106 | omitOperationSuffix?: boolean;
|
107 | /**
|
108 | * @default false
|
109 | * @description If set to true, it will export the sub-types created in order to make it easier to access fields declared under fragment spread.
|
110 | */
|
111 | exportFragmentSpreadSubTypes?: boolean;
|
112 | /**
|
113 | * @default false
|
114 | * @description If set to true, it will enable support for parsing variables on fragments.
|
115 | */
|
116 | experimentalFragmentVariables?: boolean;
|
117 | /**
|
118 | * @default false
|
119 | * @description If set to true, merge equal fragment interfaces.
|
120 | */
|
121 | mergeFragmentTypes?: boolean;
|
122 | /**
|
123 | * @ignore
|
124 | */
|
125 | namespacedImportName?: string;
|
126 | }
|
127 | export declare class BaseDocumentsVisitor<TRawConfig extends RawDocumentsConfig = RawDocumentsConfig, TPluginConfig extends ParsedDocumentsConfig = ParsedDocumentsConfig> extends BaseVisitor<TRawConfig, TPluginConfig> {
|
128 | protected _schema: GraphQLSchema;
|
129 | protected _unnamedCounter: number;
|
130 | protected _variablesTransfomer: OperationVariablesToObject;
|
131 | protected _selectionSetToObject: SelectionSetToObject;
|
132 | protected _globalDeclarations: Set<string>;
|
133 | constructor(rawConfig: TRawConfig, additionalConfig: TPluginConfig, _schema: GraphQLSchema, defaultScalars?: NormalizedScalarsMap);
|
134 | getGlobalDeclarations(noExport?: boolean): string[];
|
135 | setSelectionSetHandler(handler: SelectionSetToObject): void;
|
136 | setDeclarationBlockConfig(config: DeclarationBlockConfig): void;
|
137 | setVariablesTransformer(variablesTransfomer: OperationVariablesToObject): void;
|
138 | get schema(): GraphQLSchema;
|
139 | get addTypename(): boolean;
|
140 | private handleAnonymousOperation;
|
141 | FragmentDefinition(node: FragmentDefinitionNode): string;
|
142 | protected applyVariablesWrapper(variablesBlock: string): string;
|
143 | OperationDefinition(node: OperationDefinitionNode): string;
|
144 | }
|