Skip to content

Conversation

@bbakerman
Copy link
Member

@bbakerman bbakerman commented Aug 9, 2023

This fixes the deprecated defaultValue input of null values when an AST literal is required - eg in schema printing and introspection.

see #3285

// but this code can know - its is SET to a value so, it MUST be a Null Literal
// this method would assert at the end of it if inputValueWithState.isNotSet() were true
//
return value == null ? NullValue.of() : value;
Copy link
Member Author

@bbakerman bbakerman Aug 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment outlines why this is safe - but what you cant see in this diff is if (inputValueWithState.isInternal()) being called. Since this is true then the value MUST have been set into the input value and hence we can turn the legacy null into a AST NullValue safely.

.directiveIsRepeatable(true)
.schemaDescription(true)
.inputValueDeprecation(true)
.typeRefFragmentDepth(7)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly just reformatting

def fField = (queryType['fields'] as List)[0]
def arg = (fField['args'] as List)[0]
arg['name'] == "arg"
arg['defaultValue'] == "null" // printed AST
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test is here - the introspection AST printed value is "null" and not ""

@bbakerman bbakerman added this to the 2023 October milestone Aug 10, 2023
@bbakerman bbakerman added the needs to be backported a bugfix that still needs to be backported label Aug 10, 2023
@dondonz dondonz added this pull request to the merge queue Aug 21, 2023
Merged via the queue into master with commit a54bb43 Aug 21, 2023
bbakerman pushed a commit that referenced this pull request Aug 22, 2023
* Backport null default value https://github.com/graphql-java/graphql-java/pull/3286/files

* Fix Javadoc

* Add import

* Add imports

* Another import
@dondonz dondonz deleted the 3285_default_value_problems branch August 29, 2023 00:59
dondonz added a commit that referenced this pull request Aug 31, 2023
deprecated default value method produces bad results

(cherry picked from commit a54bb43)
dondonz added a commit that referenced this pull request Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs to be backported a bugfix that still needs to be backported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants