mirror of
https://github.com/supabase/supabase.git
synced 2026-07-05 02:24:20 +08:00
* First round of wrapping RQ errors with handleError * Remove the throw before the handleError usage. * Make the handling of an API error more versatile. Add logging in Sentry if the error is of unknown type. * Remove throwing of the handleError function. * Add return type to the handleError function to be never so that we're sure it always throws. --------- Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
30 lines
1007 B
TypeScript
30 lines
1007 B
TypeScript
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
|
|
|
|
import { get, handleError } from 'data/fetchers'
|
|
import type { ResponseError } from 'types'
|
|
import { integrationKeys } from './keys'
|
|
|
|
export async function getIntegrations(signal?: AbortSignal) {
|
|
const { data, error } = await get('/platform/integrations', {
|
|
params: { query: { integration_name: '' } },
|
|
signal,
|
|
})
|
|
|
|
if (error) handleError(error)
|
|
return data
|
|
}
|
|
|
|
export type IntegrationsData = Awaited<ReturnType<typeof getIntegrations>>
|
|
export type ProjectIntegrationConnectionsData = Awaited<ReturnType<typeof getIntegrations>>
|
|
export type IntegrationsError = ResponseError
|
|
|
|
export const useIntegrationsQuery = <TData = IntegrationsData>({
|
|
enabled = true,
|
|
...options
|
|
}: UseQueryOptions<IntegrationsData, IntegrationsError, TData> = {}) =>
|
|
useQuery<IntegrationsData, IntegrationsError, TData>(
|
|
integrationKeys.integrationsList(),
|
|
({ signal }) => getIntegrations(signal),
|
|
{ enabled: enabled, ...options }
|
|
)
|