Title: SchemaDiff EnforceDirectives Option Does Not Identify Removal of Directive From Type or Field · Issue #3343 · graphql-java/graphql-java · GitHub
Open Graph Title: SchemaDiff EnforceDirectives Option Does Not Identify Removal of Directive From Type or Field · Issue #3343 · graphql-java/graphql-java
X Title: SchemaDiff EnforceDirectives Option Does Not Identify Removal of Directive From Type or Field · Issue #3343 · graphql-java/graphql-java
Description: Describe the bug The enforceDirectives option for SchemaDiff does not properly detect if a directive was removed from a field or type. This is because it relies on an introspection result as input. The introspection query does not return...
Open Graph Description: Describe the bug The enforceDirectives option for SchemaDiff does not properly detect if a directive was removed from a field or type. This is because it relies on an introspection result as input....
X Description: Describe the bug The enforceDirectives option for SchemaDiff does not properly detect if a directive was removed from a field or type. This is because it relies on an introspection result as input....
Opengraph URL: https://github.com/graphql-java/graphql-java/issues/3343
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"SchemaDiff EnforceDirectives Option Does Not Identify Removal of Directive From Type or Field","articleBody":"**Describe the bug**\r\nThe enforceDirectives option for SchemaDiff does not properly detect if a directive was removed from a field or type. This is because it relies on an introspection result as input. The introspection query does not return directives on fields or types so they are not present when the diff of the document is ran. \r\n\r\n**To Reproduce**\r\n\r\nSchema 1:\r\n\r\n```\r\ndirective @someDirective on FIELD_DEFINITION\r\n\r\ntype test {\r\n version: String! @someDirective\r\n}\r\n\r\ntype Query {\r\n getTests: [test]!\r\n}\r\n```\r\n\r\nSchema 2:\r\n\r\n```\r\ndirective @someDirective on FIELD_DEFINITION\r\n\r\ntype test {\r\n version: String!\r\n}\r\n\r\ntype Query {\r\n getTests: [test]!\r\n}\r\n```\r\nWhen schema diff is run on these two schemas it will detect no changes even though removal of a directive could be a breaking change especially for composite schemas. \r\n\r\nPotential solution would be providing the ability for DiffSet to provide the SchemaDefinition directly so that it can be overridden to use an approach that does not require introspection:\r\n\r\n```\r\npublic interface DiffSet {\r\n Document getOldSchemaDefinition();\r\n Document getNewSchemaDefinition();\r\n}\r\n\r\n\r\npublic class IntrospectionDiffSet implements DiffSet {\r\n ....\r\n @Override\r\n public Document getOldSchemaDefinition() {\r\n return new IntrospectionResultToSchema().createSchemaDefinition(this.introspectionOld); \r\n }\r\n \r\n @Override\r\n public Document getNewSchemaDefinition() {\r\n return new IntrospectionResultToSchema().createSchemaDefinition(this.introspectionNew); \r\n }\r\n}\r\n```\r\nThe SchemaDiff class can then use this hook rather than requiring the introspection result method. \r\n\r\n```\r\npublic class SchemaDiff {\r\n ...\r\n private void diffSchemaImpl(DiffSet diffSet, DifferenceReporter reporter) {\r\n Document oldDoc = diffSet.getOldSchemaDefinition();\r\n Document newDoc = diffSet.getNewSchemaDefinition();\r\n ...\r\n }\r\n}\r\n```\r\n\r\nWe would then be able to override this implementation with something like this:\r\n```\r\n public class SDLDiffSet implements DiffSet {\r\n ....\r\n \r\n @Override\r\n public Document getOldSchemaDefinition() {\r\n return Parser.parse(this.oldSchemaSdl);\r\n }\r\n \r\n @Override\r\n public Document getNewSchemaDefinition() {\r\n return Parser.parse(this.newSchemaSdl);\r\n }\r\n}\r\n```\r\n\r\nI am willing to help with a PR if there is some agreement on direction here. \r\n\r\n","author":{"url":"https://github.com/ndejaco2","@type":"Person","name":"ndejaco2"},"datePublished":"2023-10-03T21:09:08.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/3343/graphql-java/issues/3343"}
| 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:d514a6e1-5881-05c0-9870-f35c50e9df12 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EBC2:425E5:203AC5D:2C9C8CF:6A609A7C |
| html-safe-nonce | 17f0cd866ddc31342d974b48a96c04816684a786f3d36a423769351f1eba6182 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQkMyOjQyNUU1OjIwM0FDNUQ6MkM5QzhDRjo2QTYwOUE3QyIsInZpc2l0b3JfaWQiOiIzNDI2MDY3MDM2OTU0OTkxMjI4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 7bbd087eba265721f0ed14abfbec79e5cbda0c4c8deb3fc1e09f09dd840c28a6 |
| hovercard-subject-tag | issue:1924955142 |
| 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/3343/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4ab129620256ba93cd59104fd27e32c9a83d7ec6be5c6bdee4669d0f88775acc/graphql-java/graphql-java/issues/3343 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4ab129620256ba93cd59104fd27e32c9a83d7ec6be5c6bdee4669d0f88775acc/graphql-java/graphql-java/issues/3343 |
| og:image:alt | Describe the bug The enforceDirectives option for SchemaDiff does not properly detect if a directive was removed from a field or type. This is because it relies on an introspection result as input.... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ndejaco2 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5142d23feb6a650085422edf60d68c93777dfa6c4b0c9151eb464d3e4969f618 |
| 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 | b2111e158bcd758ab9d0446577ae8f5dd78fcca8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width