-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Do not output undefined
for nullable fields within @throwOnFieldError
and @catch
#4974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
eb5b277
to
8b282f3
Compare
@captbaritone I've opted into always generating the nullable types in the raw response type without |
@tobias-tengler Yeah, while I think you are correct that we should not allow optional types in raw response (since the server will never omit fields) in practice since they are currently typed that way it will be a major breaking change to update that behavior. At the very least we will need a feature flag, but I think bundling that flag (and therefor the PR) with a larger rethinking of raw response types makes more sense to me. |
06de7f7
to
ac450a8
Compare
@captbaritone That's what I thought. I've updated the PR to only contain the change that |
undefined
for nullable fields within @throwOnFieldError
and @catch
I'm going to import this and see what breaking type changes is produces for us. |
@captbaritone has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Hmm. Looks like this creates many thousands of Flow issues internally. On common case seems to be people defining their own types to model a piece of a fragment and then assigning a bit of the Relay data into that type, which won't work. |
Interesting. At least with TypeScript it shouldn't be an issue, since the user defined type would have to be the same as Relay's current type ( Regarding Flow: The example you've made doesn't seem to reflect my changes. In your example the original Relay type is somehow just - +someField?: string
+ +someField: string | null But looking at the snapshots, the original Relay type of a nullable field should be - +someField: ?string,
+ +someField: string | null, Do you know why your original types do not include |
Hmm. You're right. I think my example is not quite representative. Let me try to get one that's a direct reduction of the issue I saw internally. |
ed92970
to
33f2f9e
Compare
@captbaritone did you manage to find a better example? |
Since
@throwOnFieldError
or@catch
will catch missing data errors, we can output nullable fields in the$data
type asfield: Type | null
instead offield: Type | null | undefined
(unless optional).Closes #4971
Supersedes #4972