Lesson 2 of 9 · 23m
Nullability, Deprecation, and Schema Evolution
How to choose nullable versus non-null fields, evolve a graph without breaking deployed clients, and use deprecation as an operational process.
The most expensive GraphQL decision is often one tiny !. New schema designers either make everything nullable, which pushes defensive checks into every client, or make everything non-null, which turns one resolver failure into a blank screen. There is no universal rule. There is a useful question: if this value cannot be produced, should the parent object still be usable?
Nullability is error containment
In GraphQL, when a non-null field errors, null propagates upward until it reaches a nullable position or the root. That means this schema makes one bad invoice destroy the workspace payload:
type Workspace {
invoices: [Invoice!]!
}
type Invoice {
amountDue: Int! # resolver throws because billing provider timed out
}If the invoice list can still be useful without amountDue, make the field nullable:
type Invoice {
amountDue: Int
amountDueStatus: MoneyStatus!
}
enum MoneyStatus {
AVAILABLE
UNAVAILABLE
}For truly load-bearing identity fields — id, and usually the object type itself — non-null is appropriate. For integration-backed data, nullable plus an explicit state is often more honest.
Lists need two decisions
[Invoice!]! says: the list itself is always present, and every element is a real invoice. That is usually right for collections you control. [Invoice] says elements may be null because partial failures are expected. In practice, most product lists should be non-null lists of non-null items unless partial failure is a normal operating mode.
Evolution rules that keep clients alive
Safe changes:
- Add a new object type, field, enum value with client-aware rollout, input field with a default behavior, or optional argument.
- Deprecate an existing field.
- Widen a nullable response in rare cases, after checking client assumptions.
Dangerous or breaking changes:
- Remove or rename a field, type, enum value, or argument.
- Change a field type, including nullability tightening.
- Make an input field required.
- Reuse an enum value with a different meaning.
type Member {
email: String! @deprecated(reason: "Use contactEmail; removed after 2026-03-01")
contactEmail: String!
}Deprecation is not documentation theater. Track usage by client and operation hash, contact owners, and remove only after measured traffic reaches zero.
Enum additions are deploy-order changes
Adding an enum value is additive on the wire, but old clients may not know how to render it. Coordinate the rollout: teach clients to handle UNKNOWN-style fallback behavior first, then let producers emit the new value. GraphQL has no magic versioning here; mobile release trains make it your problem.
Field notes
- Never tighten a response field from nullable to non-null without treating it as a breaking change.
- A default input behavior must be deterministic; implicit defaults become folklore quickly.
- Schema registry checks should compare against the published schema, not just the previous commit.
- Deprecations need owners and deadlines, or they become decorative comments.
- If clients routinely use
!in TypeScript generated types, your schema is lying about nullability.
Was this lesson helpful?