@graphql-codegen/typescript-react-query 3.2.3-alpha-23d229715.0 → 3.3.1
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/index.js +6 -4
- package/index.mjs +6 -4
- package/package.json +4 -5
package/index.js
CHANGED
|
@@ -65,8 +65,9 @@ class CustomMapperFetcher {
|
|
|
65
65
|
this.visitor.reactQueryIdentifiersInUse.add(hookConfig.infiniteQuery.options);
|
|
66
66
|
const options = `options?: ${hookConfig.infiniteQuery.options}<${operationResultType}, TError, TData>`;
|
|
67
67
|
const typedFetcher = this.getFetcherFnName(operationResultType, operationVariablesTypes);
|
|
68
|
+
const implHookOuter = this._isReactHook ? `const query = ${typedFetcher}(${documentVariableName})` : '';
|
|
68
69
|
const impl = this._isReactHook
|
|
69
|
-
? `(metaData) =>
|
|
70
|
+
? `(metaData) => query({...variables, ...(metaData.pageParam ?? {})})`
|
|
70
71
|
: `(metaData) => ${typedFetcher}(${documentVariableName}, {...variables, ...(metaData.pageParam ?? {})})()`;
|
|
71
72
|
return `export const useInfinite${operationName} = <
|
|
72
73
|
TData = ${operationResultType},
|
|
@@ -74,12 +75,13 @@ class CustomMapperFetcher {
|
|
|
74
75
|
>(
|
|
75
76
|
${variables},
|
|
76
77
|
${options}
|
|
77
|
-
) =>
|
|
78
|
-
${
|
|
78
|
+
) =>{
|
|
79
|
+
${implHookOuter}
|
|
80
|
+
return ${hookConfig.infiniteQuery.hook}<${operationResultType}, TError, TData>(
|
|
79
81
|
${generateInfiniteQueryKey(node, hasRequiredVariables)},
|
|
80
82
|
${impl},
|
|
81
83
|
options
|
|
82
|
-
);`;
|
|
84
|
+
)};`;
|
|
83
85
|
}
|
|
84
86
|
generateQueryHook(node, documentVariableName, operationName, operationResultType, operationVariablesTypes, hasRequiredVariables) {
|
|
85
87
|
const variables = `variables${hasRequiredVariables ? '' : '?'}: ${operationVariablesTypes}`;
|
package/index.mjs
CHANGED
|
@@ -59,8 +59,9 @@ class CustomMapperFetcher {
|
|
|
59
59
|
this.visitor.reactQueryIdentifiersInUse.add(hookConfig.infiniteQuery.options);
|
|
60
60
|
const options = `options?: ${hookConfig.infiniteQuery.options}<${operationResultType}, TError, TData>`;
|
|
61
61
|
const typedFetcher = this.getFetcherFnName(operationResultType, operationVariablesTypes);
|
|
62
|
+
const implHookOuter = this._isReactHook ? `const query = ${typedFetcher}(${documentVariableName})` : '';
|
|
62
63
|
const impl = this._isReactHook
|
|
63
|
-
? `(metaData) =>
|
|
64
|
+
? `(metaData) => query({...variables, ...(metaData.pageParam ?? {})})`
|
|
64
65
|
: `(metaData) => ${typedFetcher}(${documentVariableName}, {...variables, ...(metaData.pageParam ?? {})})()`;
|
|
65
66
|
return `export const useInfinite${operationName} = <
|
|
66
67
|
TData = ${operationResultType},
|
|
@@ -68,12 +69,13 @@ class CustomMapperFetcher {
|
|
|
68
69
|
>(
|
|
69
70
|
${variables},
|
|
70
71
|
${options}
|
|
71
|
-
) =>
|
|
72
|
-
${
|
|
72
|
+
) =>{
|
|
73
|
+
${implHookOuter}
|
|
74
|
+
return ${hookConfig.infiniteQuery.hook}<${operationResultType}, TError, TData>(
|
|
73
75
|
${generateInfiniteQueryKey(node, hasRequiredVariables)},
|
|
74
76
|
${impl},
|
|
75
77
|
options
|
|
76
|
-
);`;
|
|
78
|
+
)};`;
|
|
77
79
|
}
|
|
78
80
|
generateQueryHook(node, documentVariableName, operationName, operationResultType, operationVariablesTypes, hasRequiredVariables) {
|
|
79
81
|
const variables = `variables${hasRequiredVariables ? '' : '?'}: ${operationVariablesTypes}`;
|
package/package.json
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/typescript-react-query",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.1",
|
|
4
4
|
"description": "GraphQL Code Generator plugin for generating a ready-to-use React-Query Hooks based on GraphQL operations",
|
|
5
5
|
"peerDependencies": {
|
|
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-tag": "^2.0.0"
|
|
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"
|
|
8
7
|
},
|
|
9
8
|
"dependencies": {
|
|
10
|
-
"@graphql-codegen/plugin-helpers": "2.
|
|
11
|
-
"@graphql-codegen/visitor-plugin-common": "2.5.2
|
|
9
|
+
"@graphql-codegen/plugin-helpers": "^2.3.2",
|
|
10
|
+
"@graphql-codegen/visitor-plugin-common": "2.5.2",
|
|
12
11
|
"auto-bind": "~4.0.0",
|
|
13
12
|
"change-case-all": "1.0.14",
|
|
14
13
|
"tslib": "~2.3.0"
|