@graphql-codegen/visitor-plugin-common 5.6.1 → 5.7.0-alpha-20250219142655-325d6c9ee35a514b43d3a15c097858a5b77e4a1c

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.
@@ -22,6 +22,7 @@ class BaseVisitor {
22
22
  emitLegacyCommonJSImports: rawConfig.emitLegacyCommonJSImports === undefined ? true : !!rawConfig.emitLegacyCommonJSImports,
23
23
  extractAllFieldsToTypes: rawConfig.extractAllFieldsToTypes ?? false,
24
24
  printFieldsOnNewLines: rawConfig.printFieldsOnNewLines ?? false,
25
+ includeExternalFragments: rawConfig.includeExternalFragments ?? false,
25
26
  ...(additionalConfig || {}),
26
27
  };
27
28
  this.scalars = {};
@@ -261,7 +261,7 @@ class ClientSideBaseVisitor extends base_visitor_js_1.BaseVisitor {
261
261
  const graph = this.fragmentsGraph;
262
262
  const orderedDeps = graph.overallOrder();
263
263
  const localFragments = orderedDeps
264
- .filter(name => !graph.getNodeData(name).isExternal)
264
+ .filter(name => !graph.getNodeData(name).isExternal || this.config.includeExternalFragments)
265
265
  .map(name => this._generateFragment(graph.getNodeData(name).node));
266
266
  return localFragments.join('\n');
267
267
  }
@@ -18,6 +18,7 @@ export class BaseVisitor {
18
18
  emitLegacyCommonJSImports: rawConfig.emitLegacyCommonJSImports === undefined ? true : !!rawConfig.emitLegacyCommonJSImports,
19
19
  extractAllFieldsToTypes: rawConfig.extractAllFieldsToTypes ?? false,
20
20
  printFieldsOnNewLines: rawConfig.printFieldsOnNewLines ?? false,
21
+ includeExternalFragments: rawConfig.includeExternalFragments ?? false,
21
22
  ...(additionalConfig || {}),
22
23
  };
23
24
  this.scalars = {};
@@ -257,7 +257,7 @@ export class ClientSideBaseVisitor extends BaseVisitor {
257
257
  const graph = this.fragmentsGraph;
258
258
  const orderedDeps = graph.overallOrder();
259
259
  const localFragments = orderedDeps
260
- .filter(name => !graph.getNodeData(name).isExternal)
260
+ .filter(name => !graph.getNodeData(name).isExternal || this.config.includeExternalFragments)
261
261
  .map(name => this._generateFragment(graph.getNodeData(name).node));
262
262
  return localFragments.join('\n');
263
263
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-codegen/visitor-plugin-common",
3
- "version": "5.6.1",
3
+ "version": "5.7.0-alpha-20250219142655-325d6c9ee35a514b43d3a15c097858a5b77e4a1c",
4
4
  "peerDependencies": {
5
5
  "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
6
6
  },
@@ -24,6 +24,7 @@ export interface ParsedConfig {
24
24
  inlineFragmentTypes: InlineFragmentTypeOptions;
25
25
  emitLegacyCommonJSImports: boolean;
26
26
  printFieldsOnNewLines: boolean;
27
+ includeExternalFragments: boolean;
27
28
  }
28
29
  export interface RawConfig {
29
30
  /**
@@ -372,6 +373,12 @@ export interface RawConfig {
372
373
  * without resorting to running tools like Prettier on the output.
373
374
  */
374
375
  printFieldsOnNewLines?: boolean;
376
+ /**
377
+ * @default false
378
+ * @description Whether to include external fragments in the generated code. External fragments are not defined
379
+ * in the same location as the operation definition.
380
+ */
381
+ includeExternalFragments?: boolean;
375
382
  }
376
383
  export declare class BaseVisitor<TRawConfig extends RawConfig = RawConfig, TPluginConfig extends ParsedConfig = ParsedConfig> {
377
384
  protected _parsedConfig: TPluginConfig;
@@ -24,6 +24,7 @@ export interface ParsedConfig {
24
24
  inlineFragmentTypes: InlineFragmentTypeOptions;
25
25
  emitLegacyCommonJSImports: boolean;
26
26
  printFieldsOnNewLines: boolean;
27
+ includeExternalFragments: boolean;
27
28
  }
28
29
  export interface RawConfig {
29
30
  /**
@@ -372,6 +373,12 @@ export interface RawConfig {
372
373
  * without resorting to running tools like Prettier on the output.
373
374
  */
374
375
  printFieldsOnNewLines?: boolean;
376
+ /**
377
+ * @default false
378
+ * @description Whether to include external fragments in the generated code. External fragments are not defined
379
+ * in the same location as the operation definition.
380
+ */
381
+ includeExternalFragments?: boolean;
375
382
  }
376
383
  export declare class BaseVisitor<TRawConfig extends RawConfig = RawConfig, TPluginConfig extends ParsedConfig = ParsedConfig> {
377
384
  protected _parsedConfig: TPluginConfig;