@graphql-codegen/typescript 4.0.9 → 4.1.0-alpha-20240728124515-0e7e51fbc250f3e96f346caed708834ffc0a8ddf

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/cjs/visitor.js CHANGED
@@ -30,6 +30,7 @@ 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),
33
34
  ...additionalConfig,
34
35
  });
35
36
  (0, auto_bind_1.default)(this);
@@ -150,6 +151,8 @@ class TsVisitor extends visitor_plugin_common_1.BaseTypesVisitor {
150
151
  return `${this.getMaybeWrapper(ancestors)}<${super.ListType(node, key, parent, path, ancestors)}>`;
151
152
  }
152
153
  UnionTypeDefinition(node, key, parent) {
154
+ if (this.config.onlyTypescriptOperationTypes)
155
+ return '';
153
156
  if (this.config.onlyOperationTypes || this.config.onlyEnums)
154
157
  return '';
155
158
  let withFutureAddedValue = [];
package/esm/visitor.js CHANGED
@@ -26,6 +26,7 @@ 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),
29
30
  ...additionalConfig,
30
31
  });
31
32
  autoBind(this);
@@ -146,6 +147,8 @@ export class TsVisitor extends BaseTypesVisitor {
146
147
  return `${this.getMaybeWrapper(ancestors)}<${super.ListType(node, key, parent, path, ancestors)}>`;
147
148
  }
148
149
  UnionTypeDefinition(node, key, parent) {
150
+ if (this.config.onlyTypescriptOperationTypes)
151
+ return '';
149
152
  if (this.config.onlyOperationTypes || this.config.onlyEnums)
150
153
  return '';
151
154
  let withFutureAddedValue = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-codegen/typescript",
3
- "version": "4.0.9",
3
+ "version": "4.1.0-alpha-20240728124515-0e7e51fbc250f3e96f346caed708834ffc0a8ddf",
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.3.1",
11
+ "@graphql-codegen/visitor-plugin-common": "5.4.0-alpha-20240728124515-0e7e51fbc250f3e96f346caed708834ffc0a8ddf",
12
12
  "auto-bind": "~4.0.0",
13
13
  "tslib": "~2.6.0"
14
14
  },
@@ -511,4 +511,8 @@ 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;
514
518
  }
@@ -511,4 +511,8 @@ 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;
514
518
  }
@@ -16,6 +16,7 @@ export interface TypeScriptPluginParsedConfig extends ParsedTypesConfig {
16
16
  inputMaybeValue: string;
17
17
  noExport: boolean;
18
18
  useImplementingTypes: boolean;
19
+ onlyTypescriptOperationTypes: boolean;
19
20
  }
20
21
  export declare const EXACT_SIGNATURE = "type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };";
21
22
  export declare const MAKE_OPTIONAL_SIGNATURE = "type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };";
@@ -16,6 +16,7 @@ export interface TypeScriptPluginParsedConfig extends ParsedTypesConfig {
16
16
  inputMaybeValue: string;
17
17
  noExport: boolean;
18
18
  useImplementingTypes: boolean;
19
+ onlyTypescriptOperationTypes: boolean;
19
20
  }
20
21
  export declare const EXACT_SIGNATURE = "type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };";
21
22
  export declare const MAKE_OPTIONAL_SIGNATURE = "type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };";