@depup/graphql-codegen__typescript-operations 6.1.1-depup.0 → 6.1.3-depup.0

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/README.md CHANGED
@@ -13,8 +13,8 @@ npm install @depup/graphql-codegen__typescript-operations
13
13
 
14
14
  | Field | Value |
15
15
  |-------|-------|
16
- | Original | [@graphql-codegen/typescript-operations](https://www.npmjs.com/package/@graphql-codegen/typescript-operations) @ 6.1.1 |
17
- | Processed | 2026-07-21 |
16
+ | Original | [@graphql-codegen/typescript-operations](https://www.npmjs.com/package/@graphql-codegen/typescript-operations) @ 6.1.3 |
17
+ | Processed | 2026-08-05 |
18
18
  | Smoke test | passed |
19
19
  | Deps updated | 2 |
20
20
 
package/changes.json CHANGED
@@ -9,6 +9,6 @@
9
9
  "to": "^2.8.1"
10
10
  }
11
11
  },
12
- "timestamp": "2026-07-21T16:04:46.562Z",
12
+ "timestamp": "2026-08-05T08:57:29.001Z",
13
13
  "totalUpdated": 2
14
14
  }
package/cjs/index.js CHANGED
@@ -82,13 +82,32 @@ const plugin = async (inputSchema, rawDocuments, config, { outputFile }) => {
82
82
  }
83
83
  }
84
84
  }
85
+ // #region generateSchemaTypes
86
+ // When Input and Enum appear in Result selection sets, we need to
87
+ // generate those types so they can be referred to correctly
85
88
  const schemaTypes = (0, plugin_helpers_1.oldVisit)((0, schema_ast_1.transformSchemaAST)(schema, config).ast, { leave: visitor });
86
- // IMPORTANT: when a visitor leaves a node with no transformation logic,
87
- // It will leave the node as an object.
88
- // Here, we filter in nodes that have been turned into strings, i.e. they have been transformed
89
- // This way, we do not have to explicitly declare a method for every node type to convert them to null
90
- const schemaTypesDefinitions = schemaTypes.definitions.filter(def => typeof def === 'string');
91
- let content = [...schemaTypesDefinitions, ...operationsDefinitions].join('\n');
89
+ const schemaTypesDefinitions = findTransformedDefinitions(schemaTypes);
90
+ // #endregion
91
+ // #region generateIntrospectionTypesDefinitions
92
+ // It is possible for queries to refer to enums in introspection:
93
+ // - `__TypeKind`
94
+ // - `__DirectiveOperation`
95
+ //
96
+ // In such cases, we need to generate the used introspection types
97
+ // so the Result types can refer to them correctly (similar to how we do schema types)
98
+ let introspectionTypesDefinitions = [];
99
+ if (visitor.shouldVisitIntrospectionTypes()) {
100
+ const introspectionTypes = (0, plugin_helpers_1.oldVisit)((0, graphql_1.parse)((0, graphql_1.printIntrospectionSchema)(schema)), {
101
+ leave: visitor,
102
+ });
103
+ introspectionTypesDefinitions = findTransformedDefinitions(introspectionTypes);
104
+ }
105
+ // #endregion
106
+ let content = [
107
+ ...schemaTypesDefinitions,
108
+ ...introspectionTypesDefinitions,
109
+ ...operationsDefinitions,
110
+ ].join('\n');
92
111
  if (config.globalNamespace) {
93
112
  content = `
94
113
  declare global {
@@ -118,3 +137,11 @@ const semanticToStrict = async (schema) => {
118
137
  throw new Error("To use the `nullability.errorHandlingClient` option, you must install the 'graphql-sock' package.");
119
138
  }
120
139
  };
140
+ // IMPORTANT: when a visitor leaves a node with no transformation logic,
141
+ // It will leave the node as an object.
142
+ //
143
+ // This helper function filters in nodes that have been turned into strings, i.e. they have been transformed
144
+ // This way, we do not have to explicitly declare a method for every node type to convert them to null
145
+ const findTransformedDefinitions = (visitedResult) => {
146
+ return visitedResult.definitions.filter(def => typeof def === 'string');
147
+ };
package/cjs/visitor.js CHANGED
@@ -10,6 +10,14 @@ const ts_operation_variables_to_object_js_1 = require("./ts-operation-variables-
10
10
  class TypeScriptDocumentsVisitor extends visitor_plugin_common_1.BaseDocumentsVisitor {
11
11
  _usedSchemaTypes = {};
12
12
  _needsExactUtilityType = false;
13
+ /**
14
+ * _usedEnumIntrospectionType is a metadata value
15
+ * which tracks whether an introspection type enum (i.e. __TypeKind or __DirectiveLocation)
16
+ * has been referred to in selection sets
17
+ *
18
+ * If it is, we need to generate the enum values from introspection types
19
+ */
20
+ _usedEnumIntrospectionType = false;
13
21
  _outputPath;
14
22
  constructor(schema, config, documentNode, outputPath) {
15
23
  super(config, {
@@ -465,6 +473,9 @@ class TypeScriptDocumentsVisitor extends visitor_plugin_common_1.BaseDocumentsVi
465
473
  node: namedType,
466
474
  tsType: this.convertName(namedType.name),
467
475
  };
476
+ if ((0, graphql_1.isIntrospectionType)(namedType)) {
477
+ this._usedEnumIntrospectionType = true;
478
+ }
468
479
  return;
469
480
  }
470
481
  if (namedType instanceof graphql_1.GraphQLScalarType) {
@@ -504,6 +515,9 @@ class TypeScriptDocumentsVisitor extends visitor_plugin_common_1.BaseDocumentsVi
504
515
  // 2. In Client Preset, it is used by fragment-masking.ts, so it needs `export`
505
516
  return `${internalUtilityTypeWarning}export type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };`;
506
517
  }
518
+ shouldVisitIntrospectionTypes() {
519
+ return this._usedEnumIntrospectionType;
520
+ }
507
521
  }
508
522
  exports.TypeScriptDocumentsVisitor = TypeScriptDocumentsVisitor;
509
523
  const internalUtilityTypeWarning = '/** Internal type. DO NOT USE DIRECTLY. */\n';
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { concatAST } from 'graphql';
1
+ import { concatAST, parse, printIntrospectionSchema, } from 'graphql';
2
2
  import { oldVisit } from '@graphql-codegen/plugin-helpers';
3
3
  import { transformSchemaAST } from '@graphql-codegen/schema-ast';
4
4
  import { optimizeOperations } from '@graphql-codegen/visitor-plugin-common';
@@ -45,13 +45,32 @@ export const plugin = async (inputSchema, rawDocuments, config, { outputFile })
45
45
  }
46
46
  }
47
47
  }
48
+ // #region generateSchemaTypes
49
+ // When Input and Enum appear in Result selection sets, we need to
50
+ // generate those types so they can be referred to correctly
48
51
  const schemaTypes = oldVisit(transformSchemaAST(schema, config).ast, { leave: visitor });
49
- // IMPORTANT: when a visitor leaves a node with no transformation logic,
50
- // It will leave the node as an object.
51
- // Here, we filter in nodes that have been turned into strings, i.e. they have been transformed
52
- // This way, we do not have to explicitly declare a method for every node type to convert them to null
53
- const schemaTypesDefinitions = schemaTypes.definitions.filter(def => typeof def === 'string');
54
- let content = [...schemaTypesDefinitions, ...operationsDefinitions].join('\n');
52
+ const schemaTypesDefinitions = findTransformedDefinitions(schemaTypes);
53
+ // #endregion
54
+ // #region generateIntrospectionTypesDefinitions
55
+ // It is possible for queries to refer to enums in introspection:
56
+ // - `__TypeKind`
57
+ // - `__DirectiveOperation`
58
+ //
59
+ // In such cases, we need to generate the used introspection types
60
+ // so the Result types can refer to them correctly (similar to how we do schema types)
61
+ let introspectionTypesDefinitions = [];
62
+ if (visitor.shouldVisitIntrospectionTypes()) {
63
+ const introspectionTypes = oldVisit(parse(printIntrospectionSchema(schema)), {
64
+ leave: visitor,
65
+ });
66
+ introspectionTypesDefinitions = findTransformedDefinitions(introspectionTypes);
67
+ }
68
+ // #endregion
69
+ let content = [
70
+ ...schemaTypesDefinitions,
71
+ ...introspectionTypesDefinitions,
72
+ ...operationsDefinitions,
73
+ ].join('\n');
55
74
  if (config.globalNamespace) {
56
75
  content = `
57
76
  declare global {
@@ -81,3 +100,11 @@ const semanticToStrict = async (schema) => {
81
100
  throw new Error("To use the `nullability.errorHandlingClient` option, you must install the 'graphql-sock' package.");
82
101
  }
83
102
  };
103
+ // IMPORTANT: when a visitor leaves a node with no transformation logic,
104
+ // It will leave the node as an object.
105
+ //
106
+ // This helper function filters in nodes that have been turned into strings, i.e. they have been transformed
107
+ // This way, we do not have to explicitly declare a method for every node type to convert them to null
108
+ const findTransformedDefinitions = (visitedResult) => {
109
+ return visitedResult.definitions.filter(def => typeof def === 'string');
110
+ };
package/esm/visitor.js CHANGED
@@ -1,11 +1,19 @@
1
1
  import autoBind from 'auto-bind';
2
- import { getNamedType, GraphQLEnumType, GraphQLInputObjectType, GraphQLScalarType, isEnumType, Kind, TypeInfo, visit, visitWithTypeInfo, } from 'graphql';
2
+ import { getNamedType, GraphQLEnumType, GraphQLInputObjectType, GraphQLScalarType, isEnumType, isIntrospectionType, Kind, TypeInfo, visit, visitWithTypeInfo, } from 'graphql';
3
3
  import { normalizeImportExtension } from '@graphql-codegen/plugin-helpers';
4
4
  import { BaseDocumentsVisitor, buildTypeImport, convertSchemaEnumToDeclarationBlockString, DeclarationBlock, DEFAULT_INPUT_SCALARS, generateFragmentImportStatement, generateImportStatement, getConfigValue, getEnumsImports, getNodeComment, indent, isNativeNamedType, isOneOfInputObjectType, parseEnumValues, PreResolveTypesProcessor, printTypeScriptMaybeType, SelectionSetToObject, wrapTypeWithModifiers, } from '@graphql-codegen/visitor-plugin-common';
5
5
  import { TypeScriptOperationVariablesToObject } from './ts-operation-variables-to-object.js';
6
6
  export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor {
7
7
  _usedSchemaTypes = {};
8
8
  _needsExactUtilityType = false;
9
+ /**
10
+ * _usedEnumIntrospectionType is a metadata value
11
+ * which tracks whether an introspection type enum (i.e. __TypeKind or __DirectiveLocation)
12
+ * has been referred to in selection sets
13
+ *
14
+ * If it is, we need to generate the enum values from introspection types
15
+ */
16
+ _usedEnumIntrospectionType = false;
9
17
  _outputPath;
10
18
  constructor(schema, config, documentNode, outputPath) {
11
19
  super(config, {
@@ -461,6 +469,9 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor {
461
469
  node: namedType,
462
470
  tsType: this.convertName(namedType.name),
463
471
  };
472
+ if (isIntrospectionType(namedType)) {
473
+ this._usedEnumIntrospectionType = true;
474
+ }
464
475
  return;
465
476
  }
466
477
  if (namedType instanceof GraphQLScalarType) {
@@ -500,6 +511,9 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor {
500
511
  // 2. In Client Preset, it is used by fragment-masking.ts, so it needs `export`
501
512
  return `${internalUtilityTypeWarning}export type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };`;
502
513
  }
514
+ shouldVisitIntrospectionTypes() {
515
+ return this._usedEnumIntrospectionType;
516
+ }
503
517
  }
504
518
  const internalUtilityTypeWarning = '/** Internal type. DO NOT USE DIRECTLY. */\n';
505
519
  function parseOneOfInputValue({ node, schema, ancestors, }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@depup/graphql-codegen__typescript-operations",
3
- "version": "6.1.1-depup.0",
3
+ "version": "6.1.3-depup.0",
4
4
  "description": "GraphQL Code Generator plugin for generating TypeScript types for GraphQL queries, mutations, subscriptions and fragments (with updated dependencies)",
5
5
  "peerDependenciesMeta": {
6
6
  "graphql-sock": {
@@ -15,8 +15,8 @@
15
15
  "auto-bind": "^5.0.1",
16
16
  "tslib": "^2.8.1",
17
17
  "@graphql-codegen/plugin-helpers": "^7.1.0",
18
- "@graphql-codegen/visitor-plugin-common": "^7.2.1",
19
- "@graphql-codegen/schema-ast": "^6.1.0"
18
+ "@graphql-codegen/schema-ast": "^6.1.0",
19
+ "@graphql-codegen/visitor-plugin-common": "^7.2.3"
20
20
  },
21
21
  "repository": {
22
22
  "type": "git",
@@ -72,8 +72,8 @@
72
72
  },
73
73
  "depsUpdated": 2,
74
74
  "originalPackage": "@graphql-codegen/typescript-operations",
75
- "originalVersion": "6.1.1",
76
- "processedAt": "2026-07-21T16:04:51.544Z",
75
+ "originalVersion": "6.1.3",
76
+ "processedAt": "2026-08-05T08:57:36.549Z",
77
77
  "smokeTest": "passed"
78
78
  }
79
79
  }
@@ -1,4 +1,4 @@
1
- import { EnumTypeDefinitionNode, GraphQLEnumType, GraphQLInputObjectType, GraphQLScalarType, InputObjectTypeDefinitionNode, InputValueDefinitionNode, type DocumentNode, type GraphQLSchema, type TypeDefinitionNode } from 'graphql';
1
+ import { GraphQLEnumType, GraphQLInputObjectType, GraphQLScalarType, InputObjectTypeDefinitionNode, InputValueDefinitionNode, type DocumentNode, type EnumTypeDefinitionNode, type GraphQLSchema, type TypeDefinitionNode } from 'graphql';
2
2
  import { BaseDocumentsVisitor, DeclarationKind, ParsedDocumentsConfig, type ConvertSchemaEnumToDeclarationBlockString, type ParsedEnumValuesMap } from '@graphql-codegen/visitor-plugin-common';
3
3
  import type { TypeScriptDocumentsPluginConfig } from './config.cjs';
4
4
  export interface TypeScriptDocumentsParsedConfig extends ParsedDocumentsConfig {
@@ -34,6 +34,14 @@ type UsedSchemaTypes = Record<string, {
34
34
  export declare class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor<TypeScriptDocumentsPluginConfig, TypeScriptDocumentsParsedConfig> {
35
35
  protected _usedSchemaTypes: UsedSchemaTypes;
36
36
  protected _needsExactUtilityType: boolean;
37
+ /**
38
+ * _usedEnumIntrospectionType is a metadata value
39
+ * which tracks whether an introspection type enum (i.e. __TypeKind or __DirectiveLocation)
40
+ * has been referred to in selection sets
41
+ *
42
+ * If it is, we need to generate the enum values from introspection types
43
+ */
44
+ protected _usedEnumIntrospectionType: boolean;
37
45
  private _outputPath;
38
46
  constructor(schema: GraphQLSchema, config: TypeScriptDocumentsPluginConfig, documentNode: DocumentNode, outputPath: string);
39
47
  EnumTypeDefinition(node: EnumTypeDefinitionNode): string | null;
@@ -58,5 +66,6 @@ export declare class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor<Typ
58
66
  private collectUsedSchemaTypesToGenerate;
59
67
  getExactUtilityType(): string | null;
60
68
  getIncrementalUtilityType(): string | null;
69
+ shouldVisitIntrospectionTypes(): boolean;
61
70
  }
62
71
  export {};
@@ -1,4 +1,4 @@
1
- import { EnumTypeDefinitionNode, GraphQLEnumType, GraphQLInputObjectType, GraphQLScalarType, InputObjectTypeDefinitionNode, InputValueDefinitionNode, type DocumentNode, type GraphQLSchema, type TypeDefinitionNode } from 'graphql';
1
+ import { GraphQLEnumType, GraphQLInputObjectType, GraphQLScalarType, InputObjectTypeDefinitionNode, InputValueDefinitionNode, type DocumentNode, type EnumTypeDefinitionNode, type GraphQLSchema, type TypeDefinitionNode } from 'graphql';
2
2
  import { BaseDocumentsVisitor, DeclarationKind, ParsedDocumentsConfig, type ConvertSchemaEnumToDeclarationBlockString, type ParsedEnumValuesMap } from '@graphql-codegen/visitor-plugin-common';
3
3
  import type { TypeScriptDocumentsPluginConfig } from './config.js';
4
4
  export interface TypeScriptDocumentsParsedConfig extends ParsedDocumentsConfig {
@@ -34,6 +34,14 @@ type UsedSchemaTypes = Record<string, {
34
34
  export declare class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor<TypeScriptDocumentsPluginConfig, TypeScriptDocumentsParsedConfig> {
35
35
  protected _usedSchemaTypes: UsedSchemaTypes;
36
36
  protected _needsExactUtilityType: boolean;
37
+ /**
38
+ * _usedEnumIntrospectionType is a metadata value
39
+ * which tracks whether an introspection type enum (i.e. __TypeKind or __DirectiveLocation)
40
+ * has been referred to in selection sets
41
+ *
42
+ * If it is, we need to generate the enum values from introspection types
43
+ */
44
+ protected _usedEnumIntrospectionType: boolean;
37
45
  private _outputPath;
38
46
  constructor(schema: GraphQLSchema, config: TypeScriptDocumentsPluginConfig, documentNode: DocumentNode, outputPath: string);
39
47
  EnumTypeDefinition(node: EnumTypeDefinitionNode): string | null;
@@ -58,5 +66,6 @@ export declare class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor<Typ
58
66
  private collectUsedSchemaTypesToGenerate;
59
67
  getExactUtilityType(): string | null;
60
68
  getIncrementalUtilityType(): string | null;
69
+ shouldVisitIntrospectionTypes(): boolean;
61
70
  }
62
71
  export {};