Re-add GraphQLSchema.Builder.clearDirectives()#4276
Merged
andimarek merged 1 commit intographql-java:masterfrom Mar 2, 2026
Merged
Re-add GraphQLSchema.Builder.clearDirectives()#4276andimarek merged 1 commit intographql-java:masterfrom
andimarek merged 1 commit intographql-java:masterfrom
Conversation
PR graphql-java#4229 removed `clearDirectives()` from `GraphQLSchema.Builder` as part of unifying built-in directive handling. However, as noted in issue graphql-java#4259, this method is useful when using `GraphQLSchema.transform` to replace all non-built-in directives: the typical pattern is to collect the non-built-in directives from the source schema, call `clearDirectives()` on the builder, then add back transformed versions of those directives. The new implementation clears `additionalDirectives` entirely. Built-in directives are always re-added automatically at build time by `ensureBuiltInDirectives()`, so they cannot be permanently removed through this method. This treats all built-ins uniformly, consistent with the approach introduced in graphql-java#4229. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
|
Thanks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR #4229 removed
clearDirectives()fromGraphQLSchema.Builderas part of unifying built-in directive handling. As noted in issue #4259, this method is useful in practice: a common pattern when usingGraphQLSchema.transformis to collect the non-built-in directives from the source schema, callclearDirectives()on the builder, and then add back transformed versions of those directives.This PR re-adds
clearDirectives()with semantics that are consistent with the approach introduced in #4229:additionalDirectivesentirely (including any explicitly-added built-ins)ensureBuiltInDirectives(), so they cannot be permanently removed — all built-ins are treated uniformlyChanges
Builder.clearDirectives()toGraphQLSchemawith Javadoc illustrating the transform use caseclearDirectives()followed bybuild()still yields all 7 built-in directivesclearDirectives()followed by adding a custom directive yields the expected setclearDirectives()in aschema.transform()to replace non-built-in directivesRelated
Fixes #4259. See also #4229.