Throw at build for resolvers that can't be called on their JDK dynamic proxy in 15.0.0
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- graphql, kotlin, spring
- Domain
- backend-api-design, release, testing
Research direction
Read SchemaClassScanner#warnIfNotCallableOnResolver and the existing FieldResolverError implementation to see how resolver errors are reported. Update SchemaParserTest's “parser handles spring AOP proxied resolvers by default” test to verify the error, including when the resolver fallback options are enabled. Add the change to the 15.0.0 release notes; done means the warning becomes an error with the same message and the tests pass.
Written by the indexing model from the issue text.
Description
Since #853, tools warns at build when a resolver is a JDK dynamic proxy (e.g. Spring AOP with proxyTargetClass = false) and a field resolves to a method or public field the proxy can't call. Spring4AopProxyHandler makes the scanner match fields against the target class, but the proxy only implements the target's interfaces, so every query of those fields fails:
class ProxiedQuery : GraphQLQueryResolver {
fun test() = "ok"
}
val resolver = ProxyFactory(ProxiedQuery()).proxy as GraphQLQueryResolver
object of type jdk.proxy2.$Proxy2 is not an instance of ProxiedQuery
For a public field it's Can not get final int field ProxiedQuery.count on jdk.proxy2.$Proxy2. For a field, the message says to add a getter as well, since class-based proxies don't pass field reads to the target either. The build logs this once per field:
Field 'Query.test' resolves to scenarios.ProxiedQuery.test, but the resolver is a jdk.proxy2.$Proxy2, which isn't a scenarios.ProxiedQuery, so every query of the field will fail. This happens with JDK dynamic proxies, which only implement interfaces. Use class-based proxies instead, e.g. proxyTargetClass = true in Spring.
A field that can never work should fail the build. But a schema whose broken field is never queried builds and runs fine today, so throwing has to wait for a major release.
What to change
- replace the warning in
SchemaClassScanner#warnIfNotCallableOnResolverwith aFieldResolverErrorthat keeps the same message - throw it even with
allowUnimplementedResolversormissingResolverDataFetcherset, since the resolver exists but can't be called - turn
SchemaParserTest."parser handles spring AOP proxied resolvers by default", which only builds today, into a test for the error - mention it in the 15.0.0 release notes
- Dominant language
- Kotlin
- Stars
- 824
- Forks
- 175
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 52
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from graphql-java-kickstart/graphql-java-tools
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
graphql-java-kickstart/graphql-java-tools#893 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
graphql-java-kickstart/graphql-java-tools#889 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 55/100
graphql-java-kickstart/graphql-java-tools#886 ·
Maintainers usually reply within 1 day
-
Reject directives applied at the wrong location, without a required argument or twice in 15.0.0Openenhancement
Difficulty 3/5 1-2 days Newbie friendliness 72/100
graphql-java-kickstart/graphql-java-tools#884 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
graphql-java-kickstart/graphql-java-tools#881 ·
Maintainers usually reply within 1 day
All issues in graphql-java-kickstart/graphql-java-tools
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
navikt/mock-oauth2-server#1129 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
-
unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
thunderbird/thunderbird-android#11778 · 2 comments ·
Maintainers usually reply within 1 day
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
software-mansion/enriched-markdown#1042 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
world-federation-of-advertisers/cross-media-measurement#4709 ·
Maintainers usually reply within 1 day