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.
22 lines
869 B
TypeScript
22 lines
869 B
TypeScript
import { useQuery } from '@tanstack/react-query'
|
|
import { fetchHandler } from 'data/fetchers'
|
|
import { BASE_PATH } from 'lib/constants'
|
|
import type { ResponseError, UseCustomQueryOptions } from 'types'
|
|
|
|
export async function getDeploymentCommit(signal?: AbortSignal) {
|
|
const response = await fetchHandler(`${BASE_PATH}/api/get-deployment-commit`)
|
|
return (await response.json()) as { commitSha: string; commitTime: string }
|
|
}
|
|
|
|
export type DeploymentCommitData = Awaited<ReturnType<typeof getDeploymentCommit>>
|
|
|
|
export const useDeploymentCommitQuery = <TData = DeploymentCommitData>({
|
|
enabled = true,
|
|
...options
|
|
}: UseCustomQueryOptions<DeploymentCommitData, ResponseError, TData> = {}) =>
|
|
useQuery<DeploymentCommitData, ResponseError, TData>({
|
|
queryKey: ['deployment-commit'],
|
|
queryFn: ({ signal }) => getDeploymentCommit(signal),
|
|
...options,
|
|
})
|