fix: fix incorrect sdl optionality with schema defaults #1325
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #1321
We need to know whether or not each type has a schema-default value in order to generate the SDL with correct optionality of fields.
Say you have the following InputObject:
The SDL currently generated by this is:
Which means that callers are required to pass in a value
optionalInputDefaulted
as input, even though we are specifying that we are defaulting this value in the schema.Then, in order to solve this issue, you would need to change your input object to the following:
This generates the correct SDL of:
Which lets the caller make use of the defaulting behavior by not passing in a value.
By requiring types to be wrapped as Options even though they are being defaulted, we need to treat them as Options throughout the project, which is silly since we know that they are being defaulted and therefore are always
Some
.This change fixes that, by marking input fields with defaults as optional in the SDL.