@depup/graphql-codegen__typescript-operations 6.1.6-depup.1 → 6.1.7-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,16 +13,15 @@ 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.6 |
17
- | Processed | 2026-08-22 |
16
+ | Original | [@graphql-codegen/typescript-operations](https://www.npmjs.com/package/@graphql-codegen/typescript-operations) @ 6.1.7 |
17
+ | Processed | 2026-09-20 |
18
18
  | Smoke test | passed |
19
- | Deps updated | 3 |
19
+ | Deps updated | 2 |
20
20
 
21
21
  ## Dependency Changes
22
22
 
23
23
  | Dependency | From | To |
24
24
  |------------|------|-----|
25
- | @graphql-codegen/plugin-helpers | ^7.1.0 | ^7.2.0 |
26
25
  | auto-bind | ^5.0.0 | ^5.0.1 |
27
26
  | tslib | ^2.8.0 | ^2.8.1 |
28
27
 
package/changes.json CHANGED
@@ -7,12 +7,8 @@
7
7
  "tslib": {
8
8
  "from": "^2.8.0",
9
9
  "to": "^2.8.1"
10
- },
11
- "@graphql-codegen/plugin-helpers": {
12
- "from": "^7.1.0",
13
- "to": "^7.2.0"
14
10
  }
15
11
  },
16
- "timestamp": "2026-08-22T08:07:49.168Z",
17
- "totalUpdated": 3
12
+ "timestamp": "2026-09-20T08:10:55.815Z",
13
+ "totalUpdated": 2
18
14
  }
package/cjs/index.js CHANGED
@@ -67,10 +67,10 @@ const plugin = async (inputSchema, rawDocuments, config, { outputFile }) => {
67
67
  // For Fragment types to resolve correctly, we must get read all docs (`standard` and `external`)
68
68
  // Fragment types are usually (but not always) in `external` files in certain setup, like a monorepo.
69
69
  const allDocumentsAST = (0, graphql_1.concatAST)(parsedDocuments.all.documentNodes);
70
- const visitor = new visitor_js_1.TypeScriptDocumentsVisitor(schema, config, allDocumentsAST, outputFile);
71
70
  // We only visit `standard` documents to generate types.
72
71
  // `external` documents are included as references for typechecking and completeness i.e. only used for reading purposes, no writing.
73
72
  const documentsToVisitAST = (0, graphql_1.concatAST)(parsedDocuments.standard.documentNodes);
73
+ const visitor = new visitor_js_1.TypeScriptDocumentsVisitor(schema, config, allDocumentsAST, documentsToVisitAST, outputFile);
74
74
  const operationsResult = (0, plugin_helpers_1.oldVisit)(documentsToVisitAST, {
75
75
  leave: visitor,
76
76
  });
package/cjs/visitor.js CHANGED
@@ -9,6 +9,16 @@ const visitor_plugin_common_1 = require("@graphql-codegen/visitor-plugin-common"
9
9
  const ts_operation_variables_to_object_js_1 = require("./ts-operation-variables-to-object.js");
10
10
  class TypeScriptDocumentsVisitor extends visitor_plugin_common_1.BaseDocumentsVisitor {
11
11
  _usedSchemaTypes = {};
12
+ /**
13
+ * _namedSchemaTypes is a subset of _usedSchemaTypes: the schema types this file's own
14
+ * generated declarations actually name, as opposed to types merely reached through the
15
+ * document (e.g. via a fragment). Those two diverge when `inlineFragmentTypes` is `'combine'`
16
+ * or `'mask'`: a fragment spread there collapses to a bare reference to the fragment's own
17
+ * generated type (printed in whichever file defines that fragment) instead of inlining its
18
+ * fields, so a schema type selected only inside such a fragment is never named here.
19
+ * This is what should gate whether a schema-type import/declaration is actually emitted.
20
+ */
21
+ _namedSchemaTypes = {};
12
22
  _needsExactUtilityType = false;
13
23
  /**
14
24
  * _usedEnumIntrospectionType is a metadata value
@@ -19,7 +29,7 @@ class TypeScriptDocumentsVisitor extends visitor_plugin_common_1.BaseDocumentsVi
19
29
  */
20
30
  _usedEnumIntrospectionType = false;
21
31
  _outputPath;
22
- constructor(schema, config, documentNode, outputPath) {
32
+ constructor(schema, config, documentNode, documentsToVisitAST, outputPath) {
23
33
  super(config, {
24
34
  arrayInputCoercion: (0, visitor_plugin_common_1.getConfigValue)(config.arrayInputCoercion, true),
25
35
  noExport: (0, visitor_plugin_common_1.getConfigValue)(config.noExport, false),
@@ -49,6 +59,7 @@ class TypeScriptDocumentsVisitor extends visitor_plugin_common_1.BaseDocumentsVi
49
59
  });
50
60
  this._outputPath = outputPath;
51
61
  (0, auto_bind_1.default)(this);
62
+ // #region collectUsedSchemaTypes
52
63
  const allFragments = [
53
64
  ...documentNode.definitions.filter(d => d.kind === graphql_1.Kind.FRAGMENT_DEFINITION).map(fragmentDef => ({
54
65
  node: fragmentDef,
@@ -70,6 +81,33 @@ class TypeScriptDocumentsVisitor extends visitor_plugin_common_1.BaseDocumentsVi
70
81
  schema,
71
82
  documentNode: documentWithAllFragments,
72
83
  });
84
+ // #endregion collectUsedSchemaTypes
85
+ // #region collectNamedSchemaTypes
86
+ const printedDefinitionNodes = new Set(documentsToVisitAST.definitions);
87
+ const namedFragments = this.config.inlineFragmentTypes === 'inline'
88
+ ? // In `inline` mode (the default), every fragment spread - internal or external - is inlined
89
+ // into whatever printed declaration references it, transitively, so anything reachable via
90
+ // `documentWithAllFragments` genuinely ends up named in this file's output too.
91
+ allFragments
92
+ : // In `combine`/`mask` mode, a fragment spread instead collapses to a bare reference to the
93
+ // fragment's own generated type. That reference only actually names a schema type when the
94
+ // fragment's own declaration is ALSO printed in this file (i.e. it's part of
95
+ // `documentsToVisitAST`) - an external fragment's fields are never printed (or inlined) here,
96
+ //
97
+ // i.e. only find fragments named in the same document
98
+ allFragments.filter(fragment => printedDefinitionNodes.has(fragment.node));
99
+ const namedDocument = {
100
+ ...documentNode,
101
+ definitions: [
102
+ ...documentsToVisitAST.definitions.filter(d => d.kind !== graphql_1.Kind.FRAGMENT_DEFINITION),
103
+ ...namedFragments.map(f => f.node),
104
+ ],
105
+ };
106
+ this._namedSchemaTypes = this.collectUsedSchemaTypesToGenerate({
107
+ schema,
108
+ documentNode: namedDocument,
109
+ });
110
+ // #endregion collectNamedSchemaTypes
73
111
  const processorConfig = {
74
112
  namespacedImportName: this.config.namespacedImportName,
75
113
  convertName: this.convertName.bind(this),
@@ -107,7 +145,7 @@ class TypeScriptDocumentsVisitor extends visitor_plugin_common_1.BaseDocumentsVi
107
145
  }
108
146
  EnumTypeDefinition(node) {
109
147
  const enumName = node.name.value;
110
- if (!this._usedSchemaTypes[enumName] || // If not used...
148
+ if (!this._namedSchemaTypes[enumName] || // If not named in this file's own output...
111
149
  this.config.importSchemaTypesFrom // ... Or, is imported from a shared file
112
150
  ) {
113
151
  return null; // ... then, don't generate in this file
@@ -134,7 +172,7 @@ class TypeScriptDocumentsVisitor extends visitor_plugin_common_1.BaseDocumentsVi
134
172
  }
135
173
  InputObjectTypeDefinition(node) {
136
174
  const inputTypeName = node.name.value;
137
- if (!this._usedSchemaTypes[inputTypeName] || // If not used...
175
+ if (!this._namedSchemaTypes[inputTypeName] || // If not named in this file's own output...
138
176
  this.config.importSchemaTypesFrom // ... Or, is imported from a shared file
139
177
  ) {
140
178
  return null; // ... then, don't generate in this file
@@ -262,7 +300,7 @@ class TypeScriptDocumentsVisitor extends visitor_plugin_common_1.BaseDocumentsVi
262
300
  if (!this.config.importSchemaTypesFrom) {
263
301
  return [];
264
302
  }
265
- const hasTypesToImport = Object.values(this._usedSchemaTypes).filter(value => value.type === 'GraphQLEnumType' || value.type === 'GraphQLInputObjectType').length > 0;
303
+ const hasTypesToImport = Object.values(this._namedSchemaTypes).filter(value => value.type === 'GraphQLEnumType' || value.type === 'GraphQLInputObjectType').length > 0;
266
304
  if (!hasTypesToImport) {
267
305
  return [];
268
306
  }
@@ -288,7 +326,7 @@ class TypeScriptDocumentsVisitor extends visitor_plugin_common_1.BaseDocumentsVi
288
326
  getEnumsImports() {
289
327
  const usedEnumMap = {};
290
328
  for (const [enumName, enumDetails] of Object.entries(this.config.enumValues)) {
291
- if (this._usedSchemaTypes[enumName]) {
329
+ if (this._namedSchemaTypes[enumName]) {
292
330
  usedEnumMap[enumName] = enumDetails;
293
331
  }
294
332
  }
@@ -305,7 +343,7 @@ class TypeScriptDocumentsVisitor extends visitor_plugin_common_1.BaseDocumentsVi
305
343
  : 'multi-file-shared-type-file';
306
344
  const imports = {};
307
345
  for (const [scalarName, parsedScalar] of Object.entries(this.config.scalars)) {
308
- const usedScalar = this._usedSchemaTypes[scalarName];
346
+ const usedScalar = this._namedSchemaTypes[scalarName];
309
347
  if (!usedScalar || usedScalar.type !== 'GraphQLScalarType') {
310
348
  continue;
311
349
  }
package/esm/index.js CHANGED
@@ -30,10 +30,10 @@ export const plugin = async (inputSchema, rawDocuments, config, { outputFile })
30
30
  // For Fragment types to resolve correctly, we must get read all docs (`standard` and `external`)
31
31
  // Fragment types are usually (but not always) in `external` files in certain setup, like a monorepo.
32
32
  const allDocumentsAST = concatAST(parsedDocuments.all.documentNodes);
33
- const visitor = new TypeScriptDocumentsVisitor(schema, config, allDocumentsAST, outputFile);
34
33
  // We only visit `standard` documents to generate types.
35
34
  // `external` documents are included as references for typechecking and completeness i.e. only used for reading purposes, no writing.
36
35
  const documentsToVisitAST = concatAST(parsedDocuments.standard.documentNodes);
36
+ const visitor = new TypeScriptDocumentsVisitor(schema, config, allDocumentsAST, documentsToVisitAST, outputFile);
37
37
  const operationsResult = oldVisit(documentsToVisitAST, {
38
38
  leave: visitor,
39
39
  });
package/esm/visitor.js CHANGED
@@ -5,6 +5,16 @@ import { BaseDocumentsVisitor, buildTypeImport, convertSchemaEnumToDeclarationBl
5
5
  import { TypeScriptOperationVariablesToObject } from './ts-operation-variables-to-object.js';
6
6
  export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor {
7
7
  _usedSchemaTypes = {};
8
+ /**
9
+ * _namedSchemaTypes is a subset of _usedSchemaTypes: the schema types this file's own
10
+ * generated declarations actually name, as opposed to types merely reached through the
11
+ * document (e.g. via a fragment). Those two diverge when `inlineFragmentTypes` is `'combine'`
12
+ * or `'mask'`: a fragment spread there collapses to a bare reference to the fragment's own
13
+ * generated type (printed in whichever file defines that fragment) instead of inlining its
14
+ * fields, so a schema type selected only inside such a fragment is never named here.
15
+ * This is what should gate whether a schema-type import/declaration is actually emitted.
16
+ */
17
+ _namedSchemaTypes = {};
8
18
  _needsExactUtilityType = false;
9
19
  /**
10
20
  * _usedEnumIntrospectionType is a metadata value
@@ -15,7 +25,7 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor {
15
25
  */
16
26
  _usedEnumIntrospectionType = false;
17
27
  _outputPath;
18
- constructor(schema, config, documentNode, outputPath) {
28
+ constructor(schema, config, documentNode, documentsToVisitAST, outputPath) {
19
29
  super(config, {
20
30
  arrayInputCoercion: getConfigValue(config.arrayInputCoercion, true),
21
31
  noExport: getConfigValue(config.noExport, false),
@@ -45,6 +55,7 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor {
45
55
  });
46
56
  this._outputPath = outputPath;
47
57
  autoBind(this);
58
+ // #region collectUsedSchemaTypes
48
59
  const allFragments = [
49
60
  ...documentNode.definitions.filter(d => d.kind === Kind.FRAGMENT_DEFINITION).map(fragmentDef => ({
50
61
  node: fragmentDef,
@@ -66,6 +77,33 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor {
66
77
  schema,
67
78
  documentNode: documentWithAllFragments,
68
79
  });
80
+ // #endregion collectUsedSchemaTypes
81
+ // #region collectNamedSchemaTypes
82
+ const printedDefinitionNodes = new Set(documentsToVisitAST.definitions);
83
+ const namedFragments = this.config.inlineFragmentTypes === 'inline'
84
+ ? // In `inline` mode (the default), every fragment spread - internal or external - is inlined
85
+ // into whatever printed declaration references it, transitively, so anything reachable via
86
+ // `documentWithAllFragments` genuinely ends up named in this file's output too.
87
+ allFragments
88
+ : // In `combine`/`mask` mode, a fragment spread instead collapses to a bare reference to the
89
+ // fragment's own generated type. That reference only actually names a schema type when the
90
+ // fragment's own declaration is ALSO printed in this file (i.e. it's part of
91
+ // `documentsToVisitAST`) - an external fragment's fields are never printed (or inlined) here,
92
+ //
93
+ // i.e. only find fragments named in the same document
94
+ allFragments.filter(fragment => printedDefinitionNodes.has(fragment.node));
95
+ const namedDocument = {
96
+ ...documentNode,
97
+ definitions: [
98
+ ...documentsToVisitAST.definitions.filter(d => d.kind !== Kind.FRAGMENT_DEFINITION),
99
+ ...namedFragments.map(f => f.node),
100
+ ],
101
+ };
102
+ this._namedSchemaTypes = this.collectUsedSchemaTypesToGenerate({
103
+ schema,
104
+ documentNode: namedDocument,
105
+ });
106
+ // #endregion collectNamedSchemaTypes
69
107
  const processorConfig = {
70
108
  namespacedImportName: this.config.namespacedImportName,
71
109
  convertName: this.convertName.bind(this),
@@ -103,7 +141,7 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor {
103
141
  }
104
142
  EnumTypeDefinition(node) {
105
143
  const enumName = node.name.value;
106
- if (!this._usedSchemaTypes[enumName] || // If not used...
144
+ if (!this._namedSchemaTypes[enumName] || // If not named in this file's own output...
107
145
  this.config.importSchemaTypesFrom // ... Or, is imported from a shared file
108
146
  ) {
109
147
  return null; // ... then, don't generate in this file
@@ -130,7 +168,7 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor {
130
168
  }
131
169
  InputObjectTypeDefinition(node) {
132
170
  const inputTypeName = node.name.value;
133
- if (!this._usedSchemaTypes[inputTypeName] || // If not used...
171
+ if (!this._namedSchemaTypes[inputTypeName] || // If not named in this file's own output...
134
172
  this.config.importSchemaTypesFrom // ... Or, is imported from a shared file
135
173
  ) {
136
174
  return null; // ... then, don't generate in this file
@@ -258,7 +296,7 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor {
258
296
  if (!this.config.importSchemaTypesFrom) {
259
297
  return [];
260
298
  }
261
- const hasTypesToImport = Object.values(this._usedSchemaTypes).filter(value => value.type === 'GraphQLEnumType' || value.type === 'GraphQLInputObjectType').length > 0;
299
+ const hasTypesToImport = Object.values(this._namedSchemaTypes).filter(value => value.type === 'GraphQLEnumType' || value.type === 'GraphQLInputObjectType').length > 0;
262
300
  if (!hasTypesToImport) {
263
301
  return [];
264
302
  }
@@ -284,7 +322,7 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor {
284
322
  getEnumsImports() {
285
323
  const usedEnumMap = {};
286
324
  for (const [enumName, enumDetails] of Object.entries(this.config.enumValues)) {
287
- if (this._usedSchemaTypes[enumName]) {
325
+ if (this._namedSchemaTypes[enumName]) {
288
326
  usedEnumMap[enumName] = enumDetails;
289
327
  }
290
328
  }
@@ -301,7 +339,7 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor {
301
339
  : 'multi-file-shared-type-file';
302
340
  const imports = {};
303
341
  for (const [scalarName, parsedScalar] of Object.entries(this.config.scalars)) {
304
- const usedScalar = this._usedSchemaTypes[scalarName];
342
+ const usedScalar = this._namedSchemaTypes[scalarName];
305
343
  if (!usedScalar || usedScalar.type !== 'GraphQLScalarType') {
306
344
  continue;
307
345
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@depup/graphql-codegen__typescript-operations",
3
- "version": "6.1.6-depup.1",
3
+ "version": "6.1.7-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": {
@@ -12,11 +12,11 @@
12
12
  "graphql-sock": "^1.0.0"
13
13
  },
14
14
  "dependencies": {
15
- "auto-bind": "^5.0.1",
16
- "tslib": "^2.8.1",
17
- "@graphql-codegen/visitor-plugin-common": "^7.2.5",
15
+ "@graphql-codegen/plugin-helpers": "^7.3.0",
18
16
  "@graphql-codegen/schema-ast": "^6.1.0",
19
- "@graphql-codegen/plugin-helpers": "^7.2.0"
17
+ "@graphql-codegen/visitor-plugin-common": "^7.2.5",
18
+ "auto-bind": "^5.0.1",
19
+ "tslib": "^2.8.1"
20
20
  },
21
21
  "repository": {
22
22
  "type": "git",
@@ -68,16 +68,12 @@
68
68
  "tslib": {
69
69
  "from": "^2.8.0",
70
70
  "to": "^2.8.1"
71
- },
72
- "@graphql-codegen/plugin-helpers": {
73
- "from": "^7.1.0",
74
- "to": "^7.2.0"
75
71
  }
76
72
  },
77
- "depsUpdated": 3,
73
+ "depsUpdated": 2,
78
74
  "originalPackage": "@graphql-codegen/typescript-operations",
79
- "originalVersion": "6.1.6",
80
- "processedAt": "2026-08-22T08:07:54.560Z",
75
+ "originalVersion": "6.1.7",
76
+ "processedAt": "2026-09-20T08:11:01.935Z",
81
77
  "smokeTest": "passed"
82
78
  }
83
79
  }
@@ -33,6 +33,16 @@ type UsedSchemaTypes = Record<string, {
33
33
  }>;
34
34
  export declare class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor<TypeScriptDocumentsPluginConfig, TypeScriptDocumentsParsedConfig> {
35
35
  protected _usedSchemaTypes: UsedSchemaTypes;
36
+ /**
37
+ * _namedSchemaTypes is a subset of _usedSchemaTypes: the schema types this file's own
38
+ * generated declarations actually name, as opposed to types merely reached through the
39
+ * document (e.g. via a fragment). Those two diverge when `inlineFragmentTypes` is `'combine'`
40
+ * or `'mask'`: a fragment spread there collapses to a bare reference to the fragment's own
41
+ * generated type (printed in whichever file defines that fragment) instead of inlining its
42
+ * fields, so a schema type selected only inside such a fragment is never named here.
43
+ * This is what should gate whether a schema-type import/declaration is actually emitted.
44
+ */
45
+ protected _namedSchemaTypes: UsedSchemaTypes;
36
46
  protected _needsExactUtilityType: boolean;
37
47
  /**
38
48
  * _usedEnumIntrospectionType is a metadata value
@@ -43,7 +53,7 @@ export declare class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor<Typ
43
53
  */
44
54
  protected _usedEnumIntrospectionType: boolean;
45
55
  private _outputPath;
46
- constructor(schema: GraphQLSchema, config: TypeScriptDocumentsPluginConfig, documentNode: DocumentNode, outputPath: string);
56
+ constructor(schema: GraphQLSchema, config: TypeScriptDocumentsPluginConfig, documentNode: DocumentNode, documentsToVisitAST: DocumentNode, outputPath: string);
47
57
  EnumTypeDefinition(node: EnumTypeDefinitionNode): string | null;
48
58
  InputObjectTypeDefinition(node: InputObjectTypeDefinitionNode): string | null;
49
59
  InputValueDefinition(node: InputValueDefinitionNode, _key?: number | string, _parent?: any, _path?: Array<string | number>, ancestors?: Array<TypeDefinitionNode>): string;
@@ -33,6 +33,16 @@ type UsedSchemaTypes = Record<string, {
33
33
  }>;
34
34
  export declare class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor<TypeScriptDocumentsPluginConfig, TypeScriptDocumentsParsedConfig> {
35
35
  protected _usedSchemaTypes: UsedSchemaTypes;
36
+ /**
37
+ * _namedSchemaTypes is a subset of _usedSchemaTypes: the schema types this file's own
38
+ * generated declarations actually name, as opposed to types merely reached through the
39
+ * document (e.g. via a fragment). Those two diverge when `inlineFragmentTypes` is `'combine'`
40
+ * or `'mask'`: a fragment spread there collapses to a bare reference to the fragment's own
41
+ * generated type (printed in whichever file defines that fragment) instead of inlining its
42
+ * fields, so a schema type selected only inside such a fragment is never named here.
43
+ * This is what should gate whether a schema-type import/declaration is actually emitted.
44
+ */
45
+ protected _namedSchemaTypes: UsedSchemaTypes;
36
46
  protected _needsExactUtilityType: boolean;
37
47
  /**
38
48
  * _usedEnumIntrospectionType is a metadata value
@@ -43,7 +53,7 @@ export declare class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor<Typ
43
53
  */
44
54
  protected _usedEnumIntrospectionType: boolean;
45
55
  private _outputPath;
46
- constructor(schema: GraphQLSchema, config: TypeScriptDocumentsPluginConfig, documentNode: DocumentNode, outputPath: string);
56
+ constructor(schema: GraphQLSchema, config: TypeScriptDocumentsPluginConfig, documentNode: DocumentNode, documentsToVisitAST: DocumentNode, outputPath: string);
47
57
  EnumTypeDefinition(node: EnumTypeDefinitionNode): string | null;
48
58
  InputObjectTypeDefinition(node: InputObjectTypeDefinitionNode): string | null;
49
59
  InputValueDefinition(node: InputValueDefinitionNode, _key?: number | string, _parent?: any, _path?: Array<string | number>, ancestors?: Array<TypeDefinitionNode>): string;