@@ -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 stripUndefinedValues ( obj : Record < string , unknown > ) : Record < string , unknown > {
27+ return Object . fromEntries ( Object . entries ( obj ) . filter ( ( [ , v ] ) => v !== undefined ) ) ;
28+ }
29+
2630const selectJson = < TData > ( data : ApiResponse < TData > ) => data . json ;
2731
2832export const selectJsonWithHeaders = < TData > (
@@ -43,11 +47,12 @@ function _apiOptions<
4347 : [ Options & PathParamOptions < TApiPath > ]
4448) {
4549 const url = getApiUrl ( path , ...( [ { path : pathParams } ] as OptionalPathParams < TApiPath > ) ) ;
50+ const strippedOptions = stripUndefinedValues ( options ) ;
4651
4752 return queryOptions ( {
4853 queryKey :
49- Object . keys ( options ) . length > 0
50- ? ( [ { infinite : false , version : 'v2' } , url , options ] as ApiQueryKey )
54+ Object . keys ( strippedOptions ) . length > 0
55+ ? ( [ { infinite : false , version : 'v2' } , url , strippedOptions ] as ApiQueryKey )
5156 : ( [ { infinite : false , version : 'v2' } , url ] as ApiQueryKey ) ,
5257 queryFn : pathParams === skipToken ? skipToken : apiFetch < TActualData > ,
5358 enabled : pathParams !== skipToken ,
@@ -77,11 +82,12 @@ function _apiOptionsInfinite<
7782 : [ Options & PathParamOptions < TApiPath > ]
7883) {
7984 const url = getApiUrl ( path , ...( [ { path : pathParams } ] as OptionalPathParams < TApiPath > ) ) ;
85+ const strippedOptions = stripUndefinedValues ( options ) ;
8086
8187 return infiniteQueryOptions ( {
8288 queryKey :
83- Object . keys ( options ) . length > 0
84- ? ( [ { infinite : true , version : 'v2' } , url , options ] as InfiniteApiQueryKey )
89+ Object . keys ( strippedOptions ) . length > 0
90+ ? ( [ { infinite : true , version : 'v2' } , url , strippedOptions ] as InfiniteApiQueryKey )
8591 : ( [ { infinite : true , version : 'v2' } , url ] as InfiniteApiQueryKey ) ,
8692 queryFn : pathParams === skipToken ? skipToken : apiFetchInfinite < TActualData > ,
8793 getPreviousPageParam : parsePageParam ( 'previous' ) ,
0 commit comments