Use semantic nullability with @throwOnFieldError and @catch#346
Merged
captbaritone merged 1 commit intoMay 22, 2026
Merged
Conversation
Replace @killsParentOnException with @semanticNonNull for non-spec fields by enabling Grats' strictSemanticNullability. Spec-required non-null fields (Node.id, PageInfo.hasNextPage/hasPreviousPage, Edge.cursor, Connection.pageInfo) keep @killsParentOnException. On the client side, add @throwOnFieldError to all queries and fragments so Relay generates non-null types for @semanticNonNull fields, and @catch on mutations since @throwOnFieldError doesn't support mutation definitions. Add per-todo ErrorBoundary so field errors only take down the affected todo item rather than the entire app.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
strictSemanticNullability+nullableByDefaultto replace@killsParentOnExceptionwith@semanticNonNullfor non-spec fields@killsParentOnExceptionon the 5 spec-required fields:Node.id,PageInfo.hasNextPage/hasPreviousPage,Edge.cursor,Connection.pageInfo@throwOnFieldErrorto all client queries and fragments so Relay generates non-null types for@semanticNonNullfieldsErrorBoundaryso a field error only takes down the affected todo item, not the entire appWhy
@killsParentOnExceptionmakes fields!in the schema, but if a resolver throws, the error propagates up and nulls out the nearest nullable ancestor — potentially taking down large portions of the response. Semantic nullability decouples error handling from nullability: fields stay nullable in the schema (with@semanticNonNullannotation), and clients that handle errors out-of-band (via@throwOnFieldError) get non-null types with explicit error handling.Test plan
npx gratsregenerates schema with@semanticNonNulldirectives on non-spec fields, spec fields remain!yarn relaycompiles successfullynpx tsc --noEmitpasses with no type errors