GraphQL fundamentalseasy0-2 years
A frontend team says a field, `order.customer.name`, sometimes comes back `null` even though the customer definitely exists and `name` is declared `String!` in the schema. `String!` is supposed to mean "never null" — so what's actually happening?
! isn't a guarantee the engine enforces against the database — it's a promise a resolver has to keep, and when a resolver can't keep it, the engine doesn't lie about it, it nulls the field that failed and walks up. If the customer resolver on Order throws — a timeout, a downstream outage, a bug — the engine can't produce a non-null Customer, so order.customer becomes null. If Order.customer is itself typed non-null in the schema, that null can't stop there either, so it keeps bubbling up to the next field, and the next, until it reaches a field that's actually allowed to be null, or the whole response. name reading null almost always means something failed a level or two above it, not that the name resolver itself returned null.