Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#896 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
74/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
graphql, kotlin
Lĩnh vực
backend-api-design

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Kotlin
Star
824
Fork
175
Merge trung bình
2 ngày 5 giờ
Pull request đã merge (30 ngày)
52

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của graphql-java-kickstart/graphql-java-tools

Tất cả issue của graphql-java-kickstart/graphql-java-tools

Issue tương tự

Thêm issue về Kotlin

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.