Netflix / dgs-framework

GraphQL for Java with Spring Boot made easy.
https://netflix.github.io/dgs
Apache License 2.0
3.03k stars 286 forks source link

Fix handling of @InputArgument for Java objects with optionals. #1926

Closed srinivasankavitha closed 6 days ago

srinivasankavitha commented 1 month ago

Pull Request type

Changes in this PR

This PR fixes handling of @InputArgument for optionals. The current implementation of the DefaultInputObjectMapper does not handling converting from map to optionals, resulting in the following error when used:

**Failed to convert from type [java.util.LinkedHashMap<?, ?>] to type [@com.netflix.graphql.dgs.InputArgument 

Conversion of String to Optional, for e.g works fine since Spring's ObjectToOptionalConverter handles this fine: https://github.com/spring-projects/spring-framework/blob/main/spring-core/src/main/java/org/springframework/core/convert/support/ObjectToOptionalConverter.java

Adding similar logic to the DefaultInputObjectMapper to handle optionals based on this code: https://github.com/spring-projects/spring-framework/blob/main/spring-core/src/main/java/org/springframework/core/convert/support/ObjectToOptionalConverter.java#L76

Describe the new behavior from this PR, and why it's needed Issue #1925

filippocozzini commented 6 days ago

Any update?

srinivasankavitha commented 6 days ago

Any update?

Sorry for the delay. I need to address some of the comments before I can push the fix through.

srinivasankavitha commented 6 days ago

Declining this PR in favor of a better fix here: https://github.com/Netflix/dgs-framework/pull/1951