@graphql-codegen/typescript-graphql-request 7.0.1 → 8.0.0-alpha-20261012120400-2358670988a7da1bc5635a0119ecc3effc2ae723

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
@@ -11,15 +11,22 @@ export type SdkFunctionWrapper = <T>(action: (requestHeaders?:Record<string, str
11
11
  class GraphQLRequestVisitor extends visitor_plugin_common_1.ClientSideBaseVisitor {
12
12
  constructor(schema, fragments, rawConfig) {
13
13
  super(schema, fragments, rawConfig, {
14
+ ...(rawConfig.documentMode === visitor_plugin_common_1.DocumentMode.string
15
+ ? { documentMode: visitor_plugin_common_1.DocumentMode.plainString }
16
+ : {}),
14
17
  rawRequest: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.rawRequest, false),
15
18
  extensionsType: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.extensionsType, 'any'),
16
19
  });
17
20
  this._operationsToInclude = [];
18
21
  (0, auto_bind_1.default)(this);
19
- const typeImport = this.config.useTypeImports ? 'import type' : 'import';
20
- this._additionalImports.push(`${typeImport} { GraphQLClient, RequestOptions } from 'graphql-request';`);
22
+ if (rawConfig.documentMode === visitor_plugin_common_1.DocumentMode.string) {
23
+ // eslint-disable-next-line no-console
24
+ console.warn("[typescript-graphql-request] documentMode: 'string' does not work with this plugin (it references an undeclared TypedDocumentString), and has been remapped to 'plainString' for correctness. Set documentMode: 'plainString' to silence this warning.");
25
+ }
26
+ const typeImport = this.config.useTypeImports ? 'type ' : '';
27
+ this._additionalImports.push(`import { ${typeImport}GraphQLClient, type RequestOptions } from 'graphql-request';`);
21
28
  if (this.config.rawRequest) {
22
- if (this.config.documentMode !== visitor_plugin_common_1.DocumentMode.string) {
29
+ if (this.config.documentMode !== visitor_plugin_common_1.DocumentMode.plainString) {
23
30
  this._additionalImports.push(`import { GraphQLError, print } from 'graphql'`);
24
31
  }
25
32
  else {
@@ -71,7 +78,7 @@ class GraphQLRequestVisitor extends visitor_plugin_common_1.ClientSideBaseVisito
71
78
  const docVarName = this.getDocumentNodeVariable(o.documentVariableName);
72
79
  if (this.config.rawRequest) {
73
80
  let docArg = docVarName;
74
- if (this.config.documentMode !== visitor_plugin_common_1.DocumentMode.string) {
81
+ if (this.config.documentMode !== visitor_plugin_common_1.DocumentMode.plainString) {
75
82
  docArg = `${docVarName}String`;
76
83
  extraVariables.push(`const ${docArg} = print(${docVarName});`);
77
84
  }
package/esm/visitor.js CHANGED
@@ -7,15 +7,22 @@ export type SdkFunctionWrapper = <T>(action: (requestHeaders?:Record<string, str
7
7
  export class GraphQLRequestVisitor extends ClientSideBaseVisitor {
8
8
  constructor(schema, fragments, rawConfig) {
9
9
  super(schema, fragments, rawConfig, {
10
+ ...(rawConfig.documentMode === DocumentMode.string
11
+ ? { documentMode: DocumentMode.plainString }
12
+ : {}),
10
13
  rawRequest: getConfigValue(rawConfig.rawRequest, false),
11
14
  extensionsType: getConfigValue(rawConfig.extensionsType, 'any'),
12
15
  });
13
16
  this._operationsToInclude = [];
14
17
  autoBind(this);
15
- const typeImport = this.config.useTypeImports ? 'import type' : 'import';
16
- this._additionalImports.push(`${typeImport} { GraphQLClient, RequestOptions } from 'graphql-request';`);
18
+ if (rawConfig.documentMode === DocumentMode.string) {
19
+ // eslint-disable-next-line no-console
20
+ console.warn("[typescript-graphql-request] documentMode: 'string' does not work with this plugin (it references an undeclared TypedDocumentString), and has been remapped to 'plainString' for correctness. Set documentMode: 'plainString' to silence this warning.");
21
+ }
22
+ const typeImport = this.config.useTypeImports ? 'type ' : '';
23
+ this._additionalImports.push(`import { ${typeImport}GraphQLClient, type RequestOptions } from 'graphql-request';`);
17
24
  if (this.config.rawRequest) {
18
- if (this.config.documentMode !== DocumentMode.string) {
25
+ if (this.config.documentMode !== DocumentMode.plainString) {
19
26
  this._additionalImports.push(`import { GraphQLError, print } from 'graphql'`);
20
27
  }
21
28
  else {
@@ -67,7 +74,7 @@ export class GraphQLRequestVisitor extends ClientSideBaseVisitor {
67
74
  const docVarName = this.getDocumentNodeVariable(o.documentVariableName);
68
75
  if (this.config.rawRequest) {
69
76
  let docArg = docVarName;
70
- if (this.config.documentMode !== DocumentMode.string) {
77
+ if (this.config.documentMode !== DocumentMode.plainString) {
71
78
  docArg = `${docVarName}String`;
72
79
  extraVariables.push(`const ${docArg} = print(${docVarName});`);
73
80
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-codegen/typescript-graphql-request",
3
- "version": "7.0.1",
3
+ "version": "8.0.0-alpha-20261012120400-2358670988a7da1bc5635a0119ecc3effc2ae723",
4
4
  "description": "GraphQL Code Generator plugin for generating a ready-to-use SDK based on graphql-request and GraphQL operations",
5
5
  "peerDependencies": {
6
6
  "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",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "dependencies": {
11
11
  "@graphql-codegen/plugin-helpers": "^6.3.0",
12
- "@graphql-codegen/visitor-plugin-common": "^6.3.0",
12
+ "@graphql-codegen/visitor-plugin-common": "^7.3.0",
13
13
  "auto-bind": "~4.0.0",
14
14
  "tslib": "^2.8.1"
15
15
  },