Support ArgumentValue wrapper for input parameters#1450
Conversation
|
The optional specification of Java SE8 is not applicable to scala and kotlin. In the functional programming, the data class has accurately described the data type. Therefore, I think only Java needs it. |
|
I could also use some suggestions on naming: |
Maybe we don't need it, only isDefined is needed. |
Yea, I should only have one of Defined/Undefined. Maybe we should adopt the |
People from different languages and backgrounds have different norms. 😄 |
|
It looks good, just describe the option in the markdown document and wait for @kobylynskyi review. |
…rgumentValue from org.springframework.graphql.data
|
After some feedback, this has been rewritten to use ArgumentValue, rather than generating its own class that solves the same problem. Which also solves the naming problem, by adopting someone elses. |
|
Thanks for the PR. If projects are not based on spring-graphql, it might be valuable to let the wrapper type up to the user, like this: |
I thought about that, and even have had it compatible with Optional at an earlier point in the PoC. Alternative solution would be an interface, but Last good idea is a factory, that is default provided supporting Other alternative solution would be a custom object provided by this project, but that doesn't support If there is further request for some solution to support more wrappers (be it the factory or some other good idea), I'm happy to code it up. But I feel this PR is big enough. |
kobylynskyi
left a comment
There was a problem hiding this comment.
@rwo-trackunit good job! Your changes look good. I will merge this soon, wait for some other PRs to be merged and release it ASAP.
Thanks!
|
Once merged, don't hesitate to tag me in any found bugs, or suggested changes to this corner of the project. |
|
Consider squashing this PR. The commits in here includes several PoCs, so it may give a confusing git history. |
|
This was released in 5.10.0. Thanks! |
Description
When updating an object we want to support patch-like procedure:
In #966 it was debated if we could use Optional to solve this, ultimately concluding that it would not be appropriate.
This PR tries to solve it by using the existing ArgumentValue wrapper for input parameters, when that input is not mandatory and is not a list.
Example:
becomes
This works because ArgumentValue (just like Optional) is supported by spring-graphql GraphQlArgumentBinder
It is all locked behind the configuration
useWrapperForNullableInputTypes.TODO:
As I have no experience with Kotlin or Scala, this currently only works for Java.
Changes were made to: