Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Throw at build for resolvers that can't be called on their JDK dynamic proxy in 15.0.0

未關閉
#868 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
76/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
graphql, kotlin, spring

研究方向

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.

由索引模型根據 Issue 內容生成。

描述

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#warnIfNotCallableOnResolver with a FieldResolverError that keeps the same message
  • throw it even with allowUnimplementedResolvers or missingResolverDataFetcher set, 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
主要語言
Kotlin
星號
824
分支
175
平均合併
2 天 5 小時
30 天內合併 PR
52

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

graphql-java-kickstart/graphql-java-tools 的其他 Issue

查看 graphql-java-kickstart/graphql-java-tools 的全部 Issue

相似的 Issue

更多 Kotlin Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。