@graphql-codegen/typescript-rtk-query 2.4.1 → 3.0.0-alpha-20230524083052-08ce957b4

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/config.js CHANGED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/cjs/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RTKQueryVisitor = 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, "RTKQueryVisitor", { enumerable: true, get: function () { return visitor_js_1.RTKQueryVisitor; } });
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 = [
@@ -34,7 +34,8 @@ const validate = async (schema, documents, config, outputFile) => {
34
34
  throw new Error(`Plugin "typescript-rtk-query" requires extension to be ".ts" or ".tsx"!`);
35
35
  }
36
36
  if (!config.importBaseApiFrom) {
37
- throw new Error(`You must specify the "importBaseApiFrom" option to use the RTK Query plugin!` + JSON.stringify(config));
37
+ throw new Error(`You must specify the "importBaseApiFrom" option to use the RTK Query plugin!` +
38
+ JSON.stringify(config));
38
39
  }
39
40
  };
40
41
  exports.validate = validate;
package/cjs/visitor.js CHANGED
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RTKQueryVisitor = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const visitor_plugin_common_1 = require("@graphql-codegen/visitor-plugin-common");
6
- const change_case_all_1 = require("change-case-all");
7
5
  const auto_bind_1 = tslib_1.__importDefault(require("auto-bind"));
6
+ const change_case_all_1 = require("change-case-all");
7
+ const visitor_plugin_common_1 = require("@graphql-codegen/visitor-plugin-common");
8
8
  class RTKQueryVisitor extends visitor_plugin_common_1.ClientSideBaseVisitor {
9
9
  constructor(schema, fragments, rawConfig, documents) {
10
10
  super(schema, fragments, rawConfig, {
@@ -17,7 +17,9 @@ class RTKQueryVisitor extends visitor_plugin_common_1.ClientSideBaseVisitor {
17
17
  this.rawConfig = rawConfig;
18
18
  this._endpoints = [];
19
19
  this._hooks = [];
20
- this._externalImportPrefix = this.config.importOperationTypesFrom ? `${this.config.importOperationTypesFrom}.` : '';
20
+ this._externalImportPrefix = this.config.importOperationTypesFrom
21
+ ? `${this.config.importOperationTypesFrom}.`
22
+ : '';
21
23
  this._documents = documents;
22
24
  (0, auto_bind_1.default)(this);
23
25
  }
@@ -52,7 +54,9 @@ const injectedRtkApi = ${this.config.importBaseApiAlternateName}.injectEndpoints
52
54
 
53
55
  export { injectedRtkApi as api };
54
56
  ` +
55
- (this.config.exportHooks ? `export const { ${this._hooks.join(', ')} } = injectedRtkApi;` : '') +
57
+ (this.config.exportHooks
58
+ ? `export const { ${this._hooks.join(', ')} } = injectedRtkApi;`
59
+ : '') +
56
60
  '\n\n');
57
61
  }
58
62
  buildOperation(node, documentVariableName, operationType, operationResultType, operationVariablesTypes, hasRequiredVariables) {
package/esm/config.js CHANGED
@@ -1 +0,0 @@
1
- export {};
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 { RTKQueryVisitor } 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 = [
@@ -29,7 +29,8 @@ export const validate = async (schema, documents, config, outputFile) => {
29
29
  throw new Error(`Plugin "typescript-rtk-query" requires extension to be ".ts" or ".tsx"!`);
30
30
  }
31
31
  if (!config.importBaseApiFrom) {
32
- throw new Error(`You must specify the "importBaseApiFrom" option to use the RTK Query plugin!` + JSON.stringify(config));
32
+ throw new Error(`You must specify the "importBaseApiFrom" option to use the RTK Query plugin!` +
33
+ JSON.stringify(config));
33
34
  }
34
35
  };
35
36
  export { RTKQueryVisitor };
package/esm/visitor.js CHANGED
@@ -1,6 +1,6 @@
1
- import { ClientSideBaseVisitor, getConfigValue, DocumentMode, } from '@graphql-codegen/visitor-plugin-common';
2
- import { pascalCase } from 'change-case-all';
3
1
  import autoBind from 'auto-bind';
2
+ import { pascalCase } from 'change-case-all';
3
+ import { ClientSideBaseVisitor, DocumentMode, getConfigValue, } from '@graphql-codegen/visitor-plugin-common';
4
4
  export class RTKQueryVisitor extends ClientSideBaseVisitor {
5
5
  constructor(schema, fragments, rawConfig, documents) {
6
6
  super(schema, fragments, rawConfig, {
@@ -13,7 +13,9 @@ export class RTKQueryVisitor extends ClientSideBaseVisitor {
13
13
  this.rawConfig = rawConfig;
14
14
  this._endpoints = [];
15
15
  this._hooks = [];
16
- this._externalImportPrefix = this.config.importOperationTypesFrom ? `${this.config.importOperationTypesFrom}.` : '';
16
+ this._externalImportPrefix = this.config.importOperationTypesFrom
17
+ ? `${this.config.importOperationTypesFrom}.`
18
+ : '';
17
19
  this._documents = documents;
18
20
  autoBind(this);
19
21
  }
@@ -48,7 +50,9 @@ const injectedRtkApi = ${this.config.importBaseApiAlternateName}.injectEndpoints
48
50
 
49
51
  export { injectedRtkApi as api };
50
52
  ` +
51
- (this.config.exportHooks ? `export const { ${this._hooks.join(', ')} } = injectedRtkApi;` : '') +
53
+ (this.config.exportHooks
54
+ ? `export const { ${this._hooks.join(', ')} } = injectedRtkApi;`
55
+ : '') +
52
56
  '\n\n');
53
57
  }
54
58
  buildOperation(node, documentVariableName, operationType, operationResultType, operationVariablesTypes, hasRequiredVariables) {
package/package.json CHANGED
@@ -1,7 +1,12 @@
1
1
  {
2
2
  "name": "@graphql-codegen/typescript-rtk-query",
3
- "version": "2.4.1",
3
+ "version": "3.0.0-alpha-20230524083052-08ce957b4",
4
4
  "description": "GraphQL Code Generator plugin for injecting graphql endpoints into a preconfigured RTK Query api",
5
+ "peerDependenciesMeta": {
6
+ "graphql-request": {
7
+ "optional": true
8
+ }
9
+ },
5
10
  "peerDependencies": {
6
11
  "@reduxjs/toolkit": "^1.6.0",
7
12
  "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",
@@ -21,6 +26,9 @@
21
26
  "directory": "packages/plugins/typescript/rtk-query"
22
27
  },
23
28
  "license": "MIT",
29
+ "engines": {
30
+ "node": ">= 16.0.0"
31
+ },
24
32
  "main": "cjs/index.js",
25
33
  "module": "esm/index.js",
26
34
  "typings": "typings/index.d.ts",
@@ -1,6 +1,6 @@
1
- import { Types, PluginValidateFn, PluginFunction } from '@graphql-codegen/plugin-helpers';
2
- import { RTKQueryVisitor } from './visitor.cjs';
1
+ import { PluginFunction, PluginValidateFn, Types } from '@graphql-codegen/plugin-helpers';
3
2
  import { RTKQueryRawPluginConfig } from './config.cjs';
3
+ import { RTKQueryVisitor } from './visitor.cjs';
4
4
  export declare const plugin: PluginFunction<RTKQueryRawPluginConfig, Types.ComplexPluginOutput>;
5
5
  export declare const validate: PluginValidateFn<any>;
6
6
  export { RTKQueryVisitor };
@@ -1,6 +1,6 @@
1
- import { Types, PluginValidateFn, PluginFunction } from '@graphql-codegen/plugin-helpers';
2
- import { RTKQueryVisitor } from './visitor.js';
1
+ import { PluginFunction, PluginValidateFn, Types } from '@graphql-codegen/plugin-helpers';
3
2
  import { RTKQueryRawPluginConfig } from './config.js';
3
+ import { RTKQueryVisitor } from './visitor.js';
4
4
  export declare const plugin: PluginFunction<RTKQueryRawPluginConfig, Types.ComplexPluginOutput>;
5
5
  export declare const validate: PluginValidateFn<any>;
6
6
  export { RTKQueryVisitor };
@@ -1,7 +1,7 @@
1
+ import { GraphQLSchema, OperationDefinitionNode } from 'graphql';
2
+ import { Types } from '@graphql-codegen/plugin-helpers';
1
3
  import { ClientSideBaseVisitor, LoadedFragment } from '@graphql-codegen/visitor-plugin-common';
2
- import { OperationDefinitionNode, GraphQLSchema } from 'graphql';
3
4
  import { RTKQueryPluginConfig, RTKQueryRawPluginConfig } from './config.cjs';
4
- import { Types } from '@graphql-codegen/plugin-helpers';
5
5
  export declare class RTKQueryVisitor extends ClientSideBaseVisitor<RTKQueryRawPluginConfig, RTKQueryPluginConfig> {
6
6
  protected rawConfig: RTKQueryRawPluginConfig;
7
7
  private _externalImportPrefix;
@@ -1,7 +1,7 @@
1
+ import { GraphQLSchema, OperationDefinitionNode } from 'graphql';
2
+ import { Types } from '@graphql-codegen/plugin-helpers';
1
3
  import { ClientSideBaseVisitor, LoadedFragment } from '@graphql-codegen/visitor-plugin-common';
2
- import { OperationDefinitionNode, GraphQLSchema } from 'graphql';
3
4
  import { RTKQueryPluginConfig, RTKQueryRawPluginConfig } from './config.js';
4
- import { Types } from '@graphql-codegen/plugin-helpers';
5
5
  export declare class RTKQueryVisitor extends ClientSideBaseVisitor<RTKQueryRawPluginConfig, RTKQueryPluginConfig> {
6
6
  protected rawConfig: RTKQueryRawPluginConfig;
7
7
  private _externalImportPrefix;