Skip to content

Fix GraphqlDecoder Optional record fields and non-nullable list nulls#3272

Merged
velo merged 2 commits intomasterfrom
fix/graphql-decoder-optional-and-list-nulls
Mar 17, 2026
Merged

Fix GraphqlDecoder Optional record fields and non-nullable list nulls#3272
velo merged 2 commits intomasterfrom
fix/graphql-decoder-optional-and-list-nulls

Conversation

@velo
Copy link
Copy Markdown
Member

@velo velo commented Mar 17, 2026

Summary

  • Optional record fields: GraphqlDecoder now properly returns Optional.empty() instead of null for Optional-typed record fields. The decoder manually constructs records with Optional fields to avoid Jackson's convertValue limitation, recursively handling N-level deep nested records.
  • Non-nullable list return types: Collection/array return types never return null — the decoder returns empty collections for null body, null operation data, and any other null-producing code path.

Test plan

  • Added test: decodesRecordWithOptionalFieldPresent
  • Added test: decodesRecordWithOptionalFieldNull — verifies Optional.empty() not null
  • Added test: decodesRecordWithOptionalFieldMissing — verifies Optional.empty() not null
  • Added test: decodesNestedRecordWithOptionalFields — 2-level deep
  • Added test: decodesDeeplyNestedRecordWithOptionalFields — 3-level deep
  • Added test: returnsEmptyListForNullBody
  • Added test: returnsEmptyListForNullOperationDataWithListType
  • All 45 graphql module tests pass

🤖 Generated with Claude Code

@velo velo merged commit e0c1d64 into master Mar 17, 2026
4 checks passed
@velo velo deleted the fix/graphql-decoder-optional-and-list-nulls branch March 17, 2026 10:35
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