Skip to content

[Fusion] Add support for merging @authorize directives#9378

Merged
glen-84 merged 2 commits intomainfrom
gai/merge-authorize-directives
Mar 17, 2026
Merged

[Fusion] Add support for merging @authorize directives#9378
glen-84 merged 2 commits intomainfrom
gai/merge-authorize-directives

Conversation

@glen-84
Copy link
Copy Markdown
Member

@glen-84 glen-84 commented Mar 17, 2026

Summary of the changes (Less than 80 chars)

  • [Fusion] Add support for merging @authorize directives.

Copilot AI review requested due to automatic review settings March 17, 2026 08:15
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 17, 2026

Fusion Gateway Performance Results

Progress: 0/6 benchmarks completed — this report updates as each job finishes.

Simple Composite Query

Req/s Err%
Constant 1 (50 VUs) pending pending
Ramping 1 (0-500-0 VUs) pending pending
Response Times
Min Med Avg P90 P95 Max
Constant 1 pending pending pending pending pending pending
Ramping 1 pending pending pending pending pending pending

Deep Recursion Query

Req/s Err%
Constant 1 (50 VUs) pending pending
Ramping 1 (0-500-0 VUs) pending pending
Response Times
Min Med Avg P90 P95 Max
Constant 1 pending pending pending pending pending pending
Ramping 1 pending pending pending pending pending pending

Variable Batching Throughput

Req/s Err%
Constant 1 (50 VUs) pending pending
Ramping 1 (0-500-0 VUs) pending pending
Response Times
Min Med Avg P90 P95 Max
Constant 1 pending pending pending pending pending pending
Ramping 1 pending pending pending pending pending pending

Runner 1 = benchmarking-1

Run 23187017560 • Commit 19f5cc3 • Tue, 17 Mar 2026 09:18:50 GMT

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds composition-time support for merging @authorize directives across source schemas in Fusion composition, including a canonical directive definition and directive merger logic, plus snapshot-style tests validating expected merge results.

Changes:

  • Introduces AuthorizeDirectiveMerger and related directive/type definitions (@authorize, ApplyPolicy) to canonicalize and merge directives.
  • Wires @authorize merging into SourceSchemaMerger for object types and output fields.
  • Adds composition tests covering multiple @authorize merging scenarios (policies, roles, apply-policy combinations).

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/HotChocolate/Fusion/test/Fusion.Composition.Tests/SourceSchemaMerger.AuthorizeDirective.Tests.cs Adds snapshot tests validating @authorize merging behaviors.
src/HotChocolate/Fusion/src/Fusion.Composition/WellKnownTypeNames.cs Adds well-known type name constant for ApplyPolicy.
src/HotChocolate/Fusion/src/Fusion.Composition/WellKnownDirectiveNames.cs Adds well-known directive name constant for authorize.
src/HotChocolate/Fusion/src/Fusion.Composition/WellKnownArgumentNames.cs Adds well-known argument name constants for apply, policy, and roles.
src/HotChocolate/Fusion/src/Fusion.Composition/SourceSchemaMerger.cs Registers and applies the new AuthorizeDirectiveMerger during merge.
src/HotChocolate/Fusion/src/Fusion.Composition/Properties/CompositionResources.resx Adds localized error messages for invalid @authorize argument values.
src/HotChocolate/Fusion/src/Fusion.Composition/Properties/CompositionResources.Designer.cs Generated resource accessors for the new messages.
src/HotChocolate/Fusion/src/Fusion.Composition/Directives/AuthorizeDirective.cs Adds parsing/normalization for @authorize directive instances.
src/HotChocolate/Fusion/src/Fusion.Composition/Directives/ApplyPolicy.cs Defines ApplyPolicy enum used by composition-side parsing/merging.
src/HotChocolate/Fusion/src/Fusion.Composition/DirectiveMergers/AuthorizeDirectiveMerger.cs Implements directive deduplication and merged directive emission.
src/HotChocolate/Fusion/src/Fusion.Composition/Definitions/AuthorizeMutableDirectiveDefinition.cs Adds canonical mutable definition for @authorize.
src/HotChocolate/Fusion/src/Fusion.Composition/Definitions/ApplyPolicyMutableEnumTypeDefinition.cs Adds mutable enum definition for ApplyPolicy to support the canonical directive definition.
Files not reviewed (1)
  • src/HotChocolate/Fusion/src/Fusion.Composition/Properties/CompositionResources.Designer.cs: Language not supported

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds first-class composition support for HotChocolate’s @authorize directive so authorization metadata is preserved (and de-duplicated) when composing multiple source schemas into a single execution schema.

Changes:

  • Introduces an AuthorizeDirectiveMerger and hooks it into SourceSchemaMerger for object types and output fields.
  • Adds canonical @authorize directive + ApplyPolicy enum definitions used to validate “definition matches canonical” before merging.
  • Adds comprehensive snapshot tests covering policy/roles/apply merging and de-duplication behavior.

Reviewed changes

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

Show a summary per file
File Description
src/HotChocolate/Fusion/test/Fusion.Composition.Tests/SourceSchemaMerger.AuthorizeDirective.Tests.cs New snapshot tests covering @authorize directive merging scenarios.
src/HotChocolate/Fusion/src/Fusion.Composition/WellKnownTypeNames.cs Adds well-known type name for ApplyPolicy.
src/HotChocolate/Fusion/src/Fusion.Composition/WellKnownDirectiveNames.cs Adds well-known directive name for authorize.
src/HotChocolate/Fusion/src/Fusion.Composition/WellKnownArgumentNames.cs Adds well-known argument names apply, policy, and roles.
src/HotChocolate/Fusion/src/Fusion.Composition/SourceSchemaMerger.cs Registers and applies the new authorize directive merger during type/field merges.
src/HotChocolate/Fusion/src/Fusion.Composition/Properties/CompositionResources.resx Adds localized error strings for invalid @authorize argument shapes/values.
src/HotChocolate/Fusion/src/Fusion.Composition/Properties/CompositionResources.Designer.cs Generated strongly-typed accessors for the new resource strings.
src/HotChocolate/Fusion/src/Fusion.Composition/Directives/AuthorizeDirective.cs Parses @authorize directive arguments into a normalized representation for merging.
src/HotChocolate/Fusion/src/Fusion.Composition/Directives/ApplyPolicy.cs Internal enum representing ApplyPolicy values for merging logic.
src/HotChocolate/Fusion/src/Fusion.Composition/DirectiveMergers/AuthorizeDirectiveMerger.cs Implements merging + de-duplication rules for @authorize directives.
src/HotChocolate/Fusion/src/Fusion.Composition/Definitions/AuthorizeMutableDirectiveDefinition.cs Canonical mutable directive definition for @authorize used for definition matching.
src/HotChocolate/Fusion/src/Fusion.Composition/Definitions/ApplyPolicyMutableEnumTypeDefinition.cs Canonical mutable enum definition for ApplyPolicy.
Files not reviewed (1)
  • src/HotChocolate/Fusion/src/Fusion.Composition/Properties/CompositionResources.Designer.cs: Language not supported

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

@glen-84 glen-84 merged commit b4489a0 into main Mar 17, 2026
128 of 134 checks passed
@glen-84 glen-84 deleted the gai/merge-authorize-directives branch March 17, 2026 09:34
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (922de59) to head (4829a2a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff      @@
##   main   #9378   +/-   ##
============================
============================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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