You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
toReadOnlySchema() fails on schemas with interfaces, unions or custom directives #896
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 passing codeRegistryBuilder.build(), toReadOnlySchema() doesn't pass a code registry at all.
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.
Activity