useIsDataApiEnabled.ts 562 B

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