From d825ce4d9b64cdf2319a56649f9f98c251972c9f Mon Sep 17 00:00:00 2001 From: David Chen Date: Thu, 11 Apr 2024 16:23:03 -0700 Subject: [PATCH 1/3] remove incorrect request init import --- packages/plugins/typescript/react-query/package.json | 2 +- .../typescript/react-query/src/fetcher-graphql-request.ts | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/plugins/typescript/react-query/package.json b/packages/plugins/typescript/react-query/package.json index 53df298f0..6a743bd1c 100644 --- a/packages/plugins/typescript/react-query/package.json +++ b/packages/plugins/typescript/react-query/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-codegen/typescript-react-query", - "version": "6.1.0", + "version": "6.1.1", "type": "module", "description": "GraphQL Code Generator plugin for generating a ready-to-use React-Query Hooks based on GraphQL operations", "repository": { diff --git a/packages/plugins/typescript/react-query/src/fetcher-graphql-request.ts b/packages/plugins/typescript/react-query/src/fetcher-graphql-request.ts index 9a61e8fb0..887c5c240 100644 --- a/packages/plugins/typescript/react-query/src/fetcher-graphql-request.ts +++ b/packages/plugins/typescript/react-query/src/fetcher-graphql-request.ts @@ -132,11 +132,6 @@ function fetcher(client: Graph config; const variables = this.generateQueryVariablesSignature(config); - const typeImport = this.visitor.config.useTypeImports ? 'import type' : 'import'; - if (this.clientPath) this.visitor.imports.add(this.clientPath); - this.visitor.imports.add( - `${typeImport} { RequestInit } from 'graphql-request/dist/types.dom';`, - ); return this.clientPath ? `\nuse${operationName}.fetcher = (${variables}, headers?: RequestInit['headers']) => fetcher<${operationResultType}, ${operationVariablesTypes}>(${documentVariableName}, variables, headers);` From 14bb8a4af2987a43a4e104efae0138a42ccc40ec Mon Sep 17 00:00:00 2001 From: David Chen Date: Thu, 11 Apr 2024 16:59:04 -0700 Subject: [PATCH 2/3] remove RequestInit import from dom --- .../typescript/react-query/src/fetcher-graphql-request.ts | 4 +--- .../react-query/tests/__snapshots__/react-query.spec.ts.snap | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/plugins/typescript/react-query/src/fetcher-graphql-request.ts b/packages/plugins/typescript/react-query/src/fetcher-graphql-request.ts index 887c5c240..b748b7ea7 100644 --- a/packages/plugins/typescript/react-query/src/fetcher-graphql-request.ts +++ b/packages/plugins/typescript/react-query/src/fetcher-graphql-request.ts @@ -69,9 +69,6 @@ function fetcher(client: Graph const typeImport = this.visitor.config.useTypeImports ? 'import type' : 'import'; if (this.clientPath) this.visitor.imports.add(this.clientPath); this.visitor.imports.add(`${typeImport} { GraphQLClient } from 'graphql-request';`); - this.visitor.imports.add( - `${typeImport} { RequestInit } from 'graphql-request/dist/types.dom';`, - ); const { generateBaseQueryHook, variables, options } = this.generateQueryHelper( config, @@ -132,6 +129,7 @@ function fetcher(client: Graph config; const variables = this.generateQueryVariablesSignature(config); + if (this.clientPath) this.visitor.imports.add(this.clientPath); return this.clientPath ? `\nuse${operationName}.fetcher = (${variables}, headers?: RequestInit['headers']) => fetcher<${operationResultType}, ${operationVariablesTypes}>(${documentVariableName}, variables, headers);` diff --git a/packages/plugins/typescript/react-query/tests/__snapshots__/react-query.spec.ts.snap b/packages/plugins/typescript/react-query/tests/__snapshots__/react-query.spec.ts.snap index 9c7f5655e..a9915584f 100644 --- a/packages/plugins/typescript/react-query/tests/__snapshots__/react-query.spec.ts.snap +++ b/packages/plugins/typescript/react-query/tests/__snapshots__/react-query.spec.ts.snap @@ -648,7 +648,6 @@ export const useTestMutation = < exports[`React-Query fetcher: graphql-request Should generate query correctly with client: prepend 1`] = ` [ "import { GraphQLClient } from 'graphql-request';", - "import { RequestInit } from 'graphql-request/dist/types.dom';", "import { useQuery, useInfiniteQuery, useMutation, UseQueryOptions, UseInfiniteQueryOptions, UseMutationOptions } from 'react-query';", " function fetcher(client: GraphQLClient, query: string, variables?: TVariables, requestHeaders?: RequestInit['headers']) { @@ -723,7 +722,6 @@ exports[`React-Query fetcher: graphql-request with clientImportPath Should gener [ "import { client as graphqlClient } from 'client.ts';", "import { GraphQLClient } from 'graphql-request';", - "import { RequestInit } from 'graphql-request/dist/types.dom';", "import { useQuery, useMutation, UseQueryOptions, UseMutationOptions } from 'react-query';", " function fetcher(query: string, variables?: TVariables, requestHeaders?: RequestInit['headers']) { From bde2ac4cb390c634821e190330413db5b2ddfb26 Mon Sep 17 00:00:00 2001 From: David Chen Date: Thu, 11 Apr 2024 17:03:50 -0700 Subject: [PATCH 3/3] added changeset --- .changeset/tough-hotels-shout.md | 5 +++++ packages/plugins/typescript/react-query/package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/tough-hotels-shout.md diff --git a/.changeset/tough-hotels-shout.md b/.changeset/tough-hotels-shout.md new file mode 100644 index 000000000..c5bc087f5 --- /dev/null +++ b/.changeset/tough-hotels-shout.md @@ -0,0 +1,5 @@ +--- +'@graphql-codegen/typescript-react-query': minor +--- + +Remove incorrect import of RequestInit diff --git a/packages/plugins/typescript/react-query/package.json b/packages/plugins/typescript/react-query/package.json index 6a743bd1c..53df298f0 100644 --- a/packages/plugins/typescript/react-query/package.json +++ b/packages/plugins/typescript/react-query/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-codegen/typescript-react-query", - "version": "6.1.1", + "version": "6.1.0", "type": "module", "description": "GraphQL Code Generator plugin for generating a ready-to-use React-Query Hooks based on GraphQL operations", "repository": {