---
id: w8/m2/t002
title: GraphQL adapter — dashboard usage query (companion style)
worker: worker8
status: todo
estimate: 30m
depends_on: [w8/m2/t001]
---

## Objective

Expose the core verb as a dashboard GraphQL query in companion style next to the existing `monthToDateBandwidth` field — workspace-scoped `usage` returning compute (per service/tier), bandwidth, and build-time quantities for the current month.

## Context

- `lego/backend/internal/metrics/graphql.go` holds `monthToDateBandwidth` — the naming/shape precedent for dashboard companions.
- The new field lives in `internal/usage/graphql.go` (per-feature GraphQL contribution, like `internal/postgres/graphql.go`), registered in the API server's schema assembly.
- Stay dashboard-consistent with Render's GraphQL where shapes are capturable; where not, name fields in Render's vocabulary (compute, bandwidth, pipeline minutes).

## Steps

1. Define the GraphQL object types + `usage` field over the t001 verb.
2. Register in the schema; confirm via the GraphQL playground/introspection.
3. Adapter test asserting field names and that values pass through unmangled.

## Files

- `lego/backend/internal/usage/graphql.go` (+ test)
- API server schema wiring (`lego/backend/internal/api/`)

## Acceptance criteria

- [ ] Introspection shows the `usage` query; a fake-store query returns the expected shape.

## Out of scope

- Dashboard client wiring (w8/m3).
