Skip to content

Validate directives on enum values and directive arguments - #10151

Merged
glen-84 merged 1 commit into
mainfrom
gai/publish-missing-directive-events
Jul 27, 2026
Merged

glen-84 merged 1 commit into
mainfrom
gai/publish-missing-directive-events

Conversation

@glen-84

@glen-84 glen-84 commented Jul 27, 2026

Copy link
Copy Markdown
Member

Summary

  • SchemaValidator publishes directive events for every directives provider it walks, including enum values and directive definition arguments. Directives applied at the ENUM_VALUE and ARGUMENT_DEFINITION (on a directive definition) locations were previously skipped, so rules keyed on DirectiveEvent and DirectiveArgumentAssignmentEvent never saw them — an undefined directive there passed validation silently.

Test plan

  • Extended DirectiveIsDefinedRuleTests.Validate_DirectiveIsUndefined_Fails to cover a directive on an enum value and on a directive definition's argument alongside the existing object/field/argument cases.
  • HotChocolate.Types.Validation.Tests (404 tests) and HotChocolate.Fusion.Composition.Tests (2848 tests, the only other SchemaValidator consumer) pass on all target frameworks.

Copilot AI review requested due to automatic review settings July 27, 2026 08:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request updates schema validation so that directives applied to enum values and directive-definition arguments are also validated (via published directive-related validation events), closing a gap where undefined directives at ENUM_VALUE and directive ARGUMENT_DEFINITION locations could previously pass silently.

Changes:

  • Publish directive events for IEnumValue members while walking enum values in SchemaValidator.
  • Publish directive events for arguments of directive definitions in SchemaValidator.
  • Extend DirectiveIsDefinedRuleTests.Validate_DirectiveIsUndefined_Fails to assert failures for undefined directives on an enum value and on a directive definition argument.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/HotChocolate/Core/test/Types.Validation.Tests/Rules/DirectiveIsDefinedRuleTests.cs Adds coverage for undefined directives on enum values and directive-definition arguments.
src/HotChocolate/Core/src/Types.Validation/SchemaValidator.cs Publishes directive events for enum values and directive-definition arguments so rules see and validate those directives.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

Copy link
Copy Markdown
Contributor

Patch coverage

100.0% of changed lines covered (2/2)

File Covered Changed Patch %
…/HotChocolate/Core/src/Types.Validation/SchemaValidator.cs 2 2 100.0% 🟢

Project coverage: 53.9% (232122/430885 lines)

@glen-84
glen-84 merged commit c7b0a53 into main Jul 27, 2026
148 checks passed
@glen-84
glen-84 deleted the gai/publish-missing-directive-events branch July 27, 2026 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants