| name | schema-update |
| description | Use when updating the SDK GraphQL schema from a local or staging API server |
Update GraphQL Schema
Updates the SDK's GraphQL schema and related types from an API server instance.
Usage
/schema-update local # Download from local server
/schema-update staging # Download from staging server
/schema-update # Will prompt for server choice
Checklist
You MUST use TodoWrite to create a todo for EACH step below. Mark each complete only after verification.
Download Schema
Update Documents
Check for New Enums
Export Input Types
Update URQL Cache Configuration
Update packages/client/src/cache.ts to handle new/removed types:
Keys Section
Resolvers Section
Add field transformers for enhanced client-side types:
Common Patterns
- Activity types (
*Activity) typically have timestamp: DateTime! → use transformToDate
- Types with
createdAt: DateTime (nullable) → use transformToNullableDate
- Types with
createdAt: DateTime! (non-nullable) → use transformToDate
- Health factor types have nullable
BigDecimal fields → use transformToNullableBigDecimal
Update Wrapped-Native Transform Lists
When new object types are added to the schema, evaluate whether they belong in packages/client/src/displayTransform.ts:
Note: Types in neither list are transparent — they inherit the transform context from their parent. Only add a type when it needs to change the context (turn it on or off).
Validate
IMPORTANT: Do not mark the schema update complete until build and all tests pass.
Code Patterns
Enum Definition (enums.ts)
export enum EnumName {
VALUE_ONE = 'VALUE_ONE',
VALUE_TWO = 'VALUE_TWO',
}
Scalar Binding (graphql.ts)
import type { ..., EnumName } from './enums';
scalars: {
...
EnumName: EnumName,
...
}
Input Type Export
export type InputName = ReturnType<typeof graphql.scalar<'InputName'>>;
Stop Conditions
| Condition | Action |
|---|
| Schema download fails | Check if server is running, verify URL |
pnpm check fails | Fix document errors before proceeding |
| Build fails | Fix TypeScript errors, re-run build until it passes |
| Tests fail | Investigate and fix failing tests, re-run until all pass |
Never mark the schema update as complete while build errors or test failures exist. The iterative fix-and-verify loop is mandatory.
Common Mistakes
- Creating type exports for enums - Enums are both values and types; don't use
ReturnType<typeof graphql.scalar<'EnumName'>>
- Adding new queries/mutations without being asked - Only update existing documents unless explicitly requested
- Forgetting scalar bindings - Every input type needs a corresponding entry in
graphql.ts
- Non-alphabetical ordering - Scalar bindings should be alphabetically ordered
- Missing JSDoc comments - All enums should have documentation
- Forgetting cache.ts updates - New types need keys configuration; types with DateTime/BigDecimal/BigInt need resolvers
- Wrong nullable transformer - Use
transformToNullableDate/transformToNullableBigDecimal for nullable fields, non-nullable variants for required fields
- Missing type imports in cache.ts - Add imports for any new types used in the keys section
- Marking complete with failing build/tests - Always run
pnpm build and pnpm test --run and fix all errors before marking complete
- Skipping the wrapped-native transform evaluation - Every new object type must be checked against
WRAPPED_NATIVE_TRANSFORM_ALLOWLIST / WRAPPED_NATIVE_TRANSFORM_BLOCKLIST in displayTransform.ts; silently omitting it can cause wrong token display