mirror of
https://github.com/supabase/supabase.git
synced 2026-05-09 00:10:05 +08:00
* Add custom types for queries, mutations and infinite queries. * Migrate all queries to use the new type. * Migrate all infinite queries to useCustomInfiniteQueryOptions. * Migrate all mutations to use useCustomMutationOptions. * Add type to all imports in `types` folder.
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { useQuery } from '@tanstack/react-query'
|
|
|
|
import { get } from 'data/fetchers'
|
|
import type { ResponseError, UseCustomQueryOptions } from 'types'
|
|
import { integrationKeys } from './keys'
|
|
|
|
// FIXME(kamil): Do not retry, a single check is fine.
|
|
export async function getGitHubAuthorization(signal?: AbortSignal) {
|
|
const { data, error } = await get('/platform/integrations/github/authorization', {
|
|
signal,
|
|
})
|
|
return error ? null : data
|
|
}
|
|
|
|
export type GitHubAuthorizationData = Awaited<ReturnType<typeof getGitHubAuthorization>>
|
|
export type ProjectGitHubRepositoryConnectionsData = Awaited<
|
|
ReturnType<typeof getGitHubAuthorization>
|
|
>
|
|
export type GitHubAuthorizationError = ResponseError
|
|
|
|
export const useGitHubAuthorizationQuery = <TData = GitHubAuthorizationData>({
|
|
enabled = true,
|
|
...options
|
|
}: UseCustomQueryOptions<GitHubAuthorizationData, GitHubAuthorizationError, TData> = {}) => {
|
|
return useQuery<GitHubAuthorizationData, GitHubAuthorizationError, TData>({
|
|
queryKey: integrationKeys.githubAuthorization(),
|
|
queryFn: ({ signal }) => getGitHubAuthorization(signal),
|
|
enabled,
|
|
staleTime: 0,
|
|
...options,
|
|
})
|
|
}
|