Designing a GraphQL schema: nullability and safe changes
Designing a GraphQL schema means defining what values fields promise and how failures affect responses, not merely declaring types. A non-null marker (!) lets clients rely on a value, but an execution error can propagate null to a parent response position. Plan schema changes so new capabilities can be added without breaking existing operations, and retire old fields gradually.
Designing a GraphQL schema means defining what values fields promise and how failures affect responses, not merely declaring types. A non-null marker (!) lets clients rely on a value, but an execution error can propagate null to a parent response position. Plan schema changes so new capabilities can be added without breaking existing operations, and retire old fields gradually.
This guide covers application-facing schemas written in GraphQL SDL. It does not prescribe a server library, database model, or deployment tool. The product catalog is illustrative.
Do not copy database tables into the schema
A GraphQL schema describes the capabilities and value types a client can request. It does not require exposing storage tables. Model the objects, fields, relationships, arguments, and inputs that consumers need; resolvers and authorization logic can connect them to existing stores or services. Keeping the public contract separate lets the implementation change without forcing the same change on clients.
Output object fields are data clients select. Arguments and input objects are values clients send. Output object, interface, and union types cannot be used as inputs; define a separate input type for structured mutations.
"A product sold in the catalog"
type Product {
id: ID!
name: String!
price: Money
availability: Availability!
}
"An amount with an explicit currency"
type Money { amount: String!, currency: Currency! }
enum Currency { USD EUR }
enum Availability { IN_STOCK OUT_OF_STOCK UNKNOWN }
type Query { product(id: ID!): Product }
input UpdateProductInput { name: String, price: MoneyInput }
input MoneyInput { amount: String!, currency: Currency! }Money is an illustrative contract. Choose precision, supported currencies, and conversion rules from actual requirements. GraphQL's built-in Int is a signed 32-bit integer; do not use it blindly for large monetary amounts.
Choose ! and list types based on failure behavior
Fields are nullable by default. String may return a string or null; String! promises a value. If execution returns null or raises an error at a non-null position, the error can propagate to the nearest nullable parent. Thus ! means the server can uphold the guarantee, not merely that a value is usually present.
For lists, choose nullability of the list and its items separately:
| SDL type | Meaning |
|---|---|
[Product] | List and items may be null |
[Product!] | List may be null; items may not |
[Product]! | List may not be null; items may |
[Product!]! | Neither list nor items may be null |
If a list can be returned while an individual item may fail because of authorization or a remote-service error, [Product] may fit. If every item must be valid, [Product!]! may fit, but a single item error can null the whole list and possibly its parent. Decide from real failure paths and client behavior.
A null field can mean not yet available, absent, hidden by authorization, or temporarily failed. If clients must distinguish these states, model an explicit status or result type and document it rather than overloading one nullable value.
Define omitted and null input semantics
An omitted input field can differ from an explicitly supplied null. For an update, omission might preserve the current description while description: null clears it. GraphQL can express this distinction, but resolvers and business rules must implement it.
Before using an input such as UpdateProductInput, specify what omission, null, and a value mean for each field. Check how client languages represent the distinction. Use an explicit flag such as clearDescription or variant inputs if that is clearer. Adding a new non-null input field can invalidate old operations that do not provide it.
Evolve the contract additively
Removing or renaming fields and types, changing a field type, making an optional argument required, or changing a non-null output to nullable can break existing operations. Adding enum values or new union/interface cases can also affect clients that handle every known case exhaustively.
When replacing a field:
Add the replacement alongside the old field and confirm it works for clients.
Mark the old field with `@deprecated(reason: "Use newField...")` and state the replacement.
Monitor actual usage and coordinate a migration period and removal criteria.
Remove the old field only after evidence shows it is no longer used.
For example, add givenName and familyName before retiring fullName; keep the old field working by composing the new values. @deprecated is guidance, not an automatic shutdown.
Review before changing a schema
Which fields, arguments, and generated types do current clients use?
Do nullability and list-item rules match error, authorization, and partial-result cases?
Can a new argument be optional or have a default to preserve old operations?
Can clients handle new enum or abstract-type cases safely?
Are the deprecation reason, replacement, usage check, and removal criteria clear?
Do descriptions explain units, null meanings, and omitted-input behavior?
Have schema-diff tooling and representative client operations checked the change?
Schema checkers can flag compatibility risks, but they cannot fully predict how each runtime handles unknown enum cases or nulls. Compatibility is a contract across consumer operations and rollout practice, not a property guaranteed by the schema declaration alone.
Sources
[GraphQL schema design](https://graphql.org/learn/schema-design/)
[GraphQL schemas and types](https://graphql.org/learn/schema/)
[GraphQL specification: type system and null propagation](https://spec.graphql.org/September2026/)
[Schema change management](https://www.graphql.org/learn/governance-versioning/)
[Review and validate schema changes](https://www.graphql.org/learn/schema-review/)
[Naming conventions and design standards](https://www.graphql.org/learn/naming-design/)