Closed capaj closed 5 years ago
I'd say having arguments not-nullable by default is safer.
By default, your code doesn't have to handle custom cases when some argument is null.
If args would be nullable by default, you might have some resolver expecting an argument to be present and skip checking it. It could potentially break your code.
Current default may 'break' your request (so you'll have either to modify your frontend or to enable nullable argument), but it'll not break resolver code which I believe is a good approach.
If you want to make some argument optional (and you 'agree' to provide a code to handle such case) you have to explicitly opt-in (and show to other devs reading your code "I know what I'm doing").
I think it's not just my personal preference but some kind of logical conclusion.
Makes sense.
Is there a reason other than personal preference why
Arg
decorator is not nullable by default same asField
?