GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Re-add GraphQLSchema.Builder.clearDirectives() by rstata · Pull Request #4276 · graphql-java/graphql-java

Conversation

@rstata

@rstata rstata commented Mar 2, 2026

Copy link
Copy Markdown

Summary

PR #4229 removed clearDirectives() from GraphQLSchema.Builder as part of unifying built-in directive handling. As noted in issue #4259, this method is useful in practice: a common pattern when using GraphQLSchema.transform is to collect the non-built-in directives from the source schema, call clearDirectives() 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:

  • Clears additionalDirectives entirely (including any explicitly-added built-ins)
  • Built-in directives are always re-added automatically at build time by ensureBuiltInDirectives(), so they cannot be permanently removed — all built-ins are treated uniformly

Changes

  • Re-adds Builder.clearDirectives() to GraphQLSchema with Javadoc illustrating the transform use case
  • Adds tests covering:
    • clearDirectives() followed by build() still yields all 7 built-in directives
    • clearDirectives() followed by adding a custom directive yields the expected set
    • The primary use case: using clearDirectives() in a schema.transform() to replace non-built-in directives
    • Ordering behavior: unoverridden built-ins sort first, then user-supplied directives in insertion order; customized built-ins retain their custom properties

Related

Fixes #4259. See also #4229.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Raymie Stata @claude
Re-add GraphQLSchema.Builder.clearDirectives()
95b06a1
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 <[email protected]>
@andimarek

andimarek commented Mar 2, 2026

Copy link
Copy Markdown
Member

Thanks

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@andimarek
andimarek merged commit bae794f into graphql-java:master Mar 2, 2026
7 checks passed

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Did PR #4229 go too far?

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@rstata @andimarek
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.