useIsDataApiEnabled.ts15 lines · main
| 1 | import { useProjectPostgrestConfigQuery } from '@/data/config/project-postgrest-config-query' |
| 2 | |
| 3 | /** |
| 4 | * Returns whether the Data API is enabled for the given project. |
| 5 | * |
| 6 | * The Data API is considered enabled when the PostgREST `db_schema` config |
| 7 | * contains at least one non-empty schema name. |
| 8 | */ |
| 9 | export const useIsDataApiEnabled = ({ projectRef }: { projectRef?: string }) => { |
| 10 | const { data: config, ...rest } = useProjectPostgrestConfigQuery({ projectRef }) |
| 11 | |
| 12 | const isEnabled = !!config?.db_schema?.trim() |
| 13 | |
| 14 | return { ...rest, data: isEnabled, isEnabled } |
| 15 | } |