You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it's relatively easy to get it working for useQuery, here's my version:
import{typeUseQuerySingleReturn,useQuery}from'@supabase-cache-helpers/postgrest-react-query';importtype{PostgrestError,PostgrestSingleResponse}from'@supabase/supabase-js';importtype{UseBaseQueryOptions,UseQueryOptions}from'@tanstack/react-query';exportfunctionuseSuspenseQuery<Result>(query: PromiseLike<PostgrestSingleResponse<Result>>,config?: Omit<UseQueryOptions<PostgrestSingleResponse<Result>,PostgrestError>,'queryKey'|'queryFn'>,): UseQuerySingleReturn<Result>{//// HACK//// original useSuspenseQuery uses useBaseQuery// https://github.com/TanStack/query/blob/main/packages/react-query/src/useSuspenseQuery.ts//// aaand, original useQuery also uses useBaseQuery// https://github.com/TanStack/query/blob/main/packages/react-query/src/useQuery.ts//// Therefore, we can just pass the same config that useSuspenseQuery passes to// useBaseQuery to supabase-cache-helpers' useQuery.//constsuspense: Omit<UseBaseQueryOptions<PostgrestSingleResponse<Result>,PostgrestError>,'queryKey'|'queryFn'>={suspense: true,placeholderData: undefined,throwOnError(_error,query){returnquery.state.data===undefined;},};returnuseQuery(query,{ ...config, ...suspense}asany);}
I don't see the implementation of Tanstack router's
useSuspenseQuery()
. Is this intentional?The text was updated successfully, but these errors were encountered: