Use default value with null inputs #1027
-
On a boolean input field that has a default value, a GraphQL client can send:
The default value will only be used in the I would like to always have a boolean here, in all cases. My example here is with a boolean, but it works on all input types. How the input is declared: @InputType()
class MyInput {
@Field({ defaultValue: false })
myProperty: boolean;
} One solution is to fix the type and add @InputType()
class MyInput {
@Field({ defaultValue: false })
-- myProperty: boolean;
++ myProperty: boolean | null;
} I'm looking for a simpler solution. I tried to use the Would you have a solution, or a lead to investigate? What would be the best way to do it? I think the TypeGraphQL documentation is not very clear on this topic. There are no hints, not even with the type system that |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
I think your issue has been solved in #806, so when you provide default value, it will no more emit the field as nullable, so |
Beta Was this translation helpful? Give feedback.
I think your issue has been solved in #806, so when you provide default value, it will no more emit the field as nullable, so
null
value won't be allowed.