Workflow: Integrate GraphQL
Objective
Add a GraphQL query/mutation integration with minimal field selection, partial-error handling, DTO→entity mapping, and tests — behind a repository.
Inputs
- GraphQL schema / operation, variables, and the fields the UI actually needs.
- Sample response(s), including a partial-error response.
Outputs
- Operation (query/mutation) with variables, response DTO, mapper, repository method, tests.
Step-by-Step Process
- Design the operation (Backend Integrator) — select only needed fields; use fragments + variables (see
skills/networking/ios/graphql.md). - Define the response DTO matching the selected shape; capture fixtures (incl.
errors). - Handle partial failures — check the
errorsarray even on HTTP 200; map to a typed error. - Map DTO→entity; unit-test mapping with fixtures.
- Implement the repository method using the GraphQL client; choose a cache policy.
- Auth (Security Expert) — headers, token refresh, no leakage.
- Integration-test decode + error handling.
- Review against
checklists/api_review.md.
Validation Steps
- Only required fields are requested; inputs passed as variables.
errorsarray handled even on 200.- Mapping pure and tested; generated/DTO types not leaked to the UI.
Failure Scenarios
- Partial data + errors → decide per field: surface error vs. render partial; document.
- Over-fetching → trim the selection set.
- N+1 / large query → split or paginate; coordinate with backend.
AI Agent Instructions
- Always check
errorseven on HTTP 200; never interpolate inputs into the query string. - Request the minimal field set; map DTOs to domain entities behind a repository.
- Generate fixtures (success + partial error) and tests.
Acceptance Criteria
- [ ] Operation uses variables/fragments; minimal fields.
- [ ] Partial errors handled and typed.
- [ ] Mapping tested; no generated types in Presentation.
- [ ] Auth handled;
checklists/api_review.mdpasses.