@graphql-codegen/typescript-rtk-query 2.3.7 → 2.4.0-alpha-20230201151311-c670e7d5b

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
@@ -10,6 +10,7 @@ class RTKQueryVisitor extends visitor_plugin_common_1.ClientSideBaseVisitor {
10
10
  super(schema, fragments, rawConfig, {
11
11
  documentMode: visitor_plugin_common_1.DocumentMode.string,
12
12
  importBaseApiFrom: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.importBaseApiFrom, ''),
13
+ importBaseApiAlternateName: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.importBaseApiAlternateName, 'api'),
13
14
  exportHooks: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.exportHooks, false),
14
15
  overrideExisting: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.overrideExisting, ''),
15
16
  });
@@ -31,7 +32,10 @@ class RTKQueryVisitor extends visitor_plugin_common_1.ClientSideBaseVisitor {
31
32
  if (!this.hasOperations) {
32
33
  return baseImports;
33
34
  }
34
- return [...baseImports, `import { api } from '${this.config.importBaseApiFrom}';`];
35
+ return [
36
+ ...baseImports,
37
+ `import { ${this.config.importBaseApiAlternateName} } from '${this.config.importBaseApiFrom}';`,
38
+ ];
35
39
  }
36
40
  getInjectCall() {
37
41
  if (!this.hasOperations) {
package/esm/visitor.js CHANGED
@@ -6,6 +6,7 @@ export class RTKQueryVisitor extends ClientSideBaseVisitor {
6
6
  super(schema, fragments, rawConfig, {
7
7
  documentMode: DocumentMode.string,
8
8
  importBaseApiFrom: getConfigValue(rawConfig.importBaseApiFrom, ''),
9
+ importBaseApiAlternateName: getConfigValue(rawConfig.importBaseApiAlternateName, 'api'),
9
10
  exportHooks: getConfigValue(rawConfig.exportHooks, false),
10
11
  overrideExisting: getConfigValue(rawConfig.overrideExisting, ''),
11
12
  });
@@ -27,7 +28,10 @@ export class RTKQueryVisitor extends ClientSideBaseVisitor {
27
28
  if (!this.hasOperations) {
28
29
  return baseImports;
29
30
  }
30
- return [...baseImports, `import { api } from '${this.config.importBaseApiFrom}';`];
31
+ return [
32
+ ...baseImports,
33
+ `import { ${this.config.importBaseApiAlternateName} } from '${this.config.importBaseApiFrom}';`,
34
+ ];
31
35
  }
32
36
  getInjectCall() {
33
37
  if (!this.hasOperations) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-codegen/typescript-rtk-query",
3
- "version": "2.3.7",
3
+ "version": "2.4.0-alpha-20230201151311-c670e7d5b",
4
4
  "description": "GraphQL Code Generator plugin for injecting graphql endpoints into a preconfigured RTK Query api",
5
5
  "peerDependencies": {
6
6
  "@reduxjs/toolkit": "^1.6.0",
@@ -9,15 +9,15 @@
9
9
  "graphql-tag": "^2.0.0"
10
10
  },
11
11
  "dependencies": {
12
- "@graphql-codegen/plugin-helpers": "^2.7.2",
12
+ "@graphql-codegen/plugin-helpers": "^3.0.0",
13
13
  "@graphql-codegen/visitor-plugin-common": "2.13.1",
14
14
  "auto-bind": "~4.0.0",
15
- "change-case-all": "1.0.14",
15
+ "change-case-all": "1.0.15",
16
16
  "tslib": "~2.4.0"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",
20
- "url": "https://github.com/dotansimha/graphql-code-generator.git",
20
+ "url": "https://github.com/dotansimha/graphql-code-generator-community.git",
21
21
  "directory": "packages/plugins/typescript/rtk-query"
22
22
  },
23
23
  "license": "MIT",
@@ -23,6 +23,32 @@ export interface RTKConfig {
23
23
  * ```
24
24
  */
25
25
  importBaseApiFrom: string;
26
+ /**
27
+ * @name importBaseApiAlternateName
28
+ * @description Change the import name of the baseApi from default 'api'
29
+ * @default 'api'
30
+ *
31
+
32
+ * @exampleMarkdown
33
+ * ```ts filename="codegen.ts"
34
+ * import type { CodegenConfig } from '@graphql-codegen/cli';
35
+ *
36
+ * const config: CodegenConfig = {
37
+ * // ...
38
+ * generates: {
39
+ * 'path/to/file.ts': {
40
+ * plugins: ['typescript', 'typescript-resolvers', 'typescript-rtk-query'],
41
+ * config: {
42
+ * importBaseApiFrom: 'src/app/api/baseApi',
43
+ * importBaseApiAlternateName: 'alternateApiName'
44
+ * },
45
+ * },
46
+ * },
47
+ * };
48
+ * export default config;
49
+ * ```
50
+ */
51
+ importBaseApiAlternateName?: string;
26
52
  /**
27
53
  * @name exportHooks
28
54
  * @description Whether to export React Hooks from the generated api. Enable only when using the `"@reduxjs/toolkit/query/react"` import of `createApi`
@@ -23,6 +23,32 @@ export interface RTKConfig {
23
23
  * ```
24
24
  */
25
25
  importBaseApiFrom: string;
26
+ /**
27
+ * @name importBaseApiAlternateName
28
+ * @description Change the import name of the baseApi from default 'api'
29
+ * @default 'api'
30
+ *
31
+
32
+ * @exampleMarkdown
33
+ * ```ts filename="codegen.ts"
34
+ * import type { CodegenConfig } from '@graphql-codegen/cli';
35
+ *
36
+ * const config: CodegenConfig = {
37
+ * // ...
38
+ * generates: {
39
+ * 'path/to/file.ts': {
40
+ * plugins: ['typescript', 'typescript-resolvers', 'typescript-rtk-query'],
41
+ * config: {
42
+ * importBaseApiFrom: 'src/app/api/baseApi',
43
+ * importBaseApiAlternateName: 'alternateApiName'
44
+ * },
45
+ * },
46
+ * },
47
+ * };
48
+ * export default config;
49
+ * ```
50
+ */
51
+ importBaseApiAlternateName?: string;
26
52
  /**
27
53
  * @name exportHooks
28
54
  * @description Whether to export React Hooks from the generated api. Enable only when using the `"@reduxjs/toolkit/query/react"` import of `createApi`