File tree Expand file tree Collapse file tree 5 files changed +17
-20
lines changed
packages/typoas-react-query/src Expand file tree Collapse file tree 5 files changed +17
-20
lines changed Original file line number Diff line number Diff line change 1+ releases :
2+ " @typoas/react-query " : patch
Original file line number Diff line number Diff line change 44
55---
66
7+ ## 4.2.2 - 2025-02-12
8+
9+ > Only @typoas/react-query was updated to 4.2.2
10+
11+ - fix(react-query): Override queryKey instead of queryHashKey [ #78 ] ( https://github.com/Embraser01/typoas/pull/78 )
12+
713## 4.2.1 - 2025-02-12
814
915> Only @typoas/react-query was updated to 4.2.1
Original file line number Diff line number Diff line change 11import {
22 DefaultError ,
33 QueryClient ,
4- hashKey ,
54 useInfiniteQuery ,
65 UseInfiniteQueryOptions ,
76 UndefinedInitialDataInfiniteOptions ,
@@ -127,15 +126,8 @@ export function createInfiniteQueryHook<
127126 ...options ,
128127 getNextPageParam,
129128 initialPageParam,
130- // Override the query key hash function to include the name of the query
131- // This is the main way to ensure that the query key is unique
132- // Note that if a user provides a custom queryKeyHashFn,
133- // they will receive the name as the first argument.
134- queryKeyHashFn : ( queryKey ) => {
135- const hashFn =
136- options . queryKeyHashFn || baseOptions . queryKeyHashFn || hashKey ;
137- return hashFn ( [ name , ...queryKey ] ) ;
138- } ,
129+ // Override the query key to differentiate between multiple typoas functions
130+ queryKey : [ name , ...options . queryKey ] ,
139131 queryFn : ( { pageParam } ) => {
140132 const ctx = localContext || context ;
141133 if ( ! ctx ) {
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import {
1313} from '@typoas/runtime' ;
1414import { useApiContext } from './api-context' ;
1515import { TypoasFuncStatusType , TypoasReturnType } from './types' ;
16+ import { getQueryFunctionKey } from './func-names' ;
1617
1718export type TypoasMutationVariables <
1819 Func extends TypoasMutationFunction < FetcherData > ,
@@ -94,6 +95,10 @@ export function createMutationHook<
9495 {
9596 ...baseOptions ,
9697 ...options ,
98+ // Override the mutation key to differentiate between multiple typoas functions
99+ mutationKey : options . mutationKey
100+ ? [ getQueryFunctionKey ( func ) , ...options . mutationKey ]
101+ : undefined ,
97102 mutationFn : ( [ params , body ] ) => {
98103 const ctx = localContext || context ;
99104 if ( ! ctx ) {
Original file line number Diff line number Diff line change 55 useQuery ,
66 UseQueryOptions ,
77 UseQueryResult ,
8- hashKey ,
98 DefaultError ,
109} from '@tanstack/react-query' ;
1110import {
@@ -94,15 +93,8 @@ export function createQueryHook<
9493 {
9594 ...baseOptions ,
9695 ...options ,
97- // Override the query key hash function to include the name of the query
98- // This is the main way to ensure that the query key is unique
99- // Note that if a user provides a custom queryKeyHashFn,
100- // they will receive the name as the first argument.
101- queryKeyHashFn : ( queryKey ) => {
102- const hashFn =
103- options . queryKeyHashFn || baseOptions . queryKeyHashFn || hashKey ;
104- return hashFn ( [ name , ...queryKey ] ) ;
105- } ,
96+ // Override the query key to differentiate between multiple typoas functions
97+ queryKey : [ name , ...options . queryKey ] ,
10698 queryFn : ( ) => {
10799 const ctx = localContext || context ;
108100 if ( ! ctx ) {
You can’t perform that action at this time.
0 commit comments