@graphql-codegen/typescript-graphql-request 4.6.0-alpha-20220922145742-1e7fe329a → 5.0.0-alpha-20230518131850-e3b2bc819

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/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GraphQLRequestVisitor = exports.validate = exports.plugin = void 0;
4
- const plugin_helpers_1 = require("@graphql-codegen/plugin-helpers");
4
+ const path_1 = require("path");
5
5
  const graphql_1 = require("graphql");
6
+ const plugin_helpers_1 = require("@graphql-codegen/plugin-helpers");
6
7
  const visitor_js_1 = require("./visitor.js");
7
8
  Object.defineProperty(exports, "GraphQLRequestVisitor", { enumerable: true, get: function () { return visitor_js_1.GraphQLRequestVisitor; } });
8
- const path_1 = require("path");
9
9
  const plugin = (schema, documents, config) => {
10
10
  const allAst = (0, graphql_1.concatAST)(documents.map(v => v.document));
11
11
  const allFragments = [
package/cjs/visitor.js CHANGED
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GraphQLRequestVisitor = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const visitor_plugin_common_1 = require("@graphql-codegen/visitor-plugin-common");
6
5
  const auto_bind_1 = tslib_1.__importDefault(require("auto-bind"));
7
6
  const graphql_1 = require("graphql");
7
+ const visitor_plugin_common_1 = require("@graphql-codegen/visitor-plugin-common");
8
8
  const additionalExportedTypes = `
9
9
  export type SdkFunctionWrapper = <T>(action: (requestHeaders?:Record<string, string>) => Promise<T>, operationName: string, operationType?: string) => Promise<T>;
10
10
  `;
@@ -18,12 +18,15 @@ class GraphQLRequestVisitor extends visitor_plugin_common_1.ClientSideBaseVisito
18
18
  (0, auto_bind_1.default)(this);
19
19
  const typeImport = this.config.useTypeImports ? 'import type' : 'import';
20
20
  const fileExtension = this.config.emitLegacyCommonJSImports ? '' : '.js';
21
+ const buildPath = this.config.emitLegacyCommonJSImports ? 'cjs' : 'esm';
21
22
  this._additionalImports.push(`${typeImport} { GraphQLClient } from 'graphql-request';`);
22
- this._additionalImports.push(`${typeImport} * as Dom from 'graphql-request/dist/types.dom${fileExtension}';`);
23
+ this._additionalImports.push(`${typeImport} { GraphQLClientRequestHeaders } from 'graphql-request/build/${buildPath}/types${fileExtension}';`);
23
24
  if (this.config.rawRequest && this.config.documentMode !== visitor_plugin_common_1.DocumentMode.string) {
24
25
  this._additionalImports.push(`import { print } from 'graphql'`);
25
26
  }
26
- this._externalImportPrefix = this.config.importOperationTypesFrom ? `${this.config.importOperationTypesFrom}.` : '';
27
+ this._externalImportPrefix = this.config.importOperationTypesFrom
28
+ ? `${this.config.importOperationTypesFrom}.`
29
+ : '';
27
30
  }
28
31
  OperationDefinition(node) {
29
32
  var _a;
@@ -68,11 +71,11 @@ class GraphQLRequestVisitor extends visitor_plugin_common_1.ClientSideBaseVisito
68
71
  docArg = `${docVarName}String`;
69
72
  extraVariables.push(`const ${docArg} = print(${docVarName});`);
70
73
  }
71
- return `${operationName}(variables${optionalVariables ? '?' : ''}: ${o.operationVariablesTypes}, requestHeaders?: Dom.RequestInit["headers"]): Promise<{ data: ${o.operationResultType}; extensions?: ${this.config.extensionsType}; headers: Dom.Headers; status: number; }> {
74
+ return `${operationName}(variables${optionalVariables ? '?' : ''}: ${o.operationVariablesTypes}, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: ${o.operationResultType}; extensions?: ${this.config.extensionsType}; headers: Dom.Headers; status: number; }> {
72
75
  return withWrapper((wrappedRequestHeaders) => client.rawRequest<${o.operationResultType}>(${docArg}, variables, {...requestHeaders, ...wrappedRequestHeaders}), '${operationName}', '${operationType}');
73
76
  }`;
74
77
  }
75
- return `${operationName}(variables${optionalVariables ? '?' : ''}: ${o.operationVariablesTypes}, requestHeaders?: Dom.RequestInit["headers"]): Promise<${o.operationResultType}> {
78
+ return `${operationName}(variables${optionalVariables ? '?' : ''}: ${o.operationVariablesTypes}, requestHeaders?: GraphQLClientRequestHeaders): Promise<${o.operationResultType}> {
76
79
  return withWrapper((wrappedRequestHeaders) => client.request<${o.operationResultType}>(${docVarName}, variables, {...requestHeaders, ...wrappedRequestHeaders}), '${operationName}', '${operationType}');
77
80
  }`;
78
81
  })
package/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { oldVisit } from '@graphql-codegen/plugin-helpers';
1
+ import { extname } from 'path';
2
2
  import { concatAST, Kind } from 'graphql';
3
+ import { oldVisit } from '@graphql-codegen/plugin-helpers';
3
4
  import { GraphQLRequestVisitor } from './visitor.js';
4
- import { extname } from 'path';
5
5
  export const plugin = (schema, documents, config) => {
6
6
  const allAst = concatAST(documents.map(v => v.document));
7
7
  const allFragments = [
package/esm/visitor.js CHANGED
@@ -1,6 +1,6 @@
1
- import { ClientSideBaseVisitor, DocumentMode, getConfigValue, indentMultiline, } from '@graphql-codegen/visitor-plugin-common';
2
1
  import autoBind from 'auto-bind';
3
2
  import { Kind, print } from 'graphql';
3
+ import { ClientSideBaseVisitor, DocumentMode, getConfigValue, indentMultiline, } from '@graphql-codegen/visitor-plugin-common';
4
4
  const additionalExportedTypes = `
5
5
  export type SdkFunctionWrapper = <T>(action: (requestHeaders?:Record<string, string>) => Promise<T>, operationName: string, operationType?: string) => Promise<T>;
6
6
  `;
@@ -14,12 +14,15 @@ export class GraphQLRequestVisitor extends ClientSideBaseVisitor {
14
14
  autoBind(this);
15
15
  const typeImport = this.config.useTypeImports ? 'import type' : 'import';
16
16
  const fileExtension = this.config.emitLegacyCommonJSImports ? '' : '.js';
17
+ const buildPath = this.config.emitLegacyCommonJSImports ? 'cjs' : 'esm';
17
18
  this._additionalImports.push(`${typeImport} { GraphQLClient } from 'graphql-request';`);
18
- this._additionalImports.push(`${typeImport} * as Dom from 'graphql-request/dist/types.dom${fileExtension}';`);
19
+ this._additionalImports.push(`${typeImport} { GraphQLClientRequestHeaders } from 'graphql-request/build/${buildPath}/types${fileExtension}';`);
19
20
  if (this.config.rawRequest && this.config.documentMode !== DocumentMode.string) {
20
21
  this._additionalImports.push(`import { print } from 'graphql'`);
21
22
  }
22
- this._externalImportPrefix = this.config.importOperationTypesFrom ? `${this.config.importOperationTypesFrom}.` : '';
23
+ this._externalImportPrefix = this.config.importOperationTypesFrom
24
+ ? `${this.config.importOperationTypesFrom}.`
25
+ : '';
23
26
  }
24
27
  OperationDefinition(node) {
25
28
  var _a;
@@ -64,11 +67,11 @@ export class GraphQLRequestVisitor extends ClientSideBaseVisitor {
64
67
  docArg = `${docVarName}String`;
65
68
  extraVariables.push(`const ${docArg} = print(${docVarName});`);
66
69
  }
67
- return `${operationName}(variables${optionalVariables ? '?' : ''}: ${o.operationVariablesTypes}, requestHeaders?: Dom.RequestInit["headers"]): Promise<{ data: ${o.operationResultType}; extensions?: ${this.config.extensionsType}; headers: Dom.Headers; status: number; }> {
70
+ return `${operationName}(variables${optionalVariables ? '?' : ''}: ${o.operationVariablesTypes}, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: ${o.operationResultType}; extensions?: ${this.config.extensionsType}; headers: Dom.Headers; status: number; }> {
68
71
  return withWrapper((wrappedRequestHeaders) => client.rawRequest<${o.operationResultType}>(${docArg}, variables, {...requestHeaders, ...wrappedRequestHeaders}), '${operationName}', '${operationType}');
69
72
  }`;
70
73
  }
71
- return `${operationName}(variables${optionalVariables ? '?' : ''}: ${o.operationVariablesTypes}, requestHeaders?: Dom.RequestInit["headers"]): Promise<${o.operationResultType}> {
74
+ return `${operationName}(variables${optionalVariables ? '?' : ''}: ${o.operationVariablesTypes}, requestHeaders?: GraphQLClientRequestHeaders): Promise<${o.operationResultType}> {
72
75
  return withWrapper((wrappedRequestHeaders) => client.request<${o.operationResultType}>(${docVarName}, variables, {...requestHeaders, ...wrappedRequestHeaders}), '${operationName}', '${operationType}');
73
76
  }`;
74
77
  })
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "@graphql-codegen/typescript-graphql-request",
3
- "version": "4.6.0-alpha-20220922145742-1e7fe329a",
3
+ "version": "5.0.0-alpha-20230518131850-e3b2bc819",
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",
7
- "graphql-request": "^3.4.0 || ^4.0.0 || ^5.0.0",
7
+ "graphql-request": "^6.0.0",
8
8
  "graphql-tag": "^2.0.0"
9
9
  },
10
10
  "dependencies": {
11
- "@graphql-codegen/plugin-helpers": "^2.7.1",
12
- "@graphql-codegen/visitor-plugin-common": "2.12.1",
11
+ "@graphql-codegen/plugin-helpers": "^3.0.0",
12
+ "@graphql-codegen/visitor-plugin-common": "2.13.1",
13
13
  "auto-bind": "~4.0.0",
14
14
  "tslib": "~2.4.0"
15
15
  },
16
16
  "repository": {
17
17
  "type": "git",
18
- "url": "https://github.com/dotansimha/graphql-code-generator.git",
18
+ "url": "https://github.com/dotansimha/graphql-code-generator-community.git",
19
19
  "directory": "packages/plugins/typescript/graphql-request"
20
20
  },
21
21
  "license": "MIT",
@@ -8,15 +8,21 @@ export interface RawGraphQLRequestPluginConfig extends RawClientSideBasePluginCo
8
8
  * @default false
9
9
  *
10
10
  * @exampleMarkdown
11
- * ```yaml
12
- * generates:
13
- * path/to/file.ts:
14
- * plugins:
15
- * - typescript
16
- * - typescript-operations
17
- * - typescript-graphql-request
18
- * config:
19
- * rawRequest: true
11
+ * ```ts filename="codegen.ts"
12
+ * import type { CodegenConfig } from '@graphql-codegen/cli';
13
+ *
14
+ * const config: CodegenConfig = {
15
+ * // ...
16
+ * generates: {
17
+ * 'path/to/file.ts': {
18
+ * plugins: ['typescript', 'typescript-operations', 'typescript-graphql-request'],
19
+ * config: {
20
+ * rawRequest: true
21
+ * },
22
+ * },
23
+ * },
24
+ * };
25
+ * export default config;
20
26
  * ```
21
27
  */
22
28
  rawRequest?: boolean;
@@ -25,10 +31,22 @@ export interface RawGraphQLRequestPluginConfig extends RawClientSideBasePluginCo
25
31
  * @default any
26
32
  *
27
33
  * @exampleMarkdown
28
- * ```yaml
29
- * config:
30
- * rawRequest: true
31
- * extensionsType: unknown
34
+ * ```ts filename="codegen.ts"
35
+ * import type { CodegenConfig } from '@graphql-codegen/cli';
36
+ *
37
+ * const config: CodegenConfig = {
38
+ * // ...
39
+ * generates: {
40
+ * 'path/to/file.ts': {
41
+ * plugins: ['typescript', 'typescript-operations', 'typescript-graphql-request'],
42
+ * config: {
43
+ * rawRequest: true,
44
+ * extensionsType: 'unknown'
45
+ * },
46
+ * },
47
+ * },
48
+ * };
49
+ * export default config;
32
50
  * ```
33
51
  */
34
52
  extensionsType?: string;
@@ -8,15 +8,21 @@ export interface RawGraphQLRequestPluginConfig extends RawClientSideBasePluginCo
8
8
  * @default false
9
9
  *
10
10
  * @exampleMarkdown
11
- * ```yaml
12
- * generates:
13
- * path/to/file.ts:
14
- * plugins:
15
- * - typescript
16
- * - typescript-operations
17
- * - typescript-graphql-request
18
- * config:
19
- * rawRequest: true
11
+ * ```ts filename="codegen.ts"
12
+ * import type { CodegenConfig } from '@graphql-codegen/cli';
13
+ *
14
+ * const config: CodegenConfig = {
15
+ * // ...
16
+ * generates: {
17
+ * 'path/to/file.ts': {
18
+ * plugins: ['typescript', 'typescript-operations', 'typescript-graphql-request'],
19
+ * config: {
20
+ * rawRequest: true
21
+ * },
22
+ * },
23
+ * },
24
+ * };
25
+ * export default config;
20
26
  * ```
21
27
  */
22
28
  rawRequest?: boolean;
@@ -25,10 +31,22 @@ export interface RawGraphQLRequestPluginConfig extends RawClientSideBasePluginCo
25
31
  * @default any
26
32
  *
27
33
  * @exampleMarkdown
28
- * ```yaml
29
- * config:
30
- * rawRequest: true
31
- * extensionsType: unknown
34
+ * ```ts filename="codegen.ts"
35
+ * import type { CodegenConfig } from '@graphql-codegen/cli';
36
+ *
37
+ * const config: CodegenConfig = {
38
+ * // ...
39
+ * generates: {
40
+ * 'path/to/file.ts': {
41
+ * plugins: ['typescript', 'typescript-operations', 'typescript-graphql-request'],
42
+ * config: {
43
+ * rawRequest: true,
44
+ * extensionsType: 'unknown'
45
+ * },
46
+ * },
47
+ * },
48
+ * };
49
+ * export default config;
32
50
  * ```
33
51
  */
34
52
  extensionsType?: string;
@@ -1,6 +1,6 @@
1
- import { PluginValidateFn, PluginFunction } from '@graphql-codegen/plugin-helpers';
2
- import { GraphQLRequestVisitor } from './visitor.cjs';
1
+ import { PluginFunction, PluginValidateFn } from '@graphql-codegen/plugin-helpers';
3
2
  import { RawGraphQLRequestPluginConfig } from './config.cjs';
3
+ import { GraphQLRequestVisitor } from './visitor.cjs';
4
4
  export declare const plugin: PluginFunction<RawGraphQLRequestPluginConfig>;
5
5
  export declare const validate: PluginValidateFn<any>;
6
6
  export { GraphQLRequestVisitor };
@@ -1,6 +1,6 @@
1
- import { PluginValidateFn, PluginFunction } from '@graphql-codegen/plugin-helpers';
2
- import { GraphQLRequestVisitor } from './visitor.js';
1
+ import { PluginFunction, PluginValidateFn } from '@graphql-codegen/plugin-helpers';
3
2
  import { RawGraphQLRequestPluginConfig } from './config.js';
3
+ import { GraphQLRequestVisitor } from './visitor.js';
4
4
  export declare const plugin: PluginFunction<RawGraphQLRequestPluginConfig>;
5
5
  export declare const validate: PluginValidateFn<any>;
6
6
  export { GraphQLRequestVisitor };
@@ -1,5 +1,5 @@
1
- import { ClientSideBasePluginConfig, ClientSideBaseVisitor, LoadedFragment } from '@graphql-codegen/visitor-plugin-common';
2
1
  import { GraphQLSchema, OperationDefinitionNode } from 'graphql';
2
+ import { ClientSideBasePluginConfig, ClientSideBaseVisitor, LoadedFragment } from '@graphql-codegen/visitor-plugin-common';
3
3
  import { RawGraphQLRequestPluginConfig } from './config.cjs';
4
4
  export interface GraphQLRequestPluginConfig extends ClientSideBasePluginConfig {
5
5
  rawRequest: boolean;
@@ -1,5 +1,5 @@
1
- import { ClientSideBasePluginConfig, ClientSideBaseVisitor, LoadedFragment } from '@graphql-codegen/visitor-plugin-common';
2
1
  import { GraphQLSchema, OperationDefinitionNode } from 'graphql';
2
+ import { ClientSideBasePluginConfig, ClientSideBaseVisitor, LoadedFragment } from '@graphql-codegen/visitor-plugin-common';
3
3
  import { RawGraphQLRequestPluginConfig } from './config.js';
4
4
  export interface GraphQLRequestPluginConfig extends ClientSideBasePluginConfig {
5
5
  rawRequest: boolean;