@graphql-codegen/typescript-react-query 3.4.0 → 3.5.1-alpha-06d103feb.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.
Files changed (3) hide show
  1. package/index.js +6 -2
  2. package/index.mjs +6 -2
  3. package/package.json +2 -2
package/index.js CHANGED
@@ -64,6 +64,8 @@ class CustomMapperFetcher {
64
64
  }
65
65
  generateInfiniteQueryHook(node, documentVariableName, operationName, operationResultType, operationVariablesTypes, hasRequiredVariables) {
66
66
  const variables = `variables${hasRequiredVariables ? '' : '?'}: ${operationVariablesTypes}`;
67
+ const typeImport = this.visitor.config.useTypeImports ? 'import type' : 'import';
68
+ this.visitor.imports.add(`${typeImport} { RequestInit } from 'graphql-request/dist/types.dom';`);
67
69
  const hookConfig = this.visitor.queryMethodMap;
68
70
  this.visitor.reactQueryIdentifiersInUse.add(hookConfig.infiniteQuery.hook);
69
71
  this.visitor.reactQueryIdentifiersInUse.add(hookConfig.infiniteQuery.options);
@@ -89,6 +91,8 @@ class CustomMapperFetcher {
89
91
  }
90
92
  generateQueryHook(node, documentVariableName, operationName, operationResultType, operationVariablesTypes, hasRequiredVariables) {
91
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';`);
92
96
  const hookConfig = this.visitor.queryMethodMap;
93
97
  this.visitor.reactQueryIdentifiersInUse.add(hookConfig.query.hook);
94
98
  this.visitor.reactQueryIdentifiersInUse.add(hookConfig.query.options);
@@ -137,8 +141,8 @@ class CustomMapperFetcher {
137
141
  return '';
138
142
  const variables = `variables${hasRequiredVariables ? '' : '?'}: ${operationVariablesTypes}`;
139
143
  const typedFetcher = this.getFetcherFnName(operationResultType, operationVariablesTypes);
140
- const impl = `${typedFetcher}(${documentVariableName}, variables)`;
141
- return `\nuse${operationName}.fetcher = (${variables}) => ${impl};`;
144
+ const impl = `${typedFetcher}(${documentVariableName}, variables, options)`;
145
+ return `\nuse${operationName}.fetcher = (${variables}, options?: RequestInit['headers']) => ${impl};`;
142
146
  }
143
147
  }
144
148
 
package/index.mjs CHANGED
@@ -58,6 +58,8 @@ class CustomMapperFetcher {
58
58
  }
59
59
  generateInfiniteQueryHook(node, documentVariableName, operationName, operationResultType, operationVariablesTypes, hasRequiredVariables) {
60
60
  const variables = `variables${hasRequiredVariables ? '' : '?'}: ${operationVariablesTypes}`;
61
+ const typeImport = this.visitor.config.useTypeImports ? 'import type' : 'import';
62
+ this.visitor.imports.add(`${typeImport} { RequestInit } from 'graphql-request/dist/types.dom';`);
61
63
  const hookConfig = this.visitor.queryMethodMap;
62
64
  this.visitor.reactQueryIdentifiersInUse.add(hookConfig.infiniteQuery.hook);
63
65
  this.visitor.reactQueryIdentifiersInUse.add(hookConfig.infiniteQuery.options);
@@ -83,6 +85,8 @@ class CustomMapperFetcher {
83
85
  }
84
86
  generateQueryHook(node, documentVariableName, operationName, operationResultType, operationVariablesTypes, hasRequiredVariables) {
85
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';`);
86
90
  const hookConfig = this.visitor.queryMethodMap;
87
91
  this.visitor.reactQueryIdentifiersInUse.add(hookConfig.query.hook);
88
92
  this.visitor.reactQueryIdentifiersInUse.add(hookConfig.query.options);
@@ -131,8 +135,8 @@ class CustomMapperFetcher {
131
135
  return '';
132
136
  const variables = `variables${hasRequiredVariables ? '' : '?'}: ${operationVariablesTypes}`;
133
137
  const typedFetcher = this.getFetcherFnName(operationResultType, operationVariablesTypes);
134
- const impl = `${typedFetcher}(${documentVariableName}, variables)`;
135
- return `\nuse${operationName}.fetcher = (${variables}) => ${impl};`;
138
+ const impl = `${typedFetcher}(${documentVariableName}, variables, options)`;
139
+ return `\nuse${operationName}.fetcher = (${variables}, options?: RequestInit['headers']) => ${impl};`;
136
140
  }
137
141
  }
138
142
 
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@graphql-codegen/typescript-react-query",
3
- "version": "3.4.0",
3
+ "version": "3.5.1-alpha-06d103feb.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"
7
7
  },
8
8
  "dependencies": {
9
9
  "@graphql-codegen/plugin-helpers": "^2.3.2",
10
- "@graphql-codegen/visitor-plugin-common": "2.5.2",
10
+ "@graphql-codegen/visitor-plugin-common": "2.5.3-alpha-06d103feb.0",
11
11
  "auto-bind": "~4.0.0",
12
12
  "change-case-all": "1.0.14",
13
13
  "tslib": "~2.3.0"