Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

toReadOnlySchema() fails on schemas with interfaces, unions or custom directives

未关闭
#896 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
74/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
graphql, kotlin

调研方向

Start by comparing SchemaObjects#toReadOnlySchema() with toSchema(), which the issue identifies as passing the code registry and directives. Check for existing tests around parseSchemaObjects() and add coverage for interfaces, unions, and applied custom directives. Done means toReadOnlySchema() builds those schemas successfully without mutation or subscription support.

由索引模型根据 Issue 内容生成。

描述

bug

SchemaObjects#toReadOnlySchema() throws for any schema with an interface, a union or an applied custom directive. Same on graphql-java 26.1 and 25.1:

Schema parseSchemaObjects().toReadOnlySchema()
scalar fields only, or @deprecated builds
interface Animal AssertException: There must be a type resolver for interface Animal
union Pet = Dog AssertException: There must be a type resolver for union Pet
name: String @tag with directive @tag on FIELD_DEFINITION InvalidSchemaException: invalid schema: A definition for directive 'tag' could not be found

It only passes the query type and the dictionary to GraphQLSchema.newSchema(), and toSchema() got the extra parts it needed over time but toReadOnlySchema() never did:

  1. Since 5.6.1 (e6f6f4d, the move to graphql-java 13) the type resolvers live in the code registry instead of on the interface and union types. toSchema() started passing codeRegistryBuilder.build(), toReadOnlySchema() doesn't pass a code registry at all.
  2. graphql-java 18.0 started rejecting applied directives without a definition in the schema (graphql-java/graphql-java#2576). 71b9752 added additionalDirectives(directives) to toSchema() for that in 12.1.0, but not to toReadOnlySchema().

So it's been broken for interfaces and unions since 2019, and for custom directives since 12.1.0. I couldn't find a caller in this org, there's no test for it and nobody reported it, so probably nobody uses it.

Fix would be to pass the same code registry, directives and schema applied directives as toSchema(), just without mutation and subscription. Or deprecate it.

主要语言
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 摘要。