Title: SchemaTransformer.transformSchema produces schema with dangling reference to deleted type · Issue #4133 · graphql-java/graphql-java · GitHub
Open Graph Title: SchemaTransformer.transformSchema produces schema with dangling reference to deleted type · Issue #4133 · graphql-java/graphql-java
X Title: SchemaTransformer.transformSchema produces schema with dangling reference to deleted type · Issue #4133 · graphql-java/graphql-java
Description: Describe the bug We've implemented a visitor that prunes our schema based on the presence of a directive. This has worked well until quite recently, but has suddenly started failing with graphql.AssertException: Assert type Rom not found...
Open Graph Description: Describe the bug We've implemented a visitor that prunes our schema based on the presence of a directive. This has worked well until quite recently, but has suddenly started failing with graphql.As...
X Description: Describe the bug We've implemented a visitor that prunes our schema based on the presence of a directive. This has worked well until quite recently, but has suddenly started failing with graphq...
Opengraph URL: https://github.com/graphql-java/graphql-java/issues/4133
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"SchemaTransformer.transformSchema produces schema with dangling reference to deleted type","articleBody":"**Describe the bug**\nWe've implemented a visitor that prunes our schema based on the presence of a directive.\nThis has worked well until quite recently, but has suddenly started failing with `graphql.AssertException: Assert type Rom not found in schema`.\n\nI've analyzed the problem and reduced the schema and our visitor down to the minimal needed to reproduce the issue. Note that our actual implementation also handles other schema elements, but I don't think this is relevant for the issue at hand.\n\n**To Reproduce**\n\nGiven the following schema, our visitor crashes with `AssertException`:\n\n```graphql\ndirective @remove on FIELD_DEFINITION\n\ntype Query {\n rental: Rental @remove\n customer: Customer\n}\n\ntype Store {\n inventory: Inventory @remove\n}\n\ntype Inventory {\n store: Store @remove\n}\n\ntype Customer {\n rental: Rental\n payment: Payment @remove\n}\n\ntype Payment {\n inventory: Inventory @remove\n}\n\ntype Rental {\n id: ID\n customer: Customer @remove\n}\n\n```\n\nOur visitor is defined as follows:\n\n```java\n class SchemaPruningVisitor extends GraphQLTypeVisitorStub {\n @Override\n public TraversalControl visitGraphQLFieldDefinition(GraphQLFieldDefinition node, TraverserContext\u003cGraphQLSchemaElement\u003e context) {\n if (node.hasAppliedDirective(\"remove\")) {\n return deleteNode(context);\n }\n\n return CONTINUE;\n }\n\n @Override\n public TraversalControl visitGraphQLObjectType(GraphQLObjectType node, TraverserContext\u003cGraphQLSchemaElement\u003e context) {\n if (node.getFields().stream().allMatch(field -\u003e field.hasAppliedDirective(\"remove\"))) {\n return deleteNode(context);\n }\n\n return CONTINUE;\n }\n }\n```\n\n## Interesting observation ##\n\nNote that if we flip the order of the `Query.rental` and `Query.customer` fields then our visitor no longer crashes and produces the schema we expect:\n\n```graphql\ntype Query {\n customer: Customer\n}\n\ntype Customer {\n rental: Rental\n}\n\ntype Rental {\n id: ID\n}\n```","author":{"url":"https://github.com/alf","@type":"Person","name":"alf"},"datePublished":"2025-10-10T11:18:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/4133/graphql-java/issues/4133"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:360c9dd2-cd9a-1d76-8ffe-010e6272355f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DF3C:21F413:22D8EE:31B467:696FA258 |
| html-safe-nonce | 07bac08f5abfdb47c9fb2a62945240fa5c56b30790197f1085f5456159a19a1b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERjNDOjIxRjQxMzoyMkQ4RUU6MzFCNDY3OjY5NkZBMjU4IiwidmlzaXRvcl9pZCI6IjgzMjc0NTYxNDU3MzkzMjYwNDAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | be02ebb46a7eebc9b83e82a8cc1162599e08c5bd63a1194b9179f3ee33b47cc8 |
| hovercard-subject-tag | issue:3502448982 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/graphql-java/graphql-java/4133/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a0dcba99fac34d28733fe4b0b42cb3d0bd03ffa6bd1697d39fc820abbf3273f4/graphql-java/graphql-java/issues/4133 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a0dcba99fac34d28733fe4b0b42cb3d0bd03ffa6bd1697d39fc820abbf3273f4/graphql-java/graphql-java/issues/4133 |
| og:image:alt | Describe the bug We've implemented a visitor that prunes our schema based on the presence of a directive. This has worked well until quite recently, but has suddenly started failing with graphql.As... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alf |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0ca8d8c65612640b9a1a588b3eed68222ca723ed2d028b18fe81b28936d535eb |
| turbo-cache-control | no-preview |
| go-import | github.com/graphql-java/graphql-java git https://github.com/graphql-java/graphql-java.git |
| octolytics-dimension-user_id | 14289921 |
| octolytics-dimension-user_login | graphql-java |
| octolytics-dimension-repository_id | 38602457 |
| octolytics-dimension-repository_nwo | graphql-java/graphql-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 38602457 |
| octolytics-dimension-repository_network_root_nwo | graphql-java/graphql-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 95f60616ce2765d1114fe6da4af405a58c6d26d2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width