Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#896 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
74/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
graphql, kotlin

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Kotlin
Stelle
824
Fork
175
Merge medio
2g 5h
PR unite (30g)
52

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di graphql-java-kickstart/graphql-java-tools

Tutte le issue di graphql-java-kickstart/graphql-java-tools

Issue simili

Altre issue su Kotlin

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.