@@ -16,13 +16,17 @@ import {parseLinkHeader} from 'sentry/utils/parseLinkHeader';
1616
1717type KnownApiUrls = KnownGetsentryApiUrls | KnownSentryApiUrls ;
1818
19- type Options = QueryKeyEndpointOptions & { staleTime : number } ;
19+ type Options = QueryKeyEndpointOptions & { staleTime : number | 'static' } ;
2020
2121type PathParamOptions < TApiPath extends string > =
2222 ExtractPathParams < TApiPath > extends never
2323 ? { path ?: never }
2424 : { path : Record < ExtractPathParams < TApiPath > , string | number > | SkipToken } ;
2525
26+ function hasDefinedValues ( obj : Record < string , unknown > ) : boolean {
27+ return Object . values ( obj ) . some ( v => v !== undefined ) ;
28+ }
29+
2630const selectJson = < TData > ( data : ApiResponse < TData > ) => data . json ;
2731
2832export const selectJsonWithHeaders = < TData > (
@@ -45,10 +49,9 @@ function _apiOptions<
4549 const url = getApiUrl ( path , ...( [ { path : pathParams } ] as OptionalPathParams < TApiPath > ) ) ;
4650
4751 return queryOptions ( {
48- queryKey :
49- Object . keys ( options ) . length > 0
50- ? ( [ { infinite : false , version : 'v2' } , url , options ] as ApiQueryKey )
51- : ( [ { infinite : false , version : 'v2' } , url ] as ApiQueryKey ) ,
52+ queryKey : hasDefinedValues ( options )
53+ ? ( [ { infinite : false , version : 'v2' } , url , options ] as ApiQueryKey )
54+ : ( [ { infinite : false , version : 'v2' } , url ] as ApiQueryKey ) ,
5255 queryFn : pathParams === skipToken ? skipToken : apiFetch < TActualData > ,
5356 enabled : pathParams !== skipToken ,
5457 staleTime,
@@ -79,10 +82,9 @@ function _apiOptionsInfinite<
7982 const url = getApiUrl ( path , ...( [ { path : pathParams } ] as OptionalPathParams < TApiPath > ) ) ;
8083
8184 return infiniteQueryOptions ( {
82- queryKey :
83- Object . keys ( options ) . length > 0
84- ? ( [ { infinite : true , version : 'v2' } , url , options ] as InfiniteApiQueryKey )
85- : ( [ { infinite : true , version : 'v2' } , url ] as InfiniteApiQueryKey ) ,
85+ queryKey : hasDefinedValues ( options )
86+ ? ( [ { infinite : true , version : 'v2' } , url , options ] as InfiniteApiQueryKey )
87+ : ( [ { infinite : true , version : 'v2' } , url ] as InfiniteApiQueryKey ) ,
8688 queryFn : pathParams === skipToken ? skipToken : apiFetchInfinite < TActualData > ,
8789 getPreviousPageParam : parsePageParam ( 'previous' ) ,
8890 getNextPageParam : parsePageParam ( 'next' ) ,
0 commit comments