Repository navigation
Throw at build for resolvers that can't be called on their JDK dynamic proxy - #913
Merged
Merged
Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 #868
Checklist
Description
A resolver that is a JDK dynamic proxy (Spring AOP with
proxyTargetClass = false) only implements the target's interfaces, so every field that resolves to one of the target's own methods or public fields fails at query time:Since #853 the build only warned about it, once per field. Now
SchemaClassScannerthrows aFieldResolverErrorinstead, also withallowUnimplementedResolversor amissingResolverDataFetcherProvider, since the resolver exists but can't be called.The error lists every affected field, not just the first. A JDK-proxied resolver probably breaks all of its fields and a query and a mutation resolver can both be proxied. The scan collects them across all types and throws once before the schema result is built, so the app can fix them in one go instead of one build per field. The per-field sentence is the one the warning had (
Field 'Query.test' resolves to ...). The hint to use class-based proxies comes once at the end, with the getter hint added only when one of the fields is a public field:Another error found earlier in the scan (a missing resolver, for example) still comes first.
parser handles spring AOP proxied resolvers by defaultonly built, so it's nowparser rejects spring AOP proxied resolvers that are JDK dynamic proxies. New tests cover the two options above, all fields across a query and a mutation resolver in one error, the getter hint, and a class-based proxy that still builds.Verified with
mvn clean verifyon JDK 25 against graphql-java 26.1 and 25.1 (415 tests each). Also through the installed jar withverify-tools, scenariojdk-proxy: on master the build exits 0 with three WARNs (Query.test,Query.count,Query.total), on this branch it exits 2 with oneField ...line per field (same three) inbuild-error.txt.jdk-proxy-cglibandjdk-proxy-plainstill build and run with no warning.Release note: an app upgrading to 15.0.0 whose resolver is a JDK dynamic proxy (for example Spring AOP without
proxyTargetClass = true) fails to build with aFieldResolverErrornaming every field that can't be called, even if it never queries them. Use class-based proxies (proxyTargetClass = truein Spring), and add a getter for a public field.