Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

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

Offen
#896 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
74/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
graphql, kotlin

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
Kotlin
Sterne
824
Forks
175
Ø Merge
2 T. 5 Std.
Gemergte PRs (30 T.)
52

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus graphql-java-kickstart/graphql-java-tools

Alle Issues in graphql-java-kickstart/graphql-java-tools

Ähnliche Issues

Weitere Issues zu Kotlin

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.