---
id: w5/m8/t002
title: databases.graphql operations + codegen; postgres-tier catalog read (small lego/backend add)
worker: worker5
status: done
estimate: 40m
depends_on: [w5/m8/t001]
---

## Objective

Author the GraphQL operation documents for the whole milestone — `databases`, `database(id)`, `databaseConnectionInfo(id)` queries and `createDatabase` / `deleteDatabase` mutations — plus a postgres-family tier-catalog read so the create dialog's plan picker sources real tiers from `lego/types/tiers` instead of hardcoding a ladder (the fourth-copy trap w5/m7 closed for compute).

## Context

- bex-api already serves all five database operations (`docs/ADR006-bex-api.md` §Managed Postgres); the GraphQL schema is captured in `dashboard/src/graphql/definitions.ts`.
- The `instanceTypes` query (w5/m7 t001, `lego/backend`) projects only `tiers.Compute`; the catalog also carries postgres families (w1/m8). Extend the surface — either a family argument or a sibling query — following m7's precedent (`core.RelCanView`-guarded, auto-swept by `TestAuthzGuardsEveryVerb`).
- Codegen against prod needs `CODEGEN_SESSION_TOKEN` (401 without); w5/m4 hand-mirrored operations in exact codegen format and verified round-trip via `graphql.print` — same fallback applies.

## Steps

1. Extend the backend catalog query to the postgres family (`lego/backend`, guarded like `instanceTypes`); Go build/tests green.
2. Author `dashboard/src/features/databases/api/databases.graphql` with the three queries + two mutations in Render's dashboard shapes; run/mirror codegen.
3. Add the feature's TS types + a `use-databases` hook skeleton (list + byId), mirroring `features/services` conventions.

## Files

- `lego/backend/internal/...` (catalog query extension + test)
- `dashboard/src/features/databases/api/databases.graphql`, `dashboard/src/features/databases/types.ts`, `dashboard/src/features/databases/hooks/`
- `dashboard/src/graphql/definitions.ts` (if schema mirror needs the new field)

## Acceptance criteria

- [ ] All five database operations authored and type-checked; round-trip via `graphql.print` if codegen is tokenless.
- [ ] Postgres tiers readable via GraphQL, sourced from `lego/types/tiers` (no frontend tier list); backend authz sweep still green.

## Out of scope

- Any page/component UI (t003–t005); REST/MCP catalog endpoints.
