---
id: w4/m6.5/t001
title: "GraphQL operations + codegen for env vars (queries + mutations) in the dashboard Apollo layer"
worker: worker4
status: done
estimate: 30m
depends_on: []
---

## Objective

Add the env-var GraphQL operations the dashboard needs against m6's schema and regenerate the typed Apollo hooks: the keys-only list `service(id){ envVarKeys{ id key } }`, the per-key value fetch `service(id){ envVar(key){ id key value } }`, and the mutations `setEnvVars(serviceId, envVars)` / `setEnvVar(serviceId, key, value)` / `deleteEnvVar(serviceId, key)`. Nothing renders yet — this is the data layer.

## Context

- Read `dashboard/CLAUDE.md` before editing. The dashboard is TanStack Start + Apollo + shadcn; GraphQL ops live per feature and are codegen'd to typed hooks (see `dashboard/src/features/services/api/services.graphql` and the existing `use-services`/`use-service-lifecycle` hooks).
- bex-api's env-var GraphQL (w4/m6, `docs/ADR006-bex-api.md#env-vars`): reads nest under the service (`service(id){ envVarKeys{ id key } }`, `service(id){ envVar(key){ value } }`); mutations are top-level and return a success `Boolean`. Values are never in the bulk list — fetched per key ("Show secret").
- Match the existing codegen workflow (the same one that produced `services.graphql` typed hooks).

## Steps

1. Add the env-var operations to the services feature's `.graphql` (or a new `env.graphql`).
2. Run the dashboard's GraphQL codegen; commit the generated types/hooks.
3. Add thin hooks (`use-env-vars`, `use-env-var-value`, `use-env-var-mutations`) mirroring the existing hook style.

## Files

- `dashboard/src/features/services/api/*.graphql` (+ generated output)
- `dashboard/src/features/services/hooks/use-env-vars.ts` (+ siblings)

## Acceptance criteria

- [ ] Typed hooks exist for envVarKeys, envVar(key), setEnvVars, setEnvVar, deleteEnvVar; codegen output committed.
- [ ] Hooks compile and typecheck against the live bex-api schema.

## Out of scope

- Rendering / routes (t002+); secret files / env groups (Render features bex doesn't implement).
