---
id: w4/m14/t001
title: GraphQL operation for `auditLogs` + dashboard codegen wiring
worker: worker4
status: done
estimate: 30m
depends_on: []
---

## Objective

Add the dashboard-side GraphQL operation for bex-api's `auditLogs` root query so the rest of this milestone has typed query/response shapes to build against.

## Context

- Backend contract (`lego/backend/internal/audit/graphql.go`, shipped w4/m10): `auditLogs(ownerId: String!, startTime: String, endTime: String, cursor: String, limit: Int): [AuditLog]` — a **bare list**, no `{object, cursor}` envelope. Fields: `id`, `timestamp` (RFC3339 string), `actor`, `actorMethod`, `action`, `status` (`"success"` | `"denied"`), `resource`.
- Since there's no envelope, the "next cursor" for pagination is the **last returned item's `id`** — the REST/GraphQL surface's keyset paging is `(at, id)` descending (`internal/store/audit.go`), so passing the last item's id as `cursor` resumes strictly after it.
- Dashboard convention: one `<feature>/api/<feature>.graphql` file, `yarn codegen` generates types into `src/graphql/definitions.ts` (`dashboard/CLAUDE.md` § GraphQL). Codegen needs a live bex-api + `CODEGEN_SESSION_TOKEN`; if unavailable in this environment, add the operation by hand to `definitions.ts` matching the known schema (precedent: w4/m6.5 t001) and note it needs a real `yarn codegen` pass later.
- Follow `team.graphql`'s comment-header style (`dashboard/src/features/team/api/team.graphql`): a short header explaining what backend surface this queries and why.

## Steps

1. Create `dashboard/src/features/audit/api/audit.graphql` with an `AuditLogs($ownerId: String!, $startTime: String, $endTime: String, $cursor: String, $limit: Int)` query requesting `id timestamp actor actorMethod action status resource`.
2. Run `yarn codegen` (or hand-add to `definitions.ts` if no live backend is reachable, documenting that in this task's resolution).
3. Confirm the generated/added types compile (`yarn typecheck`).

## Files

- `dashboard/src/features/audit/api/audit.graphql` (new)
- `dashboard/src/graphql/definitions.ts` (generated or hand-added)

## Acceptance criteria

- [ ] `AuditLogs` query defined, typed, and importable.
- [ ] `yarn typecheck` passes.

## Out of scope

- The hook that calls this query (t002).
