@graphql-codegen/typescript-rtk-query 2.3.3-alpha-0814e49cc.0 → 2.3.3
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/package.json +4 -4
- package/typings/config.d.cts +64 -0
- package/typings/index.d.cts +6 -0
- package/typings/visitor.d.cts +16 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/typescript-rtk-query",
|
|
3
|
-
"version": "2.3.3
|
|
3
|
+
"version": "2.3.3",
|
|
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,8 +9,8 @@
|
|
|
9
9
|
"graphql-tag": "^2.0.0"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@graphql-codegen/plugin-helpers": "^2.6.
|
|
13
|
-
"@graphql-codegen/visitor-plugin-common": "2.12.1
|
|
12
|
+
"@graphql-codegen/plugin-helpers": "^2.6.2",
|
|
13
|
+
"@graphql-codegen/visitor-plugin-common": "2.12.1",
|
|
14
14
|
"auto-bind": "~4.0.0",
|
|
15
15
|
"change-case-all": "1.0.14",
|
|
16
16
|
"tslib": "~2.4.0"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"exports": {
|
|
32
32
|
".": {
|
|
33
33
|
"require": {
|
|
34
|
-
"types": "./typings/index.d.
|
|
34
|
+
"types": "./typings/index.d.cts",
|
|
35
35
|
"default": "./cjs/index.js"
|
|
36
36
|
},
|
|
37
37
|
"import": {
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ClientSideBasePluginConfig, RawClientSideBasePluginConfig } from '@graphql-codegen/visitor-plugin-common';
|
|
2
|
+
export interface RTKConfig {
|
|
3
|
+
/**
|
|
4
|
+
* @name importBaseApiFrom
|
|
5
|
+
* @description Define where to import the base api to inject endpoints into
|
|
6
|
+
*
|
|
7
|
+
* @exampleMarkdown
|
|
8
|
+
* ```yaml
|
|
9
|
+
* generates:
|
|
10
|
+
* ./src/app/api/generated.ts:
|
|
11
|
+
* plugins:
|
|
12
|
+
* - typescript
|
|
13
|
+
* - typescript-operations
|
|
14
|
+
* - typescript-rtk-query:
|
|
15
|
+
* importBaseApiFrom: 'src/app/api/baseApi'
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
importBaseApiFrom: string;
|
|
19
|
+
/**
|
|
20
|
+
* @name exportHooks
|
|
21
|
+
* @description Whether to export React Hooks from the generated api. Enable only when using the `"@reduxjs/toolkit/query/react"` import of `createApi`
|
|
22
|
+
* @default false
|
|
23
|
+
*
|
|
24
|
+
|
|
25
|
+
* @exampleMarkdown
|
|
26
|
+
* ```yaml
|
|
27
|
+
* generates:
|
|
28
|
+
* ./src/app/api/generated.ts:
|
|
29
|
+
* plugins:
|
|
30
|
+
* - typescript
|
|
31
|
+
* - typescript-operations
|
|
32
|
+
* - typescript-rtk-query:
|
|
33
|
+
* importBaseApiFrom: 'src/app/api/baseApi'
|
|
34
|
+
* exportHooks: true
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
exportHooks?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* @name overrideExisting
|
|
40
|
+
* @description Sets the `overrideExisting` option, for example to allow for hot module reloading when running graphql-codegen in watch mode.
|
|
41
|
+
* Will directly be injected as code.
|
|
42
|
+
* @default undefined
|
|
43
|
+
*
|
|
44
|
+
|
|
45
|
+
* @exampleMarkdown
|
|
46
|
+
* ```yaml
|
|
47
|
+
* generates:
|
|
48
|
+
* ./src/app/api/generated.ts:
|
|
49
|
+
* plugins:
|
|
50
|
+
* - add:
|
|
51
|
+
* content: 'module.hot?.accept();'
|
|
52
|
+
* - typescript
|
|
53
|
+
* - typescript-operations
|
|
54
|
+
* - typescript-rtk-query:
|
|
55
|
+
* importBaseApiFrom: 'src/app/api/baseApi'
|
|
56
|
+
* overrideExisting: 'module.hot?.status() === "apply"'
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
overrideExisting?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface RTKQueryRawPluginConfig extends RawClientSideBasePluginConfig, RTKConfig {
|
|
62
|
+
}
|
|
63
|
+
export interface RTKQueryPluginConfig extends ClientSideBasePluginConfig, RTKConfig {
|
|
64
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Types, PluginValidateFn, PluginFunction } from '@graphql-codegen/plugin-helpers';
|
|
2
|
+
import { RTKQueryVisitor } from './visitor.cjs';
|
|
3
|
+
import { RTKQueryRawPluginConfig } from './config.cjs';
|
|
4
|
+
export declare const plugin: PluginFunction<RTKQueryRawPluginConfig, Types.ComplexPluginOutput>;
|
|
5
|
+
export declare const validate: PluginValidateFn<any>;
|
|
6
|
+
export { RTKQueryVisitor };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ClientSideBaseVisitor, LoadedFragment } from '@graphql-codegen/visitor-plugin-common';
|
|
2
|
+
import { OperationDefinitionNode, GraphQLSchema } from 'graphql';
|
|
3
|
+
import { RTKQueryPluginConfig, RTKQueryRawPluginConfig } from './config.cjs';
|
|
4
|
+
import { Types } from '@graphql-codegen/plugin-helpers';
|
|
5
|
+
export declare class RTKQueryVisitor extends ClientSideBaseVisitor<RTKQueryRawPluginConfig, RTKQueryPluginConfig> {
|
|
6
|
+
protected rawConfig: RTKQueryRawPluginConfig;
|
|
7
|
+
private _externalImportPrefix;
|
|
8
|
+
private _endpoints;
|
|
9
|
+
private _hooks;
|
|
10
|
+
constructor(schema: GraphQLSchema, fragments: LoadedFragment[], rawConfig: RTKQueryRawPluginConfig, documents: Types.DocumentFile[]);
|
|
11
|
+
get imports(): Set<string>;
|
|
12
|
+
get hasOperations(): boolean;
|
|
13
|
+
getImports(): string[];
|
|
14
|
+
getInjectCall(): string;
|
|
15
|
+
protected buildOperation(node: OperationDefinitionNode, documentVariableName: string, operationType: string, operationResultType: string, operationVariablesTypes: string, hasRequiredVariables: boolean): string;
|
|
16
|
+
}
|