@graphql-codegen/typescript 4.1.0-alpha-20240728125032-e57eefd1f8d246a233a7b267f2a6a9f2861c7485 → 4.1.0-rc-20240803043057-1d6a2f31b06394be52dbbc636005859b3ce68294

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.
@@ -44,7 +44,7 @@ class TypeScriptOperationVariablesToObject extends visitor_plugin_common_1.Opera
44
44
  return `${prefix}${this._maybeType}${type ? `<${type}>` : ''}`;
45
45
  }
46
46
  getAvoidOption(isNonNullType, hasDefaultValue) {
47
- const options = (0, visitor_plugin_common_1.normalizeAvoidOptionals)(this._avoidOptionals);
47
+ const options = this._avoidOptionals;
48
48
  return ((options.object || !options.defaultValue) && hasDefaultValue) || (!options.object && !isNonNullType);
49
49
  }
50
50
  getPunctuation() {
package/cjs/visitor.js CHANGED
@@ -30,7 +30,6 @@ class TsVisitor extends visitor_plugin_common_1.BaseTypesVisitor {
30
30
  useImplementingTypes: (0, visitor_plugin_common_1.getConfigValue)(pluginConfig.useImplementingTypes, false),
31
31
  entireFieldWrapperValue: (0, visitor_plugin_common_1.getConfigValue)(pluginConfig.entireFieldWrapperValue, 'T'),
32
32
  wrapEntireDefinitions: (0, visitor_plugin_common_1.getConfigValue)(pluginConfig.wrapEntireFieldDefinitions, false),
33
- onlyTypescriptOperationTypes: (0, visitor_plugin_common_1.getConfigValue)(pluginConfig.onlyTypescriptOperationTypes, false),
34
33
  ...additionalConfig,
35
34
  });
36
35
  (0, auto_bind_1.default)(this);
@@ -151,8 +150,6 @@ class TsVisitor extends visitor_plugin_common_1.BaseTypesVisitor {
151
150
  return `${this.getMaybeWrapper(ancestors)}<${super.ListType(node, key, parent, path, ancestors)}>`;
152
151
  }
153
152
  UnionTypeDefinition(node, key, parent) {
154
- if (this.config.onlyTypescriptOperationTypes)
155
- return '';
156
153
  if (this.config.onlyOperationTypes || this.config.onlyEnums)
157
154
  return '';
158
155
  let withFutureAddedValue = [];
@@ -1,4 +1,4 @@
1
- import { normalizeAvoidOptionals, OperationVariablesToObject, } from '@graphql-codegen/visitor-plugin-common';
1
+ import { OperationVariablesToObject, } from '@graphql-codegen/visitor-plugin-common';
2
2
  import { Kind } from 'graphql';
3
3
  export class TypeScriptOperationVariablesToObject extends OperationVariablesToObject {
4
4
  constructor(_scalars, _convertName, _avoidOptionals, _immutableTypes, _namespacedImportName = null, _enumNames = [], _enumPrefix = true, _enumSuffix = true, _enumValues = {}, _applyCoercion = false, _directiveArgumentAndInputFieldMappings = {}, _maybeType = 'Maybe') {
@@ -41,7 +41,7 @@ export class TypeScriptOperationVariablesToObject extends OperationVariablesToOb
41
41
  return `${prefix}${this._maybeType}${type ? `<${type}>` : ''}`;
42
42
  }
43
43
  getAvoidOption(isNonNullType, hasDefaultValue) {
44
- const options = normalizeAvoidOptionals(this._avoidOptionals);
44
+ const options = this._avoidOptionals;
45
45
  return ((options.object || !options.defaultValue) && hasDefaultValue) || (!options.object && !isNonNullType);
46
46
  }
47
47
  getPunctuation() {
package/esm/visitor.js CHANGED
@@ -26,7 +26,6 @@ export class TsVisitor extends BaseTypesVisitor {
26
26
  useImplementingTypes: getConfigValue(pluginConfig.useImplementingTypes, false),
27
27
  entireFieldWrapperValue: getConfigValue(pluginConfig.entireFieldWrapperValue, 'T'),
28
28
  wrapEntireDefinitions: getConfigValue(pluginConfig.wrapEntireFieldDefinitions, false),
29
- onlyTypescriptOperationTypes: getConfigValue(pluginConfig.onlyTypescriptOperationTypes, false),
30
29
  ...additionalConfig,
31
30
  });
32
31
  autoBind(this);
@@ -147,8 +146,6 @@ export class TsVisitor extends BaseTypesVisitor {
147
146
  return `${this.getMaybeWrapper(ancestors)}<${super.ListType(node, key, parent, path, ancestors)}>`;
148
147
  }
149
148
  UnionTypeDefinition(node, key, parent) {
150
- if (this.config.onlyTypescriptOperationTypes)
151
- return '';
152
149
  if (this.config.onlyOperationTypes || this.config.onlyEnums)
153
150
  return '';
154
151
  let withFutureAddedValue = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-codegen/typescript",
3
- "version": "4.1.0-alpha-20240728125032-e57eefd1f8d246a233a7b267f2a6a9f2861c7485",
3
+ "version": "4.1.0-rc-20240803043057-1d6a2f31b06394be52dbbc636005859b3ce68294",
4
4
  "description": "GraphQL Code Generator plugin for generating TypeScript types",
5
5
  "peerDependencies": {
6
6
  "graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
@@ -8,7 +8,7 @@
8
8
  "dependencies": {
9
9
  "@graphql-codegen/plugin-helpers": "^5.0.4",
10
10
  "@graphql-codegen/schema-ast": "^4.0.2",
11
- "@graphql-codegen/visitor-plugin-common": "5.4.0-alpha-20240728125032-e57eefd1f8d246a233a7b267f2a6a9f2861c7485",
11
+ "@graphql-codegen/visitor-plugin-common": "5.4.0-rc-20240803043057-1d6a2f31b06394be52dbbc636005859b3ce68294",
12
12
  "auto-bind": "~4.0.0",
13
13
  "tslib": "~2.6.0"
14
14
  },
@@ -511,8 +511,4 @@ export interface TypeScriptPluginConfig extends RawTypesConfig {
511
511
  * ```
512
512
  */
513
513
  allowEnumStringTypes?: boolean;
514
- /**
515
- * @description Only generate types used by typescript operations
516
- */
517
- onlyTypescriptOperationTypes?: boolean;
518
514
  }
@@ -511,8 +511,4 @@ export interface TypeScriptPluginConfig extends RawTypesConfig {
511
511
  * ```
512
512
  */
513
513
  allowEnumStringTypes?: boolean;
514
- /**
515
- * @description Only generate types used by typescript operations
516
- */
517
- onlyTypescriptOperationTypes?: boolean;
518
514
  }
@@ -1,10 +1,10 @@
1
- import { AvoidOptionalsConfig, ConvertNameFn, NormalizedScalarsMap, OperationVariablesToObject, ParsedDirectiveArgumentAndInputFieldMappings, ParsedEnumValuesMap } from '@graphql-codegen/visitor-plugin-common';
1
+ import { ConvertNameFn, NormalizedAvoidOptionalsConfig, NormalizedScalarsMap, OperationVariablesToObject, ParsedDirectiveArgumentAndInputFieldMappings, ParsedEnumValuesMap } from '@graphql-codegen/visitor-plugin-common';
2
2
  import { TypeNode } from 'graphql';
3
3
  export declare class TypeScriptOperationVariablesToObject extends OperationVariablesToObject {
4
4
  private _avoidOptionals;
5
5
  private _immutableTypes;
6
6
  private _maybeType;
7
- constructor(_scalars: NormalizedScalarsMap, _convertName: ConvertNameFn, _avoidOptionals: boolean | AvoidOptionalsConfig, _immutableTypes: boolean, _namespacedImportName?: string | null, _enumNames?: string[], _enumPrefix?: boolean, _enumSuffix?: boolean, _enumValues?: ParsedEnumValuesMap, _applyCoercion?: Boolean, _directiveArgumentAndInputFieldMappings?: ParsedDirectiveArgumentAndInputFieldMappings, _maybeType?: string);
7
+ constructor(_scalars: NormalizedScalarsMap, _convertName: ConvertNameFn, _avoidOptionals: NormalizedAvoidOptionalsConfig, _immutableTypes: boolean, _namespacedImportName?: string | null, _enumNames?: string[], _enumPrefix?: boolean, _enumSuffix?: boolean, _enumValues?: ParsedEnumValuesMap, _applyCoercion?: Boolean, _directiveArgumentAndInputFieldMappings?: ParsedDirectiveArgumentAndInputFieldMappings, _maybeType?: string);
8
8
  private clearOptional;
9
9
  wrapAstTypeWithModifiers(baseType: string, typeNode: TypeNode, applyCoercion?: boolean): string;
10
10
  protected formatFieldString(fieldName: string, isNonNullType: boolean, hasDefaultValue: boolean): string;
@@ -1,10 +1,10 @@
1
- import { AvoidOptionalsConfig, ConvertNameFn, NormalizedScalarsMap, OperationVariablesToObject, ParsedDirectiveArgumentAndInputFieldMappings, ParsedEnumValuesMap } from '@graphql-codegen/visitor-plugin-common';
1
+ import { ConvertNameFn, NormalizedAvoidOptionalsConfig, NormalizedScalarsMap, OperationVariablesToObject, ParsedDirectiveArgumentAndInputFieldMappings, ParsedEnumValuesMap } from '@graphql-codegen/visitor-plugin-common';
2
2
  import { TypeNode } from 'graphql';
3
3
  export declare class TypeScriptOperationVariablesToObject extends OperationVariablesToObject {
4
4
  private _avoidOptionals;
5
5
  private _immutableTypes;
6
6
  private _maybeType;
7
- constructor(_scalars: NormalizedScalarsMap, _convertName: ConvertNameFn, _avoidOptionals: boolean | AvoidOptionalsConfig, _immutableTypes: boolean, _namespacedImportName?: string | null, _enumNames?: string[], _enumPrefix?: boolean, _enumSuffix?: boolean, _enumValues?: ParsedEnumValuesMap, _applyCoercion?: Boolean, _directiveArgumentAndInputFieldMappings?: ParsedDirectiveArgumentAndInputFieldMappings, _maybeType?: string);
7
+ constructor(_scalars: NormalizedScalarsMap, _convertName: ConvertNameFn, _avoidOptionals: NormalizedAvoidOptionalsConfig, _immutableTypes: boolean, _namespacedImportName?: string | null, _enumNames?: string[], _enumPrefix?: boolean, _enumSuffix?: boolean, _enumValues?: ParsedEnumValuesMap, _applyCoercion?: Boolean, _directiveArgumentAndInputFieldMappings?: ParsedDirectiveArgumentAndInputFieldMappings, _maybeType?: string);
8
8
  private clearOptional;
9
9
  wrapAstTypeWithModifiers(baseType: string, typeNode: TypeNode, applyCoercion?: boolean): string;
10
10
  protected formatFieldString(fieldName: string, isNonNullType: boolean, hasDefaultValue: boolean): string;
@@ -1,8 +1,8 @@
1
- import { AvoidOptionalsConfig, BaseTypesVisitor, DeclarationKind, ParsedTypesConfig } from '@graphql-codegen/visitor-plugin-common';
1
+ import { BaseTypesVisitor, DeclarationKind, NormalizedAvoidOptionalsConfig, ParsedTypesConfig } from '@graphql-codegen/visitor-plugin-common';
2
2
  import { EnumTypeDefinitionNode, FieldDefinitionNode, GraphQLSchema, InputValueDefinitionNode, ListTypeNode, NamedTypeNode, NonNullTypeNode, TypeDefinitionNode, UnionTypeDefinitionNode } from 'graphql';
3
3
  import { TypeScriptPluginConfig } from './config.cjs';
4
4
  export interface TypeScriptPluginParsedConfig extends ParsedTypesConfig {
5
- avoidOptionals: AvoidOptionalsConfig;
5
+ avoidOptionals: NormalizedAvoidOptionalsConfig;
6
6
  constEnums: boolean;
7
7
  enumsAsTypes: boolean;
8
8
  futureProofEnums: boolean;
@@ -16,7 +16,6 @@ export interface TypeScriptPluginParsedConfig extends ParsedTypesConfig {
16
16
  inputMaybeValue: string;
17
17
  noExport: boolean;
18
18
  useImplementingTypes: boolean;
19
- onlyTypescriptOperationTypes: boolean;
20
19
  }
21
20
  export declare const EXACT_SIGNATURE = "type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };";
22
21
  export declare const MAKE_OPTIONAL_SIGNATURE = "type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };";
@@ -1,8 +1,8 @@
1
- import { AvoidOptionalsConfig, BaseTypesVisitor, DeclarationKind, ParsedTypesConfig } from '@graphql-codegen/visitor-plugin-common';
1
+ import { BaseTypesVisitor, DeclarationKind, NormalizedAvoidOptionalsConfig, ParsedTypesConfig } from '@graphql-codegen/visitor-plugin-common';
2
2
  import { EnumTypeDefinitionNode, FieldDefinitionNode, GraphQLSchema, InputValueDefinitionNode, ListTypeNode, NamedTypeNode, NonNullTypeNode, TypeDefinitionNode, UnionTypeDefinitionNode } from 'graphql';
3
3
  import { TypeScriptPluginConfig } from './config.js';
4
4
  export interface TypeScriptPluginParsedConfig extends ParsedTypesConfig {
5
- avoidOptionals: AvoidOptionalsConfig;
5
+ avoidOptionals: NormalizedAvoidOptionalsConfig;
6
6
  constEnums: boolean;
7
7
  enumsAsTypes: boolean;
8
8
  futureProofEnums: boolean;
@@ -16,7 +16,6 @@ export interface TypeScriptPluginParsedConfig extends ParsedTypesConfig {
16
16
  inputMaybeValue: string;
17
17
  noExport: boolean;
18
18
  useImplementingTypes: boolean;
19
- onlyTypescriptOperationTypes: boolean;
20
19
  }
21
20
  export declare const EXACT_SIGNATURE = "type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };";
22
21
  export declare const MAKE_OPTIONAL_SIGNATURE = "type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };";