-
Notifications
You must be signed in to change notification settings - Fork 657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate nullableFieldStyle
Configuration for Input
types and response type
?
#6175
Comments
Input
types and response type
?nullableFieldStyle
Configuration for Input
types and response type
?
About your 1st question on separating the handling of nulls in output vs input types: we don't currently have a way to do that. Can you tell us a bit more about why you'd like to treat them differently? About But operation builders makes this unnecessary:
Now when using So this becomes:
But as you noticed, with I would keep Let me know if that makes sense! |
We have some cases where the inputs for the operations are mostly static, so having to wrap them in
Since you've mentioned that we can't treat input types differently at the moment, then I don't have a reason to set QQ: We don't have a way to differentiate between input types and output types when generating the Thanks! |
Thanks a lot for the feedback - that makes sense. There is no technical limitation, but having this separation would need to add another option to the codegen which already has a lot of complexity - so ideally we'd like to avoid it for now. The ask makes sense however so let's keep this ticket open and see if it gains some traction. In the meantime I was wondering if using annotations ( |
Thanks a lot! I'm not sure about the annotations, can we apply them to the nullable fields in the generated models? |
Yes the annotations will be applied in input and output types. |
Question
I'm generating Java models and trying to configure nullable fields in the response to be wrapped in
Optional
usingnullableFieldStyle.set("javaOptional")
.However, this setting seems to be applied to both
input
types and responsetype
in the schema. Is there a way to restrict this configuration so that it only affects nullable fields in the response modelstype X
? maybe by having separate configuration options for input types and response types?Configuration Sample
Bug?
Using the configurations shown above, the
Optional
wrapper is applied to nullable fields insideinput
types but not applied to top-level nullable input variables. This inconsistency causes the generated builder to treat top-level nullable input variables as plain types instead of wrapping them in Optional.I'm not entirely sure which behavior is expected in this case: whether the
Optional
wrapper should be applied uniformly to all nullable fields or if the difference between top-level variables and fields insideinput
types is intentional, or if it shouldn't wrap any input variable inOptional
sincegenerateOptionalOperationVariables
is set tofalse
(I think this makes most sense).I believe there is a small conflict between
nullableFieldStyle
andgenerateOptionalOperationVariables
options, since applyingnullableFieldStyle
option will indirectly applyOptional
wrappers to theinput
types fields.nullableFieldStyle
generateOptionalOperationVariables
Optional
Optional
input
types are wrapped inOptional
Optional
Optional
internally, but not in the input builders. Expected?Optional
Optional
Optional
Example
Input type
Sample Query
Generated Builder
The top-level nullable input variables (
cursor
andcheckOutDate
) are not wrapped inOptional
, whereas the fields inside the input typeCheckOutDateFilter
are wrapped inOptional
.Apollo Version
v 4.0.0
The text was updated successfully, but these errors were encountered: