Data API: REST, GraphQL and RLS
The Data API exposes selected Postgres tables through REST and GraphQL. Both use the same roles, column privileges and Row Level Security (RLS).
What it is
The Data API exposes selected Postgres tables through REST and GraphQL. Both use the same roles, column privileges and Row Level Security (RLS).
Quick start and CLI
infaris-guard hosting db api set <databaseId> --enabled --auth-project <projectId>
infaris-guard hosting db policies list <databaseId>
infaris-guard hosting db expose <databaseId> --schema public --table todos --roles authenticated --columns id,title --dry-run
infaris-guard hosting db expose <databaseId> --schema public --table todos --roles authenticated --columns id,title --yes
infaris-guard hosting db types <databaseId> --out src/database.types.ts
infaris-guard hosting db graphql enable <databaseId>
infaris-guard hosting db lint <databaseId>
bun add @infaris/dataSDK and code
import { createClient } from '@infaris/data';
const db = createClient(
process.env.NEXT_PUBLIC_INFARIS_DATA_URL!,
process.env.NEXT_PUBLIC_INFARIS_AUTH_KEY!,
{ accessToken: () => auth.getAccessToken() },
);
const { data, error } = await db.from('todos').select('id,title').limit(20);
if (error) throw error;
console.log(data);
// auth is your signed-in @infaris/auth-js client.
// GraphQL uses db.graphql(document, variables).Secure defaults
Enabling the API grants no table access. Create an RLS policy for your users first, then expose only required tables and columns. A publishable key uses anon; a user token uses authenticated. The secret key bypasses RLS and belongs on your server only.
Limits
Default 1,000 rows per response, maximum 10,000; 600 requests per minute per IP, maximum 6,000; body maximum 2 MiB. GraphQL has separate depth and complexity limits: see GraphQL.
FAQ
Empty list? Check grants, the active role and SELECT policy. Why does select(*) fail? An excluded column has no read privilege; name allowed columns. Drop-in Supabase client? The API is PostgREST-based, but URLs, keys and management differ.