@graphql-codegen/typescript-react-apollo 4.0.0-alpha-20230925212527-35314bd5d → 4.1.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 CHANGED
@@ -253,6 +253,15 @@ class ReactApolloVisitor extends visitor_plugin_common_1.ClientSideBaseVisitor {
253
253
  return ${this.getApolloReactHooksIdentifier()}.useLazyQuery<${operationResultType}, ${operationVariablesTypes}>(${this.getDocumentNodeVariable(node, documentVariableName)}, options);
254
254
  }`);
255
255
  hookResults.push(`export type ${lazyOperationName}HookResult = ReturnType<typeof use${lazyOperationName}>;`);
256
+ const suspenseOperationName = this.convertName(nodeName, {
257
+ suffix: (0, change_case_all_1.pascalCase)('SuspenseQuery'),
258
+ useTypesPrefix: false,
259
+ }) + this.config.hooksSuffix;
260
+ hookFns.push(`export function use${suspenseOperationName}(baseOptions?: ${this.getApolloReactHooksIdentifier()}.SuspenseQueryHookOptions<${operationResultType}, ${operationVariablesTypes}>) {
261
+ const options = {...defaultOptions, ...baseOptions}
262
+ return ${this.getApolloReactHooksIdentifier()}.useSuspenseQuery<${operationResultType}, ${operationVariablesTypes}>(${this.getDocumentNodeVariable(node, documentVariableName)}, options);
263
+ }`);
264
+ hookResults.push(`export type ${suspenseOperationName}HookResult = ReturnType<typeof use${suspenseOperationName}>;`);
256
265
  }
257
266
  return [...hookFns, ...hookResults].join('\n');
258
267
  }
package/esm/visitor.js CHANGED
@@ -249,6 +249,15 @@ export class ReactApolloVisitor extends ClientSideBaseVisitor {
249
249
  return ${this.getApolloReactHooksIdentifier()}.useLazyQuery<${operationResultType}, ${operationVariablesTypes}>(${this.getDocumentNodeVariable(node, documentVariableName)}, options);
250
250
  }`);
251
251
  hookResults.push(`export type ${lazyOperationName}HookResult = ReturnType<typeof use${lazyOperationName}>;`);
252
+ const suspenseOperationName = this.convertName(nodeName, {
253
+ suffix: pascalCase('SuspenseQuery'),
254
+ useTypesPrefix: false,
255
+ }) + this.config.hooksSuffix;
256
+ hookFns.push(`export function use${suspenseOperationName}(baseOptions?: ${this.getApolloReactHooksIdentifier()}.SuspenseQueryHookOptions<${operationResultType}, ${operationVariablesTypes}>) {
257
+ const options = {...defaultOptions, ...baseOptions}
258
+ return ${this.getApolloReactHooksIdentifier()}.useSuspenseQuery<${operationResultType}, ${operationVariablesTypes}>(${this.getDocumentNodeVariable(node, documentVariableName)}, options);
259
+ }`);
260
+ hookResults.push(`export type ${suspenseOperationName}HookResult = ReturnType<typeof use${suspenseOperationName}>;`);
252
261
  }
253
262
  return [...hookFns, ...hookResults].join('\n');
254
263
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-codegen/typescript-react-apollo",
3
- "version": "4.0.0-alpha-20230925212527-35314bd5d",
3
+ "version": "4.1.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",