@graphql-codegen/typescript-graphql-request 6.1.0 → 6.2.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/cjs/visitor.js +3 -5
- package/esm/visitor.js +3 -5
- package/package.json +1 -1
package/cjs/visitor.js
CHANGED
|
@@ -17,10 +17,7 @@ class GraphQLRequestVisitor extends visitor_plugin_common_1.ClientSideBaseVisito
|
|
|
17
17
|
this._operationsToInclude = [];
|
|
18
18
|
(0, auto_bind_1.default)(this);
|
|
19
19
|
const typeImport = this.config.useTypeImports ? 'import type' : 'import';
|
|
20
|
-
|
|
21
|
-
const buildPath = this.config.emitLegacyCommonJSImports ? 'cjs' : 'esm';
|
|
22
|
-
this._additionalImports.push(`${typeImport} { GraphQLClient } from 'graphql-request';`);
|
|
23
|
-
this._additionalImports.push(`${typeImport} { GraphQLClientRequestHeaders } from 'graphql-request/build/${buildPath}/types${fileExtension}';`);
|
|
20
|
+
this._additionalImports.push(`${typeImport} { GraphQLClient, RequestOptions } from 'graphql-request';`);
|
|
24
21
|
if (this.config.rawRequest) {
|
|
25
22
|
if (this.config.documentMode !== visitor_plugin_common_1.DocumentMode.string) {
|
|
26
23
|
this._additionalImports.push(`import { GraphQLError, print } from 'graphql'`);
|
|
@@ -29,6 +26,7 @@ class GraphQLRequestVisitor extends visitor_plugin_common_1.ClientSideBaseVisito
|
|
|
29
26
|
this._additionalImports.push(`import { GraphQLError } from 'graphql'`);
|
|
30
27
|
}
|
|
31
28
|
}
|
|
29
|
+
this._additionalImports.push(`type GraphQLClientRequestHeaders = RequestOptions['requestHeaders'];`);
|
|
32
30
|
this._externalImportPrefix = this.config.importOperationTypesFrom
|
|
33
31
|
? `${this.config.importOperationTypesFrom}.`
|
|
34
32
|
: '';
|
|
@@ -88,7 +86,7 @@ class GraphQLRequestVisitor extends visitor_plugin_common_1.ClientSideBaseVisito
|
|
|
88
86
|
.map(s => (0, visitor_plugin_common_1.indentMultiline)(s, 2));
|
|
89
87
|
return `${additionalExportedTypes}
|
|
90
88
|
|
|
91
|
-
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType,
|
|
89
|
+
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, _variables) => action();
|
|
92
90
|
${extraVariables.join('\n')}
|
|
93
91
|
export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) {
|
|
94
92
|
return {
|
package/esm/visitor.js
CHANGED
|
@@ -13,10 +13,7 @@ export class GraphQLRequestVisitor extends ClientSideBaseVisitor {
|
|
|
13
13
|
this._operationsToInclude = [];
|
|
14
14
|
autoBind(this);
|
|
15
15
|
const typeImport = this.config.useTypeImports ? 'import type' : 'import';
|
|
16
|
-
|
|
17
|
-
const buildPath = this.config.emitLegacyCommonJSImports ? 'cjs' : 'esm';
|
|
18
|
-
this._additionalImports.push(`${typeImport} { GraphQLClient } from 'graphql-request';`);
|
|
19
|
-
this._additionalImports.push(`${typeImport} { GraphQLClientRequestHeaders } from 'graphql-request/build/${buildPath}/types${fileExtension}';`);
|
|
16
|
+
this._additionalImports.push(`${typeImport} { GraphQLClient, RequestOptions } from 'graphql-request';`);
|
|
20
17
|
if (this.config.rawRequest) {
|
|
21
18
|
if (this.config.documentMode !== DocumentMode.string) {
|
|
22
19
|
this._additionalImports.push(`import { GraphQLError, print } from 'graphql'`);
|
|
@@ -25,6 +22,7 @@ export class GraphQLRequestVisitor extends ClientSideBaseVisitor {
|
|
|
25
22
|
this._additionalImports.push(`import { GraphQLError } from 'graphql'`);
|
|
26
23
|
}
|
|
27
24
|
}
|
|
25
|
+
this._additionalImports.push(`type GraphQLClientRequestHeaders = RequestOptions['requestHeaders'];`);
|
|
28
26
|
this._externalImportPrefix = this.config.importOperationTypesFrom
|
|
29
27
|
? `${this.config.importOperationTypesFrom}.`
|
|
30
28
|
: '';
|
|
@@ -84,7 +82,7 @@ export class GraphQLRequestVisitor extends ClientSideBaseVisitor {
|
|
|
84
82
|
.map(s => indentMultiline(s, 2));
|
|
85
83
|
return `${additionalExportedTypes}
|
|
86
84
|
|
|
87
|
-
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType,
|
|
85
|
+
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, _variables) => action();
|
|
88
86
|
${extraVariables.join('\n')}
|
|
89
87
|
export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) {
|
|
90
88
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/typescript-graphql-request",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
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",
|