@graphql-codegen/typescript-react-apollo 4.2.0 → 4.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/cjs/visitor.js CHANGED
@@ -227,6 +227,7 @@ class ReactApolloVisitor extends visitor_plugin_common_1.ClientSideBaseVisitor {
227
227
  var _a, _b;
228
228
  const nodeName = (_b = (_a = node.name) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : '';
229
229
  const suffix = this._getHookSuffix(nodeName, operationType);
230
+ const shouldEnforceRequiredVariables = hasRequiredVariables && operationType !== 'Mutation';
230
231
  const operationName = this.convertName(nodeName, {
231
232
  suffix,
232
233
  useTypesPrefix: false,
@@ -236,7 +237,9 @@ class ReactApolloVisitor extends visitor_plugin_common_1.ClientSideBaseVisitor {
236
237
  this.imports.add(this.getApolloReactHooksImport(false));
237
238
  this.imports.add(this.getDefaultOptions());
238
239
  const hookFns = [
239
- `export function use${operationName}(baseOptions${hasRequiredVariables && operationType !== 'Mutation' ? '' : '?'}: ${this.getApolloReactHooksIdentifier()}.${operationType}HookOptions<${operationResultType}, ${operationVariablesTypes}>) {
240
+ `export function use${operationName}(baseOptions${shouldEnforceRequiredVariables ? '' : '?'}: ${this.getApolloReactHooksIdentifier()}.${operationType}HookOptions<${operationResultType}, ${operationVariablesTypes}>${!shouldEnforceRequiredVariables
241
+ ? ''
242
+ : ` & ({ variables: ${operationVariablesTypes}; skip?: boolean; } | { skip: boolean; }) `}) {
240
243
  const options = {...defaultOptions, ...baseOptions}
241
244
  return ${this.getApolloReactHooksIdentifier()}.use${operationType}<${operationResultType}, ${operationVariablesTypes}>(${this.getDocumentNodeVariable(node, documentVariableName)}, options);
242
245
  }`,
package/esm/visitor.js CHANGED
@@ -223,6 +223,7 @@ export class ReactApolloVisitor extends ClientSideBaseVisitor {
223
223
  var _a, _b;
224
224
  const nodeName = (_b = (_a = node.name) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : '';
225
225
  const suffix = this._getHookSuffix(nodeName, operationType);
226
+ const shouldEnforceRequiredVariables = hasRequiredVariables && operationType !== 'Mutation';
226
227
  const operationName = this.convertName(nodeName, {
227
228
  suffix,
228
229
  useTypesPrefix: false,
@@ -232,7 +233,9 @@ export class ReactApolloVisitor extends ClientSideBaseVisitor {
232
233
  this.imports.add(this.getApolloReactHooksImport(false));
233
234
  this.imports.add(this.getDefaultOptions());
234
235
  const hookFns = [
235
- `export function use${operationName}(baseOptions${hasRequiredVariables && operationType !== 'Mutation' ? '' : '?'}: ${this.getApolloReactHooksIdentifier()}.${operationType}HookOptions<${operationResultType}, ${operationVariablesTypes}>) {
236
+ `export function use${operationName}(baseOptions${shouldEnforceRequiredVariables ? '' : '?'}: ${this.getApolloReactHooksIdentifier()}.${operationType}HookOptions<${operationResultType}, ${operationVariablesTypes}>${!shouldEnforceRequiredVariables
237
+ ? ''
238
+ : ` & ({ variables: ${operationVariablesTypes}; skip?: boolean; } | { skip: boolean; }) `}) {
236
239
  const options = {...defaultOptions, ...baseOptions}
237
240
  return ${this.getApolloReactHooksIdentifier()}.use${operationType}<${operationResultType}, ${operationVariablesTypes}>(${this.getDocumentNodeVariable(node, documentVariableName)}, options);
238
241
  }`,
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "@graphql-codegen/typescript-react-apollo",
3
- "version": "4.2.0",
3
+ "version": "4.3.1",
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
- "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
9
  "@graphql-codegen/plugin-helpers": "^3.0.0",