diff --git a/.changeset/shaky-queens-sell.md b/.changeset/shaky-queens-sell.md new file mode 100644 index 0000000000..1b7031d453 --- /dev/null +++ b/.changeset/shaky-queens-sell.md @@ -0,0 +1,8 @@ +--- +'@graphql-codegen/typescript-react-query': patch +'@graphql-codegen/typescript-solid-query': patch +--- + +Query keys should be shared between suspense and non-suspense hooks to ensure consistent state +management and synchronization, preventing discrepancies and maintaining a single source of truth +for query invalidation. diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8befd2416d..ea214f6b58 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,7 +28,7 @@ jobs: - name: Setup env uses: the-guild-org/shared-config/setup@main with: - nodeVersion: 18 + nodeVersion: 24 - name: Prettier Check run: yarn prettier:check dev-tests: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 13fdd4c432..325f6be408 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -28,6 +28,7 @@ jobs: uses: the-guild-org/shared-config/.github/workflows/release-stable.yml@main permissions: id-token: write # allows ODIC publishing + contents: write with: releaseScript: release nodeVersion: 24 diff --git a/packages/plugins/typescript/react-query/src/fetcher.ts b/packages/plugins/typescript/react-query/src/fetcher.ts index 34f392204d..cbdda157be 100644 --- a/packages/plugins/typescript/react-query/src/fetcher.ts +++ b/packages/plugins/typescript/react-query/src/fetcher.ts @@ -135,10 +135,7 @@ export abstract class FetcherRenderer { >(${argumentsResult}) => { ${implHookOuter} return ${query.getHook()}<${operationResultType}, TError, TData>( - ${this.generateQueryFormattedParameters( - this.generateQueryKey(config), - implFetcher, - )} + ${this.generateQueryFormattedParameters(this.generateQueryKey(config), implFetcher)} )};`; }; 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 3e28630dee..7eb3ff8be3 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 @@ -1439,7 +1439,7 @@ export const useSuspenseTestQuery = < return useSuspenseQuery( { - queryKey: variables === undefined ? ['testSuspense'] : ['testSuspense', variables], + queryKey: variables === undefined ? ['test'] : ['test', variables], queryFn: fetcher(dataSource.endpoint, dataSource.fetchParams || {}, TestDocument, variables), ...options } @@ -1478,7 +1478,7 @@ export const useSuspenseInfiniteTestQuery = < (() => { const { queryKey: optionsQueryKey, ...restOptions } = options; return { - queryKey: optionsQueryKey ?? variables === undefined ? ['test.infiniteSuspense'] : ['test.infiniteSuspense', variables], + queryKey: optionsQueryKey ?? variables === undefined ? ['test.infinite'] : ['test.infinite', variables], queryFn: (metaData) => fetcher(dataSource.endpoint, dataSource.fetchParams || {}, TestDocument, {...variables, ...(metaData.pageParam ?? {})})(), ...restOptions } diff --git a/packages/plugins/typescript/solid-query/src/fetcher.ts b/packages/plugins/typescript/solid-query/src/fetcher.ts index b5d4a80b93..27c90da308 100644 --- a/packages/plugins/typescript/solid-query/src/fetcher.ts +++ b/packages/plugins/typescript/solid-query/src/fetcher.ts @@ -125,10 +125,7 @@ export abstract class FetcherRenderer { >(${argumentsResult}) => { ${implHookOuter} return ${query.getHook()}<${operationResultType}, TError, TData>( - ${this.generateQueryFormattedParameters( - this.generateQueryKey(config), - implFetcher, - )} + ${this.generateQueryFormattedParameters(this.generateQueryKey(config), implFetcher)} )};`; };