@graphql-codegen/typescript-react-query 5.0.0-alpha-20230911210300-bd6b199b9 → 5.0.0-alpha-20230925154442-07a299ee9
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 +6 -1
- package/esm/visitor.js +6 -1
- package/package.json +1 -1
- package/typings/config.d.cts +10 -0
- package/typings/config.d.ts +10 -0
- package/typings/visitor.d.cts +1 -0
- package/typings/visitor.d.ts +1 -0
package/cjs/visitor.js
CHANGED
|
@@ -22,6 +22,7 @@ class ReactQueryVisitor extends visitor_plugin_common_1.ClientSideBaseVisitor {
|
|
|
22
22
|
exposeFetcher: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.exposeFetcher, false),
|
|
23
23
|
addInfiniteQuery: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.addInfiniteQuery, false),
|
|
24
24
|
legacyMode: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.legacyMode, false),
|
|
25
|
+
reactQueryImportFrom: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.reactQueryImportFrom, ''),
|
|
25
26
|
});
|
|
26
27
|
this.rawConfig = rawConfig;
|
|
27
28
|
this.reactQueryHookIdentifiersInUse = new Set();
|
|
@@ -74,7 +75,11 @@ class ReactQueryVisitor extends visitor_plugin_common_1.ClientSideBaseVisitor {
|
|
|
74
75
|
...Array.from(this.reactQueryHookIdentifiersInUse),
|
|
75
76
|
...Array.from(this.reactQueryOptionsIdentifiersInUse).map(identifier => `${this.config.useTypeImports ? 'type ' : ''}${identifier}`),
|
|
76
77
|
];
|
|
77
|
-
const moduleName = this.config.
|
|
78
|
+
const moduleName = this.config.reactQueryImportFrom
|
|
79
|
+
? this.config.reactQueryImportFrom
|
|
80
|
+
: this.config.legacyMode
|
|
81
|
+
? 'react-query'
|
|
82
|
+
: '@tanstack/react-query';
|
|
78
83
|
return [...baseImports, `import { ${hookAndTypeImports.join(', ')} } from '${moduleName}';`];
|
|
79
84
|
}
|
|
80
85
|
getFetcherImplementation() {
|
package/esm/visitor.js
CHANGED
|
@@ -18,6 +18,7 @@ export class ReactQueryVisitor extends ClientSideBaseVisitor {
|
|
|
18
18
|
exposeFetcher: getConfigValue(rawConfig.exposeFetcher, false),
|
|
19
19
|
addInfiniteQuery: getConfigValue(rawConfig.addInfiniteQuery, false),
|
|
20
20
|
legacyMode: getConfigValue(rawConfig.legacyMode, false),
|
|
21
|
+
reactQueryImportFrom: getConfigValue(rawConfig.reactQueryImportFrom, ''),
|
|
21
22
|
});
|
|
22
23
|
this.rawConfig = rawConfig;
|
|
23
24
|
this.reactQueryHookIdentifiersInUse = new Set();
|
|
@@ -70,7 +71,11 @@ export class ReactQueryVisitor extends ClientSideBaseVisitor {
|
|
|
70
71
|
...Array.from(this.reactQueryHookIdentifiersInUse),
|
|
71
72
|
...Array.from(this.reactQueryOptionsIdentifiersInUse).map(identifier => `${this.config.useTypeImports ? 'type ' : ''}${identifier}`),
|
|
72
73
|
];
|
|
73
|
-
const moduleName = this.config.
|
|
74
|
+
const moduleName = this.config.reactQueryImportFrom
|
|
75
|
+
? this.config.reactQueryImportFrom
|
|
76
|
+
: this.config.legacyMode
|
|
77
|
+
? 'react-query'
|
|
78
|
+
: '@tanstack/react-query';
|
|
74
79
|
return [...baseImports, `import { ${hookAndTypeImports.join(', ')} } from '${moduleName}';`];
|
|
75
80
|
}
|
|
76
81
|
getFetcherImplementation() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/typescript-react-query",
|
|
3
|
-
"version": "5.0.0-alpha-
|
|
3
|
+
"version": "5.0.0-alpha-20230925154442-07a299ee9",
|
|
4
4
|
"description": "GraphQL Code Generator plugin for generating a ready-to-use React-Query Hooks based on 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"
|
package/typings/config.d.cts
CHANGED
|
@@ -97,4 +97,14 @@ export interface ReactQueryRawPluginConfig extends Omit<RawClientSideBasePluginC
|
|
|
97
97
|
* @description If false, it will work with `@tanstack/react-query`, default value is true.
|
|
98
98
|
*/
|
|
99
99
|
legacyMode?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* @default empty
|
|
102
|
+
* @description Add custom import for react-query.
|
|
103
|
+
* It can be used to import from `@tanstack/react-query` instead of `react-query`. But make sure it include useQuery, UseQueryOptions, useMutation, UseMutationOptions, useInfiniteQuery, UseInfiniteQueryOptions
|
|
104
|
+
*
|
|
105
|
+
* The following options are available to use:
|
|
106
|
+
*
|
|
107
|
+
* - "src/your-own-react-query-customized": import { useQuery, UseQueryOptions, useMutation, UseMutationOptions, useInfiniteQuery, UseInfiniteQueryOptions } from your own react-query customized package.
|
|
108
|
+
*/
|
|
109
|
+
reactQueryImportFrom?: string;
|
|
100
110
|
}
|
package/typings/config.d.ts
CHANGED
|
@@ -97,4 +97,14 @@ export interface ReactQueryRawPluginConfig extends Omit<RawClientSideBasePluginC
|
|
|
97
97
|
* @description If false, it will work with `@tanstack/react-query`, default value is true.
|
|
98
98
|
*/
|
|
99
99
|
legacyMode?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* @default empty
|
|
102
|
+
* @description Add custom import for react-query.
|
|
103
|
+
* It can be used to import from `@tanstack/react-query` instead of `react-query`. But make sure it include useQuery, UseQueryOptions, useMutation, UseMutationOptions, useInfiniteQuery, UseInfiniteQueryOptions
|
|
104
|
+
*
|
|
105
|
+
* The following options are available to use:
|
|
106
|
+
*
|
|
107
|
+
* - "src/your-own-react-query-customized": import { useQuery, UseQueryOptions, useMutation, UseMutationOptions, useInfiniteQuery, UseInfiniteQueryOptions } from your own react-query customized package.
|
|
108
|
+
*/
|
|
109
|
+
reactQueryImportFrom?: string;
|
|
100
110
|
}
|
package/typings/visitor.d.cts
CHANGED
package/typings/visitor.d.ts
CHANGED