Skip to content

Commit 526f3d7

Browse files
committed
Remove deprecated config options for next major version (#10408)
* Remove deprecated config - watchConfig - dedupeFragments - noGraphQLTag * Add changesets * Regen website schema
1 parent 86c4039 commit 526f3d7

File tree

11 files changed

+23
-106
lines changed

11 files changed

+23
-106
lines changed

.changeset/brave-days-heal.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-codegen/plugin-helpers': major
3+
---
4+
5+
Remove deprecated option `watchConfig`

.changeset/kind-donkeys-retire.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-codegen/visitor-plugin-common': major
3+
---
4+
5+
Remove deprecated config option `dedupeFragments`

.changeset/tame-lizards-speak.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-codegen/client-preset': major
3+
---
4+
5+
Stop passing through the deprecated config option `dedupeFragments`

packages/plugins/other/visitor-plugin-common/src/base-visitor.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export interface ParsedConfig {
3333
fragmentImports: ImportDeclaration<FragmentImport>[];
3434
immutableTypes: boolean;
3535
useTypeImports: boolean;
36-
dedupeFragments: boolean;
3736
allowEnumStringTypes: boolean;
3837
inlineFragmentTypes: InlineFragmentTypeOptions;
3938
emitLegacyCommonJSImports: boolean;
@@ -346,15 +345,6 @@ export interface RawConfig {
346345
* @ignore
347346
*/
348347
globalNamespace?: boolean;
349-
/**
350-
* @description Removes fragment duplicates for reducing data transfer.
351-
* It is done by removing sub-fragments imports from fragment definition
352-
* Instead - all of them are imported to the Operation node.
353-
* @type boolean
354-
* @default false
355-
* @deprecated This option is no longer needed. It will be removed in the next major version.
356-
*/
357-
dedupeFragments?: boolean;
358348
/**
359349
* @ignore
360350
*/
@@ -416,7 +406,6 @@ export class BaseVisitor<TRawConfig extends RawConfig = RawConfig, TPluginConfig
416406
addTypename: !rawConfig.skipTypename,
417407
nonOptionalTypename: !!rawConfig.nonOptionalTypename,
418408
useTypeImports: !!rawConfig.useTypeImports,
419-
dedupeFragments: !!rawConfig.dedupeFragments,
420409
allowEnumStringTypes: !!rawConfig.allowEnumStringTypes,
421410
inlineFragmentTypes: rawConfig.inlineFragmentTypes ?? 'inline',
422411
emitLegacyCommonJSImports:

packages/plugins/other/visitor-plugin-common/src/client-side-base-visitor.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ export enum DocumentMode {
3535
const EXTENSIONS_TO_REMOVE = ['.ts', '.tsx', '.js', '.jsx'];
3636

3737
export interface RawClientSideBasePluginConfig extends RawConfig {
38-
/**
39-
* @description Deprecated. Changes the documentMode to `documentNode`.
40-
* @default false
41-
*/
42-
noGraphQLTag?: boolean;
4338
/**
4439
* @default graphql-tag#gql
4540
* @description Customize from which module will `gql` be imported from.
@@ -275,12 +270,7 @@ export class ClientSideBaseVisitor<
275270
documentVariableSuffix: getConfigValue(rawConfig.documentVariableSuffix, 'Document'),
276271
fragmentVariablePrefix: getConfigValue(rawConfig.fragmentVariablePrefix, ''),
277272
fragmentVariableSuffix: getConfigValue(rawConfig.fragmentVariableSuffix, 'FragmentDoc'),
278-
documentMode: ((rawConfig: RawClientSideBasePluginConfig) => {
279-
if (typeof rawConfig.noGraphQLTag === 'boolean') {
280-
return rawConfig.noGraphQLTag ? DocumentMode.documentNode : DocumentMode.graphQLTag;
281-
}
282-
return getConfigValue(rawConfig.documentMode, DocumentMode.graphQLTag);
283-
})(rawConfig),
273+
documentMode: getConfigValue(rawConfig.documentMode, DocumentMode.graphQLTag),
284274
importDocumentNodeExternallyFrom: getConfigValue(rawConfig.importDocumentNodeExternallyFrom, ''),
285275
pureMagicComment: getConfigValue(rawConfig.pureMagicComment, false),
286276
experimentalFragmentVariables: getConfigValue(rawConfig.experimentalFragmentVariables, false),
@@ -333,7 +323,7 @@ export class ClientSideBaseVisitor<
333323
return fragmentNames.map(document => this.getFragmentVariableName(document));
334324
}
335325

336-
protected _includeFragments(fragments: string[], nodeKind: 'FragmentDefinition' | 'OperationDefinition'): string {
326+
protected _includeFragments(fragments: string[]): string {
337327
if (fragments && fragments.length > 0) {
338328
if (this.config.documentMode === DocumentMode.documentNode || this.config.documentMode === DocumentMode.string) {
339329
return Array.from(this._fragments.values())
@@ -344,9 +334,6 @@ export class ClientSideBaseVisitor<
344334
if (this.config.documentMode === DocumentMode.documentNodeImportFragments) {
345335
return '';
346336
}
347-
if (this.config.dedupeFragments && nodeKind !== 'OperationDefinition') {
348-
return '';
349-
}
350337
return String(fragments.map(name => '${' + name + '}').join('\n'));
351338
}
352339

@@ -359,15 +346,13 @@ export class ClientSideBaseVisitor<
359346

360347
protected _gql(node: FragmentDefinitionNode | OperationDefinitionNode): string {
361348
const includeNestedFragments =
362-
this.config.documentMode === DocumentMode.documentNode ||
363-
this.config.documentMode === DocumentMode.string ||
364-
(this.config.dedupeFragments && node.kind === 'OperationDefinition');
349+
this.config.documentMode === DocumentMode.documentNode || this.config.documentMode === DocumentMode.string;
365350
const fragmentNames = this._extractFragments(node, includeNestedFragments);
366351
const fragments = this._transformFragments(fragmentNames);
367352

368353
const doc = this._prepareDocument(`
369354
${print(node).split('\\').join('\\\\') /* Re-escape escaped values in GraphQL syntax */}
370-
${this._includeFragments(fragments, node.kind)}`);
355+
${this._includeFragments(fragments)}`);
371356

372357
if (this.config.documentMode === DocumentMode.documentNode) {
373358
let gqlObj = gqlTag([doc]);

packages/plugins/typescript/document-nodes/tests/graphql-document-nodes.spec.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -297,29 +297,6 @@ describe('graphql-codegen typescript-graphql-document-nodes', () => {
297297
validateTs(mergeOutputs([result]));
298298
});
299299

300-
it('Should generate simple module without graphql-tag', async () => {
301-
const result = plugin(
302-
null,
303-
[
304-
{
305-
location: 'some/file/my-query.graphql',
306-
document: parse(/* GraphQL */ `
307-
query MyQuery {
308-
field
309-
}
310-
`),
311-
},
312-
],
313-
{ noGraphQLTag: true },
314-
{ outputFile: '' }
315-
) as Types.ComplexPluginOutput;
316-
317-
expect(result.content).toBeSimilarStringTo(`
318-
export const MyQuery = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"MyQuery"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"field"}}]}}]} as unknown as DocumentNode;
319-
`);
320-
validateTs(mergeOutputs([result]));
321-
});
322-
323300
it('should contain fragment definitions', async () => {
324301
const result = plugin(
325302
null,

packages/presets/client/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ export const preset: Types.OutputPreset<ClientPresetConfig> = {
134134
enumsAsConst: options.config.enumsAsConst,
135135
enumValues: options.config.enumValues,
136136
futureProofEnums: options.config.futureProofEnums,
137-
dedupeFragments: options.config.dedupeFragments,
138137
nonOptionalTypename: options.config.nonOptionalTypename,
139138
avoidOptionals: options.config.avoidOptionals,
140139
documentMode: options.config.documentMode,

packages/utils/plugins-helpers/src/types.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -464,19 +464,6 @@ export namespace Types {
464464
* For more details: https://graphql-code-generator.com/docs/getting-started/development-workflow#watch-mode
465465
*/
466466
watch?: boolean | string | string[];
467-
/**
468-
* @deprecated this is not necessary since we are using `@parcel/watcher` instead of `chockidar`.
469-
*
470-
* @description Allows overriding the behavior of watch to use stat polling over native file watching support.
471-
*
472-
* Config fields have the same defaults and sematics as the identically named ones for chokidar.
473-
*
474-
* For more details: https://graphql-code-generator.com/docs/getting-started/development-workflow#watch-mode
475-
*/
476-
watchConfig?: {
477-
usePolling: boolean;
478-
interval?: number;
479-
};
480467
/**
481468
* @description A flag to suppress non-zero exit code when there are no documents to generate.
482469
*/

website/public/config.schema.json

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@
5151
"description": "A flag to trigger codegen when there are changes in the specified GraphQL schemas.\n\nYou can either specify a boolean to turn it on/off or specify an array of glob patterns to add custom files to the watch.\n\nFor more details: https://graphql-code-generator.com/docs/getting-started/development-workflow#watch-mode",
5252
"anyOf": [{ "type": "array", "items": { "type": "string" } }, { "type": ["string", "boolean"] }]
5353
},
54-
"watchConfig": {
55-
"description": "Allows overriding the behavior of watch to use stat polling over native file watching support.\n\nConfig fields have the same defaults and sematics as the identically named ones for chokidar.\n\nFor more details: https://graphql-code-generator.com/docs/getting-started/development-workflow#watch-mode",
56-
"type": "object",
57-
"properties": { "usePolling": { "type": "boolean" }, "interval": { "type": "number" } }
58-
},
5954
"ignoreNoDocuments": {
6055
"description": "A flag to suppress non-zero exit code when there are no documents to generate.",
6156
"type": "boolean"
@@ -292,10 +287,6 @@
292287
"description": "Automatically adds `__typename` field to the generated types, even when they are not specified\nin the selection set, and makes it non-optional\nDefault value: \"false\"",
293288
"type": "boolean"
294289
},
295-
"dedupeFragments": {
296-
"description": "Removes fragment duplicates for reducing data transfer.\nIt is done by removing sub-fragments imports from fragment definition\nInstead - all of them are imported to the Operation node.\nDefault value: \"false\"",
297-
"type": "boolean"
298-
},
299290
"inlineFragmentTypes": {
300291
"description": "Whether fragment types should be inlined into other operations.\n\"inline\" is the default behavior and will perform deep inlining fragment types within operation type definitions.\n\"combine\" is the previous behavior that uses fragment type references without inlining the types (and might cause issues with deeply nested fragment that uses list types).\nDefault value: \"inline\"",
301292
"type": "string"
@@ -315,6 +306,10 @@
315306
"skipTypename": {
316307
"description": "Does not add `__typename` to the generated types, unless it was specified in the selection set.\nDefault value: \"false\"",
317308
"type": "boolean"
309+
},
310+
"dedupeFragments": {
311+
"description": "Removes fragment duplicates for reducing data transfer.\nIt is done by removing sub-fragments imports from fragment definition\nInstead - all of them are imported to the Operation node.\nDefault value: \"false\"",
312+
"type": "boolean"
318313
}
319314
}
320315
},
@@ -653,10 +648,6 @@
653648
"type": "boolean",
654649
"description": "Will use `import type {}` rather than `import {}` when importing only types. This gives\ncompatibility with TypeScript's \"importsNotUsedAsValues\": \"error\" option\nDefault value: \"false\""
655650
},
656-
"dedupeFragments": {
657-
"description": "Removes fragment duplicates for reducing data transfer.\nIt is done by removing sub-fragments imports from fragment definition\nInstead - all of them are imported to the Operation node.\nDefault value: \"false\"",
658-
"type": "boolean"
659-
},
660651
"inlineFragmentTypes": {
661652
"description": "Whether fragment types should be inlined into other operations.\n\"inline\" is the default behavior and will perform deep inlining fragment types within operation type definitions.\n\"combine\" is the previous behavior that uses fragment type references without inlining the types (and might cause issues with deeply nested fragment that uses list types).\n\"mask\" transforms the types for use with fragment masking. Useful when masked types are needed when not using the \"client\" preset e.g. such as combining it with Apollo Client's data masking feature.\nDefault value: \"inline\"",
662653
"type": "string"
@@ -850,10 +841,6 @@
850841
"type": "boolean",
851842
"description": "Will use `import type {}` rather than `import {}` when importing only types. This gives\ncompatibility with TypeScript's \"importsNotUsedAsValues\": \"error\" option\nDefault value: \"false\""
852843
},
853-
"dedupeFragments": {
854-
"description": "Removes fragment duplicates for reducing data transfer.\nIt is done by removing sub-fragments imports from fragment definition\nInstead - all of them are imported to the Operation node.\nDefault value: \"false\"",
855-
"type": "boolean"
856-
},
857844
"inlineFragmentTypes": {
858845
"description": "Whether fragment types should be inlined into other operations.\n\"inline\" is the default behavior and will perform deep inlining fragment types within operation type definitions.\n\"combine\" is the previous behavior that uses fragment type references without inlining the types (and might cause issues with deeply nested fragment that uses list types).\n\"mask\" transforms the types for use with fragment masking. Useful when masked types are needed when not using the \"client\" preset e.g. such as combining it with Apollo Client's data masking feature.\nDefault value: \"inline\"",
859846
"type": "string"
@@ -1631,14 +1618,6 @@
16311618
"type": "string",
16321619
"description": "Defines the prefix value used for `__resolveType` and `__isTypeOf` resolvers.\nIf you are using `mercurius-js`, please set this field to empty string for better compatibility.\nDefault value: \"'__'\""
16331620
},
1634-
"generateInternalResolversIfNeeded": {
1635-
"type": "object",
1636-
"description": "If relevant internal resolvers are set to `true`, the resolver type will only be generated if the right conditions are met.\nEnabling this allows a more correct type generation for the resolvers.\nFor example:\n- `__isTypeOf` is generated for implementing types and union members\n- `__resolveReference` is generated for federation types that have at least one resolvable `@key` directive\nDefault value: \"{ __resolveReference: false }\""
1637-
},
1638-
"onlyResolveTypeForInterfaces": {
1639-
"type": "boolean",
1640-
"description": "Turning this flag to `true` will generate resolver signature that has only `resolveType` for interfaces, forcing developers to write inherited type resolvers in the type itself.\nDefault value: \"false\""
1641-
},
16421621
"resolversNonOptionalTypename": {
16431622
"description": "Makes `__typename` of resolver mappings non-optional without affecting the base types.\nDefault value: \"false\"",
16441623
"anyOf": [{ "$ref": "#/definitions/ResolversNonOptionalTypenameConfig" }, { "type": "boolean" }]
@@ -1677,10 +1656,6 @@
16771656
"type": "boolean",
16781657
"description": "Will use `import type {}` rather than `import {}` when importing only types. This gives\ncompatibility with TypeScript's \"importsNotUsedAsValues\": \"error\" option\nDefault value: \"false\""
16791658
},
1680-
"dedupeFragments": {
1681-
"description": "Removes fragment duplicates for reducing data transfer.\nIt is done by removing sub-fragments imports from fragment definition\nInstead - all of them are imported to the Operation node.\nDefault value: \"false\"",
1682-
"type": "boolean"
1683-
},
16841659
"inlineFragmentTypes": {
16851660
"description": "Whether fragment types should be inlined into other operations.\n\"inline\" is the default behavior and will perform deep inlining fragment types within operation type definitions.\n\"combine\" is the previous behavior that uses fragment type references without inlining the types (and might cause issues with deeply nested fragment that uses list types).\n\"mask\" transforms the types for use with fragment masking. Useful when masked types are needed when not using the \"client\" preset e.g. such as combining it with Apollo Client's data masking feature.\nDefault value: \"inline\"",
16861661
"type": "string"
@@ -2716,10 +2691,6 @@
27162691
"description": "Adds suffix to the fragment variable\nDefault value: \"\"",
27172692
"type": "string"
27182693
},
2719-
"noGraphQLTag": {
2720-
"description": "Deprecated. Changes the documentMode to `documentNode`.\nDefault value: \"false\"",
2721-
"type": "boolean"
2722-
},
27232694
"gqlImport": {
27242695
"description": "Customize from which module will `gql` be imported from.\nThis is useful if you want to use modules other than `graphql-tag`, e.g. `graphql.macro`.\nDefault value: \"graphql-tag#gql\"",
27252696
"type": "string"
@@ -2810,10 +2781,6 @@
28102781
"type": "boolean",
28112782
"description": "Will use `import type {}` rather than `import {}` when importing only types. This gives\ncompatibility with TypeScript's \"importsNotUsedAsValues\": \"error\" option\nDefault value: \"false\""
28122783
},
2813-
"dedupeFragments": {
2814-
"description": "Removes fragment duplicates for reducing data transfer.\nIt is done by removing sub-fragments imports from fragment definition\nInstead - all of them are imported to the Operation node.\nDefault value: \"false\"",
2815-
"type": "boolean"
2816-
},
28172784
"inlineFragmentTypes": {
28182785
"description": "Whether fragment types should be inlined into other operations.\n\"inline\" is the default behavior and will perform deep inlining fragment types within operation type definitions.\n\"combine\" is the previous behavior that uses fragment type references without inlining the types (and might cause issues with deeply nested fragment that uses list types).\n\"mask\" transforms the types for use with fragment masking. Useful when masked types are needed when not using the \"client\" preset e.g. such as combining it with Apollo Client's data masking feature.\nDefault value: \"inline\"",
28192786
"type": "string"

website/src/pages/docs/guides/react-vue.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,6 @@ The `client` preset allows the following `config` options:
510510
- [`enumsAsTypes`](/plugins/typescript/typescript#enumsastypes): Generates enum as TypeScript string union `type` instead of an `enum`. Useful if you wish to generate `.d.ts` declaration file instead of `.ts`, or if you want to avoid using TypeScript enums due to bundle size concerns.
511511
- [`enumsAsConst`](/plugins/typescript/typescript#enumsasconst): Generates enum as TypeScript const assertions instead of enum. This can even be used to enable enum-like patterns in plain JavaScript code if you choose not to use TypeScript’s enum construct.
512512
- [`enumValues`](/plugins/typescript/typescript#enumvalues): Overrides the default value of enum values declared in your GraphQL schema. You can also map the entire enum to an external type by providing a string that of module#type.
513-
- [`dedupeFragments`](/plugins/typescript/typescript#dedupefragments): Removes fragment duplicates for reducing data transfer. It is done by removing sub-fragments imports from fragment definition.
514513
- [`nonOptionalTypename`](/plugins/typescript/typescript#nonoptionaltypename): Automatically adds `__typename` field to the generated types, even when they are not specified in the selection set, and makes it non-optional.
515514
- [`avoidOptionals`](/plugins/typescript/typescript#avoidoptionals): This will cause the generator to avoid using TypeScript optionals (`?`) on types.
516515

0 commit comments

Comments
 (0)