toReadOnlySchema() fails on schemas with interfaces, unions or custom directives
维护者通常 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 内容生成。
描述
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:
- 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 passingcodeRegistryBuilder.build(),toReadOnlySchema()doesn't pass a code registry at all. - graphql-java 18.0 started rejecting applied directives without a definition in the schema (graphql-java/graphql-java#2576). 71b9752 added
additionalDirectives(directives)totoSchema()for that in 12.1.0, but not totoReadOnlySchema().
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,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
graphql-java-kickstart/graphql-java-tools 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 85/100
graphql-java-kickstart/graphql-java-tools#893 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 72/100
graphql-java-kickstart/graphql-java-tools#889 ·
维护者通常 1 天内回复
-
bug
难度 3/5 1-2 天 新手友好度 55/100
graphql-java-kickstart/graphql-java-tools#886 ·
维护者通常 1 天内回复
-
enhancement
难度 3/5 1-2 天 新手友好度 72/100
graphql-java-kickstart/graphql-java-tools#884 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
graphql-java-kickstart/graphql-java-tools#881 ·
维护者通常 1 天内回复
查看 graphql-java-kickstart/graphql-java-tools 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
enhancement impact:U1 P3 reach:R2 size:S
难度 2/5 1-3 小时 新手友好度 78/100
-
enhancement triaged
难度 1/5 1 小时以内 新手友好度 75/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 73/100
ankidroid/Anki-Android#22677 ·
维护者通常 1 天内回复
-
Type Pick Request
难度 2/5 1-3 小时 新手友好度 68/100
reactwg/react-native-releases#1456 · 1 条评论 ·