Skip to content

fix: unwrap single object from GraphQL array response#3234

Merged
velo merged 2 commits intomasterfrom
fix/graphql-array-unwrap
Feb 22, 2026
Merged

fix: unwrap single object from GraphQL array response#3234
velo merged 2 commits intomasterfrom
fix/graphql-array-unwrap

Conversation

@velo
Copy link
Copy Markdown
Member

@velo velo commented Feb 22, 2026

Summary

  • When a GraphQL query returns an array type (e.g. [Type!]) but the Java method declares a single record return type (not List<T>), GraphqlDecoder now automatically unwraps the first element from the array
  • This is a common pattern when using limit: 1 to fetch a single result from a query that returns an array type
  • If the array is empty, returns null (via Util.emptyValueOf)

Test plan

  • Unit test: unwrapsSingleObjectFromArray - single-element array with non-collection return type
  • Unit test: unwrapsFirstElementFromMultiElementArray - multi-element array takes first element
  • Unit test: returnsNullForEmptyArrayWithSingleType - empty array returns null
  • Unit test: preservesArrayWhenReturnTypeIsList - array preserved when return type is List
  • Unit test: unwrapsSingleObjectFromArrayWithDelegate - unwrapping works with delegate decoder
  • All existing tests continue to pass (32 total)

@velo velo merged commit e9d0ca0 into master Feb 22, 2026
4 checks passed
@velo velo deleted the fix/graphql-array-unwrap branch February 22, 2026 15:42
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