Skip to content

Fix null input handling #3403

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

Merged
merged 8 commits into from
Apr 28, 2025
Merged

Fix null input handling #3403

merged 8 commits into from
Apr 28, 2025

Conversation

CarsonF
Copy link
Member

@CarsonF CarsonF commented Apr 26, 2025

Handle GraphQL nulls from "optional" fields as undefined.

GraphQL's / Nest's decorators have nullable option, which means the value can be null or omitted - which naturally translates to null or undefined in JS.

We actually care about this distinction, though, especially on update mutations.
undefined means no change.
null means clear the value.

We carelessly allowed both meaningly that nulls could mistakenly be stored in lots of spots that are unexpected.
Granted, this only would happen in Neo4j, as Gel's schema checks would prevent this.

Going forward we have a new optional option as a sibling to nullable.
optional lets the field be omitted or undefined. GraphQL can still give us nulls, but be will we convert them to undefined.
nullable continues to let null & undefined through.


I also added null types where we actually expect/allow nulls.

I also created ListField to help dedupe items, and convert empty lists to undefined (for filters), and to disallow empty arrays where expected.

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

Copy link

github-actions bot commented Apr 26, 2025

🗞 GraphQL Summary

View schema changes
@@ -2601,9 +2601,9 @@
   presetInventory: Boolean
   registryOfDialectsCode: String
   registryOfLanguageVarietiesCode: String
 
-  """Only languages with these sensitivities"""
+  """Only these sensitivities"""
   sensitivity: [Sensitivity!]
 }
 
 input LanguageListInput {
@@ -4861,9 +4861,9 @@
   presetInventory: Boolean
   primaryLocation: LocationFilters
   primaryPartnership: PartnershipFilters
 
-  """Only projects with these sensitivities"""
+  """Only these sensitivities"""
   sensitivity: [Sensitivity!]
 
   """Only projects matching these statuses"""
   status: [ProjectStatus!]

@CarsonF CarsonF force-pushed the bugfix/null-inputs branch from b10b9b1 to 85a5eac Compare April 26, 2025 15:25
CarsonF added 6 commits April 26, 2025 12:20
GraphQL's / Nest's decorators have `nullable` option,
which means the value can be null or omitted.
Which naturally translates to null or undefined in JS.

We actually care about this distinction, though, especially on update mutations.
undefined means no change.
null means clear the value.

We carelessly allowed both meaningly that nulls could mistakenly be stored in lots of spots that are unexpected.
Granted, this only would happen in Neo4j, as Gel's schema checks would prevent this.

Going forward we have a new `optional` option as a sibling to `nullable`.
`optional` lets the field be omitted or undefined. GraphQL can still give us nulls, but be will we convert them to undefined.
`nullable` continues to let null & undefined through.
@CarsonF CarsonF force-pushed the bugfix/null-inputs branch from 6e062e6 to 906f47d Compare April 26, 2025 17:21
@CarsonF CarsonF force-pushed the bugfix/null-inputs branch from 9fc6395 to a24814c Compare April 28, 2025 21:21
@CarsonF CarsonF merged commit c4db4ba into develop Apr 28, 2025
18 checks passed
@CarsonF CarsonF deleted the bugfix/null-inputs branch April 28, 2025 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant