toReadOnlySchema() fails on schemas with interfaces, unions or custom directives
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 74/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- graphql, kotlin
- Domain
- backend-api-design
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Kotlin
- Stars
- 824
- Forks
- 175
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 52
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from graphql-java-kickstart/graphql-java-tools
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
graphql-java-kickstart/graphql-java-tools#893 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
graphql-java-kickstart/graphql-java-tools#889 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 55/100
graphql-java-kickstart/graphql-java-tools#886 ·
Maintainers usually reply within 1 day
-
Reject directives applied at the wrong location, without a required argument or twice in 15.0.0Openenhancement
Difficulty 3/5 1-2 days Newbie friendliness 72/100
graphql-java-kickstart/graphql-java-tools#884 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
graphql-java-kickstart/graphql-java-tools#881 ·
Maintainers usually reply within 1 day
All issues in graphql-java-kickstart/graphql-java-tools
Similar issues
-
area:data-quality importer size:S
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
enorm-labs/event-junkie#3707 ·
Maintainers usually reply within 1 day
-
area/ui priority/p2 type/bug
Difficulty 1/5 Under an hour Newbie friendliness 94/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
commons-app/apps-android-commons#7072 ·
Maintainers usually reply within 1 day
-
bug ci good first issue help wanted severity: medium
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
dhananjay-nautiyal/music#17 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
T8RIN/ImageToolbox#3255 · 2 comments ·
Maintainers usually reply within 1 day