@graphql-codegen/typescript-react-apollo 4.3.3 → 4.4.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/cjs/visitor.js +6 -2
- package/esm/visitor.js +7 -3
- package/package.json +1 -1
package/cjs/visitor.js
CHANGED
|
@@ -264,7 +264,10 @@ class ReactApolloVisitor extends visitor_plugin_common_1.ClientSideBaseVisitor {
|
|
|
264
264
|
suffix: (0, change_case_all_1.pascalCase)('SuspenseQuery'),
|
|
265
265
|
useTypesPrefix: false,
|
|
266
266
|
}) + this.config.hooksSuffix;
|
|
267
|
-
hookFns.push(
|
|
267
|
+
hookFns.push(`// @ts-ignore
|
|
268
|
+
export function use${suspenseOperationName}(baseOptions?: ${this.getApolloReactHooksIdentifier()}.SuspenseQueryHookOptions<${operationResultType}, ${operationVariablesTypes}>): ${this.getApolloReactHooksIdentifier()}.UseSuspenseQueryResult<${operationResultType}, ${operationVariablesTypes}>;
|
|
269
|
+
export function use${suspenseOperationName}(baseOptions?: ${this.getApolloReactHooksIdentifier()}.SkipToken | ${this.getApolloReactHooksIdentifier()}.SuspenseQueryHookOptions<${operationResultType}, ${operationVariablesTypes}>): ${this.getApolloReactHooksIdentifier()}.UseSuspenseQueryResult<${operationResultType} | undefined, ${operationVariablesTypes}>;
|
|
270
|
+
export function use${suspenseOperationName}(baseOptions?: ${this.getApolloReactHooksIdentifier()}.SkipToken | ${this.getApolloReactHooksIdentifier()}.SuspenseQueryHookOptions<${operationResultType}, ${operationVariablesTypes}>) {
|
|
268
271
|
const options = baseOptions === ${this.getApolloReactHooksIdentifier()}.skipToken ? baseOptions : {...defaultOptions, ...baseOptions}
|
|
269
272
|
return ${this.getApolloReactHooksIdentifier()}.useSuspenseQuery<${operationResultType}, ${operationVariablesTypes}>(${this.getDocumentNodeVariable(node, documentVariableName)}, options);
|
|
270
273
|
}`);
|
|
@@ -326,8 +329,9 @@ class ReactApolloVisitor extends visitor_plugin_common_1.ClientSideBaseVisitor {
|
|
|
326
329
|
suffix: this._getHookSuffix(nodeName, operationType),
|
|
327
330
|
useTypesPrefix: false,
|
|
328
331
|
}) + this.config.hooksSuffix;
|
|
332
|
+
const operationDocComment = 'description' in node ? (0, visitor_plugin_common_1.transformComment)(node.description) : '';
|
|
329
333
|
const optional = hasRequiredVariables(node) ? '' : '?';
|
|
330
|
-
return
|
|
334
|
+
return `${operationDocComment}export function refetch${operationName}(variables${optional}: ${operationVariablesTypes}) {
|
|
331
335
|
return { query: ${this.getDocumentNodeVariable(node, documentVariableName)}, variables: variables }
|
|
332
336
|
}`;
|
|
333
337
|
}
|
package/esm/visitor.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import autoBind from 'auto-bind';
|
|
2
2
|
import { camelCase, pascalCase } from 'change-case-all';
|
|
3
3
|
import { Kind } from 'graphql';
|
|
4
|
-
import { ClientSideBaseVisitor, DocumentMode, getConfigValue, OMIT_TYPE, } from '@graphql-codegen/visitor-plugin-common';
|
|
4
|
+
import { ClientSideBaseVisitor, DocumentMode, getConfigValue, OMIT_TYPE, transformComment, } from '@graphql-codegen/visitor-plugin-common';
|
|
5
5
|
const APOLLO_CLIENT_3_UNIFIED_PACKAGE = `@apollo/client`;
|
|
6
6
|
const GROUPED_APOLLO_CLIENT_3_IDENTIFIER = 'Apollo';
|
|
7
7
|
function hasRequiredVariables(node) {
|
|
@@ -260,7 +260,10 @@ export class ReactApolloVisitor extends ClientSideBaseVisitor {
|
|
|
260
260
|
suffix: pascalCase('SuspenseQuery'),
|
|
261
261
|
useTypesPrefix: false,
|
|
262
262
|
}) + this.config.hooksSuffix;
|
|
263
|
-
hookFns.push(
|
|
263
|
+
hookFns.push(`// @ts-ignore
|
|
264
|
+
export function use${suspenseOperationName}(baseOptions?: ${this.getApolloReactHooksIdentifier()}.SuspenseQueryHookOptions<${operationResultType}, ${operationVariablesTypes}>): ${this.getApolloReactHooksIdentifier()}.UseSuspenseQueryResult<${operationResultType}, ${operationVariablesTypes}>;
|
|
265
|
+
export function use${suspenseOperationName}(baseOptions?: ${this.getApolloReactHooksIdentifier()}.SkipToken | ${this.getApolloReactHooksIdentifier()}.SuspenseQueryHookOptions<${operationResultType}, ${operationVariablesTypes}>): ${this.getApolloReactHooksIdentifier()}.UseSuspenseQueryResult<${operationResultType} | undefined, ${operationVariablesTypes}>;
|
|
266
|
+
export function use${suspenseOperationName}(baseOptions?: ${this.getApolloReactHooksIdentifier()}.SkipToken | ${this.getApolloReactHooksIdentifier()}.SuspenseQueryHookOptions<${operationResultType}, ${operationVariablesTypes}>) {
|
|
264
267
|
const options = baseOptions === ${this.getApolloReactHooksIdentifier()}.skipToken ? baseOptions : {...defaultOptions, ...baseOptions}
|
|
265
268
|
return ${this.getApolloReactHooksIdentifier()}.useSuspenseQuery<${operationResultType}, ${operationVariablesTypes}>(${this.getDocumentNodeVariable(node, documentVariableName)}, options);
|
|
266
269
|
}`);
|
|
@@ -322,8 +325,9 @@ export class ReactApolloVisitor extends ClientSideBaseVisitor {
|
|
|
322
325
|
suffix: this._getHookSuffix(nodeName, operationType),
|
|
323
326
|
useTypesPrefix: false,
|
|
324
327
|
}) + this.config.hooksSuffix;
|
|
328
|
+
const operationDocComment = 'description' in node ? transformComment(node.description) : '';
|
|
325
329
|
const optional = hasRequiredVariables(node) ? '' : '?';
|
|
326
|
-
return
|
|
330
|
+
return `${operationDocComment}export function refetch${operationName}(variables${optional}: ${operationVariablesTypes}) {
|
|
327
331
|
return { query: ${this.getDocumentNodeVariable(node, documentVariableName)}, variables: variables }
|
|
328
332
|
}`;
|
|
329
333
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/typescript-react-apollo",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"description": "GraphQL Code Generator plugin for generating a ready-to-use React Components/HOC/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"
|