Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement default value coercion and validation #2325

Merged
merged 42 commits into from
May 24, 2021

Conversation

andimarek
Copy link
Member

@andimarek andimarek commented May 9, 2021

This PR adds one new coercing function which aim to resolves a long outstanding regarding custom Scalars and default value coercion:

Currently there is no well defined way for custom Scalar values to be printed as SDL.
Related to that default values are not properly coerced.

This also applies to applied schema directives which also contains values.

Breaking changes

Argument/InputObject defaultValue/values

GraphQLArgument.defaultValue/value and GraphQLInputObject.defaultValue are renamed to argumentDefaultValue/argumentValue and inputFieldDefaultValue.

We did this to signal clearly that the returned values changed. See JavaDoc for details.

Non standard scalars removed

We removed previously deprecated non standard Scalars (Long, short etc). These Scalars are still available via https://github.com/graphql-java/graphql-java-extended-scalars

Removed deprecated Constructors

Removed previously deprecated constructors for GraphQLArgument and GraphQLInputObjectField

@andimarek andimarek changed the title add coercing between literal and external input value default value coercion May 11, 2021
@andimarek andimarek changed the title default value coercion implement default value coercion May 11, 2021
@andimarek andimarek changed the title implement default value coercion implement default value coercion and validation May 13, 2021
return (Value<?>) parseImpl(multiSourceReader, nodeFunction);
}

private Node parseImpl(Reader reader, BiFunction<GraphqlParser, GraphqlAntlrToLanguage, Object[]> nodeFunction) throws InvalidSyntaxException {
Copy link
Member

Choose a reason for hiding this comment

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

Nice trick

@andimarek andimarek added this to the 17.0 milestone May 24, 2021
@andimarek andimarek merged commit 3139ccb into master May 24, 2021
@yaacovCR
Copy link

yaacovCR commented Jan 5, 2023

Hello @andimarek et al!

At the latest WG meeting, we again discussed advancing default value coercion/validation within the reference implementation.

Just touching base at @IvanGoncharov 's suggestion to see if there have been any lessons learned from the implementation here?

Anything working well -- or not so well -- in the 1.5 years since this has been live in graphql-java?

Any feedback/commentary that might inform how the spec/reference implementation should look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants