Skip to content

Commit

Permalink
Fix null comparison for skip_printing_nulls (#3784)
Browse files Browse the repository at this point in the history
Summary:
In `skip_printing_nulls` (#3626) we change some `null` values to be undefined by skipping them in the output.

Generally, the js code uses loose equality, either as
 * `field.X != null`
 * `field.X ?? default`
 * `if (field.X) {`

which allows us to do this safely.

The comparison this commit fixes was a rare exception to that showing up when using `required`, mocking data and `skip_printing_nulls` is enabled.

Pull Request resolved: #3784

Reviewed By: captbaritone

Differential Revision: D33965847

Pulled By: alunyov

fbshipit-source-id: 98f414e4f90738fcb68c940d6ce7208734c49297
  • Loading branch information
tomgasson authored and facebook-github-bot committed Feb 3, 2022
1 parent 6649f5f commit 2ec85b8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/relay-test-utils/RelayMockPayloadGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ class RelayMockPayloadGenerator {
// information came from mock resolver __typename value and it was
// an intentional selection of the specific type
const isAbstractType =
field.concreteType === null && typeName === typeFromSelection.type;
field.concreteType == null && typeName === typeFromSelection.type;

const generateDataForField = possibleDefaultValue => {
const fieldDefaultValue =
Expand Down

0 comments on commit 2ec85b8

Please sign in to comment.