graphql-js icon indicating copy to clipboard operation
graphql-js copied to clipboard

Remove maybe types

Open danielrearden opened this issue 4 years ago • 3 comments

Optional arguments and parameters should not use the maybe type except where passing in a null value is semantically different from passing in an undefined value. So

operationName?: ?string

would become just

operationName?: string,

danielrearden avatar Jun 10 '20 11:06 danielrearden

@danielrearden Thanks 👍 Also, there is some background in this comment: https://github.com/graphql/express-graphql/pull/622#issuecomment-640920054

IvanGoncharov avatar Jun 10 '20 11:06 IvanGoncharov

@IvanGoncharov you mean to remove undefined from Maybe type?

sidpatel-github avatar Oct 29 '20 01:10 sidpatel-github

@IvanGoncharov you mean to remove undefined from Maybe type?

The general idea does not require modification of Maybe but closer inspection as to where and how it is used. Optional arguments and parameters should not generally accept null with strict TS and so Maybe as currently defined should not be user, null is wrong, and you get undefined for free by labeling the argument as optional.

yaacovCR avatar May 22 '22 18:05 yaacovCR