Update dependency com.graphql-java:graphql-java to v20 #726
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.
This PR contains the following updates:
19.2
->20.0
Release Notes
graphql-java/graphql-java
v20.0
: 20.0We are pleased to announce the release of graphql-java 20.0. Special thanks to each of the 200+ contributors over the years, who have made this milestone possible.
Breaking changes
Aligning
parseValue
coercion with JS reference implementationWe have made changes to String, Boolean, Float, and Int
parseValue
coercion, to be consistent with the reference JS implementation. The key change isparseValue
is now stricter on accepted inputs.parseValue
now requires input is of typeString
. For example, a Number input123
or a Boolean inputtrue
will no longer be accepted.parseValue
now requires input is of typeBoolean
. For example, a String input"true"
will no longer be accepted.parseValue
now requires input is of typeNumber
. For example, a String input"3.14"
will no longer be accepted.parseValue
now requires input is of typeNumber
. For example, a String input"42"
will no longer be accepted.String
parseValue
changes: https://github.com/graphql-java/graphql-java/pull/3030Boolean, Float, and Int
parseValue
changes: https://github.com/graphql-java/graphql-java/pull/3042JS reference implementation: https://github.com/graphql/graphql-js/blob/main/src/type/scalars.ts
Notable Changes
Record Like Property Fetching Support
We have now added the ability to find properties via "Record like" naming. We call it "Record like" based on Java 14
record
classes but in fact any class with a method named directly as the graphql field is named will work.If you had this graphql object type declared
then this Java
record
would be supported for fetching values via the method namesname()
andaddress()
and equally a non record class like this would also work
We still have Java Bean (aka POJO) getter naming support like
public String getName()
however now the "record like"name()
method will be used in preference and then thegetName()
methods will be used if that's not present.This means there is a new behavior if you had weird POJOs likes this
A property fetch for
name
will now returnHarry Potter
and notTom Riddle
as it previously would have.This is a behavioral breaking change but on balance we think this behavior is the most correct going forward.
https://github.com/graphql-java/graphql-java/pull/2994
Improved Data Fetching
The
PropertyDataFetcher
class is the most common data fetcher used in graphql-java. It uses Java reflection to get field values from objects based on field name.This was logically the following
with the method lookup cached for performance reasons.
However there is mechanism in the JVM that provides even faster object reflective access.
See
https://wttech.blog/blog/2020/method-handles-and-lambda-metafactory/
https://www.optaplanner.org/blog/2018/01/09/JavaReflectionButMuchFaster.html
java.lang.invoke.LambdaMetafactory#metafactory
is an arcane mechanism that can be used to create virtual method lambdas that give fast access to call object methods. It turns out to be significantly faster that Java reflection and only marginally slower that directly invoking a method.If you use
PropertyDataFetcher
a lot (and chances are you do) then this should give improved performance.The raw benchmarks are as follows
It's worth noting that while the headline numbers here look impressive, the property fetching represents a smaller portion of what happens during graphql engine execution.
It probably won't be enough to keep Elon Musk happy but all performance improvements help and at scale they help the most.
Lightweight Data Fetchers
A
DataFetcher
gets invoked with a calling environment context object calledgraphql.schema.DataFetchingEnvironment
. This is quite a rich object that contains all sorts of useful information.However simple (aka trivial) data fetchers like
PropertyDataFetcher
they don't need access to such a rich object. They just need the source object, the field name and the field typeTo marginally help performance, we have introduced a
graphql.schema.LightDataFetcher
for this use casePropertyDataFetcher
implements this and hence this lowers the object allocation at scale (which reduces memory pressure) and will make the system marginally faster to fetch data.https://github.com/graphql-java/graphql-java/pull/2953
Performance Improvements by avoid object allocations
We are always trying to wring out the most performance we can in graphql-java and so we reviewed our object allocations and found places where we can make savings.
These won't make dramatic performance savings but at scale all these things add up, reducing memory pressure and improving throughput marginally.
https://github.com/graphql-java/graphql-java/pull/2981
https://github.com/graphql-java/graphql-java/pull/2980
https://github.com/graphql-java/graphql-java/pull/2979
Locale is now available in Coercing and Parsing
The
graphql.schema.Coercing
interface used by scalars can now receive aLocale
object that indicates the callingLocale
. The same is true for the parsing code viagraphql.parser.ParserEnvironment#getLocale
A custom scalar implementation could use the locale to decide how to coerce values.
https://github.com/graphql-java/graphql-java/pull/2912
https://github.com/graphql-java/graphql-java/pull/2921
Easier ways to build common objects
We have added extra builders on the
GraphQLError
,ErrorClassification
andExecutionResult
interfaces that make it easier to build instances of these common classes.https://github.com/graphql-java/graphql-java/pull/2939
https://github.com/graphql-java/graphql-java/pull/3011
The deprecated NextGen engine has been removed
The NextGen engine was an experimental feature that explored what it might take to build a new graphql engine. In many ways it was a success as it taught us a bunch of about graph algorithms and what works and what does not.
While it had some value, on balance it was not going to become production ready and so we deprecated it a while back and it has finally been removed.
https://github.com/graphql-java/graphql-java/pull/2923
What's Changed
New Contributors
Full Changelog: graphql-java/graphql-java@v19.1...v20.0
v19.3
: 19.3The 19.3 bug fix release has been created
What's Changed
Full Changelog: graphql-java/graphql-java@v19.2...v19.3
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate. View repository job log here.