Input Types in codegen: optional properties should be Optional<>
#2054
Replies: 2 comments
-
I found a related discussion and PR, but have no idea how to use it. 😟 (I assume this is because it has nothing to do with codegen) |
Beta Was this translation helpful? Give feedback.
-
I finally figured it out: when manually implementing the Input classes the Absence of a Property can easily be determined by utilizing I believe this functionality should be available as a code generation option, as implementing these classes feels overly repetitive and unnecessary. Perhaps once I gain more experience with DGS and Kotlin, I’ll consider contributing a feature for it. For now, though, my issue is resolved. Also I don't know if this feature is properly documented or maybe I just missed it? |
Beta Was this translation helpful? Give feedback.
-
The graphqls description
incorrectly generates
SomeInput.java
When
@InputArgument SomeInput input
is used in a resolver (data fetcher) there is no way to distinguish betweeninput.title
was provided with valuenull
input.title
is absent (wasn't provided by the user)I therefore expected
SomeInput.java
to look liketo support the use case above (distinguish between null and absence for partial updates for example)
As a workaround we can use the
DataFetchingEnvironment
to check for certain fields but this pollutes the code base and doesn't feel good.Is there an option we can set for code generation to replace
T
withOptional<T>
or am I misunderstanding something here?Beta Was this translation helpful? Give feedback.
All reactions