@graphql-codegen/typescript-react-query 3.5.1 → 3.5.2-alpha-d4ba9b078.0
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 +4 -3
- package/index.mjs +4 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -91,8 +91,6 @@ class CustomMapperFetcher {
|
|
|
91
91
|
}
|
|
92
92
|
generateQueryHook(node, documentVariableName, operationName, operationResultType, operationVariablesTypes, hasRequiredVariables) {
|
|
93
93
|
const variables = `variables${hasRequiredVariables ? '' : '?'}: ${operationVariablesTypes}`;
|
|
94
|
-
const typeImport = this.visitor.config.useTypeImports ? 'import type' : 'import';
|
|
95
|
-
this.visitor.imports.add(`${typeImport} { RequestInit } from 'graphql-request/dist/types.dom';`);
|
|
96
94
|
const hookConfig = this.visitor.queryMethodMap;
|
|
97
95
|
this.visitor.reactQueryIdentifiersInUse.add(hookConfig.query.hook);
|
|
98
96
|
this.visitor.reactQueryIdentifiersInUse.add(hookConfig.query.options);
|
|
@@ -139,6 +137,8 @@ class CustomMapperFetcher {
|
|
|
139
137
|
// Related: https://reactjs.org/docs/hooks-rules.html
|
|
140
138
|
if (this._isReactHook)
|
|
141
139
|
return '';
|
|
140
|
+
const typeImport = this.visitor.config.useTypeImports ? 'import type' : 'import';
|
|
141
|
+
this.visitor.imports.add(`${typeImport} { RequestInit } from 'graphql-request/dist/types.dom';`);
|
|
142
142
|
const variables = `variables${hasRequiredVariables ? '' : '?'}: ${operationVariablesTypes}`;
|
|
143
143
|
const typedFetcher = this.getFetcherFnName(operationResultType, operationVariablesTypes);
|
|
144
144
|
const impl = `${typedFetcher}(${documentVariableName}, variables, options)`;
|
|
@@ -252,7 +252,6 @@ function fetcher<TData, TVariables>(client: GraphQLClient, query: string, variab
|
|
|
252
252
|
const variables = generateQueryVariablesSignature(hasRequiredVariables, operationVariablesTypes);
|
|
253
253
|
const typeImport = this.visitor.config.useTypeImports ? 'import type' : 'import';
|
|
254
254
|
this.visitor.imports.add(`${typeImport} { GraphQLClient } from 'graphql-request';`);
|
|
255
|
-
this.visitor.imports.add(`${typeImport} { RequestInit } from 'graphql-request/dist/types.dom';`);
|
|
256
255
|
const hookConfig = this.visitor.queryMethodMap;
|
|
257
256
|
this.visitor.reactQueryIdentifiersInUse.add(hookConfig.infiniteQuery.hook);
|
|
258
257
|
this.visitor.reactQueryIdentifiersInUse.add(hookConfig.infiniteQuery.options);
|
|
@@ -320,6 +319,8 @@ function fetcher<TData, TVariables>(client: GraphQLClient, query: string, variab
|
|
|
320
319
|
}
|
|
321
320
|
generateFetcherFetch(node, documentVariableName, operationName, operationResultType, operationVariablesTypes, hasRequiredVariables) {
|
|
322
321
|
const variables = generateQueryVariablesSignature(hasRequiredVariables, operationVariablesTypes);
|
|
322
|
+
const typeImport = this.visitor.config.useTypeImports ? 'import type' : 'import';
|
|
323
|
+
this.visitor.imports.add(`${typeImport} { RequestInit } from 'graphql-request/dist/types.dom';`);
|
|
323
324
|
return `\nuse${operationName}.fetcher = (client: GraphQLClient, ${variables}, headers?: RequestInit['headers']) => fetcher<${operationResultType}, ${operationVariablesTypes}>(client, ${documentVariableName}, variables, headers);`;
|
|
324
325
|
}
|
|
325
326
|
}
|
package/index.mjs
CHANGED
|
@@ -85,8 +85,6 @@ class CustomMapperFetcher {
|
|
|
85
85
|
}
|
|
86
86
|
generateQueryHook(node, documentVariableName, operationName, operationResultType, operationVariablesTypes, hasRequiredVariables) {
|
|
87
87
|
const variables = `variables${hasRequiredVariables ? '' : '?'}: ${operationVariablesTypes}`;
|
|
88
|
-
const typeImport = this.visitor.config.useTypeImports ? 'import type' : 'import';
|
|
89
|
-
this.visitor.imports.add(`${typeImport} { RequestInit } from 'graphql-request/dist/types.dom';`);
|
|
90
88
|
const hookConfig = this.visitor.queryMethodMap;
|
|
91
89
|
this.visitor.reactQueryIdentifiersInUse.add(hookConfig.query.hook);
|
|
92
90
|
this.visitor.reactQueryIdentifiersInUse.add(hookConfig.query.options);
|
|
@@ -133,6 +131,8 @@ class CustomMapperFetcher {
|
|
|
133
131
|
// Related: https://reactjs.org/docs/hooks-rules.html
|
|
134
132
|
if (this._isReactHook)
|
|
135
133
|
return '';
|
|
134
|
+
const typeImport = this.visitor.config.useTypeImports ? 'import type' : 'import';
|
|
135
|
+
this.visitor.imports.add(`${typeImport} { RequestInit } from 'graphql-request/dist/types.dom';`);
|
|
136
136
|
const variables = `variables${hasRequiredVariables ? '' : '?'}: ${operationVariablesTypes}`;
|
|
137
137
|
const typedFetcher = this.getFetcherFnName(operationResultType, operationVariablesTypes);
|
|
138
138
|
const impl = `${typedFetcher}(${documentVariableName}, variables, options)`;
|
|
@@ -246,7 +246,6 @@ function fetcher<TData, TVariables>(client: GraphQLClient, query: string, variab
|
|
|
246
246
|
const variables = generateQueryVariablesSignature(hasRequiredVariables, operationVariablesTypes);
|
|
247
247
|
const typeImport = this.visitor.config.useTypeImports ? 'import type' : 'import';
|
|
248
248
|
this.visitor.imports.add(`${typeImport} { GraphQLClient } from 'graphql-request';`);
|
|
249
|
-
this.visitor.imports.add(`${typeImport} { RequestInit } from 'graphql-request/dist/types.dom';`);
|
|
250
249
|
const hookConfig = this.visitor.queryMethodMap;
|
|
251
250
|
this.visitor.reactQueryIdentifiersInUse.add(hookConfig.infiniteQuery.hook);
|
|
252
251
|
this.visitor.reactQueryIdentifiersInUse.add(hookConfig.infiniteQuery.options);
|
|
@@ -314,6 +313,8 @@ function fetcher<TData, TVariables>(client: GraphQLClient, query: string, variab
|
|
|
314
313
|
}
|
|
315
314
|
generateFetcherFetch(node, documentVariableName, operationName, operationResultType, operationVariablesTypes, hasRequiredVariables) {
|
|
316
315
|
const variables = generateQueryVariablesSignature(hasRequiredVariables, operationVariablesTypes);
|
|
316
|
+
const typeImport = this.visitor.config.useTypeImports ? 'import type' : 'import';
|
|
317
|
+
this.visitor.imports.add(`${typeImport} { RequestInit } from 'graphql-request/dist/types.dom';`);
|
|
317
318
|
return `\nuse${operationName}.fetcher = (client: GraphQLClient, ${variables}, headers?: RequestInit['headers']) => fetcher<${operationResultType}, ${operationVariablesTypes}>(client, ${documentVariableName}, variables, headers);`;
|
|
318
319
|
}
|
|
319
320
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/typescript-react-query",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.2-alpha-d4ba9b078.0",
|
|
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"
|