[POC] Enable experimental semantic nullability in Grats and Relay#1
Open
captbaritone wants to merge 3 commits intomainfrom
Open
[POC] Enable experimental semantic nullability in Grats and Relay#1captbaritone wants to merge 3 commits intomainfrom
captbaritone wants to merge 3 commits intomainfrom
Conversation
captbaritone
commented
Feb 5, 2024
| import { Fragment, ReaderFragment } from 'relay-runtime'; | ||
| import { FragmentRefs } from "relay-runtime"; | ||
| export type AppChildComponent$data = { | ||
| readonly alwaysThrows: string; |
Owner
Author
There was a problem hiding this comment.
Note that this field is typed as non-nullable!
captbaritone
commented
Feb 5, 2024
| } | ||
|
|
||
| /** @gqlField */ | ||
| export function alwaysThrows(_: Query): string { |
Owner
Author
There was a problem hiding this comment.
Note that this resolver is typed as non-nullable
captbaritone
commented
Feb 5, 2024
| export type AppQuery$variables = Record<PropertyKey, never>; | ||
| export type AppQuery$data = { | ||
| readonly greeting: string | null | undefined; | ||
| readonly greeting: string; |
Owner
Author
There was a problem hiding this comment.
This field is also typed as non-nullable
captbaritone
commented
Feb 5, 2024
| fragment AppChildComponent on Query { | ||
| # When this errors, the component will throw and | ||
| # the error will be caught by the ErrorBoundary | ||
| alwaysThrows |
Owner
Author
There was a problem hiding this comment.
When this field errors, it is contained by the surrounding ErrorBoundary on line 32
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.
PR demonstrating enabling experimental support for semantic nullability in both Grats and Relay and seeing the semantic nullability of a resolver field represented in the generated types.
This depends upon a few things:
@semanticNonNullon fields which will only be null in the case of error@semanticNonNullgenerates non-nullable TypeScript types for@semanticNonNullfieldsTogether these features demonstrate the value proposition of semantic nullability:
-- https://grats.capt.dev/docs/guides/strict-semantic-nullability/#what-is-strict-semantic-nullability
Note
Parcel includes an errors overlay which catches React errors and shows an overlay in dev mode with a stack trace/component stack. You must press
escor click the "x" to see how the error case would actually render in production.