Skip to content

fix: Use Operation Interface Type instead of Runtime Type#9636

Open
cliedeman wants to merge 1 commit into
ChilliCream:mainfrom
stackworx:fix/razor-operation-interface
Open

fix: Use Operation Interface Type instead of Runtime Type#9636
cliedeman wants to merge 1 commit into
ChilliCream:mainfrom
stackworx:fix/razor-operation-interface

Conversation

@cliedeman

Copy link
Copy Markdown

Fixes #9635

Copilot AI review requested due to automatic review settings May 2, 2026 18:45

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

Updates Strawberry Shake Razor component code generation so generated components inject operation services via the generated interface type (e.g., IGetBarsQuery) rather than the concrete runtime type, improving testability/mocking (Fixes #9635).

Changes:

  • Emit descriptor.InterfaceType for the injected Operation property in Razor query components.
  • Emit descriptor.InterfaceType for the injected Operation property in Razor subscription components.
  • Update the Razor generator snapshot to reflect the interface-based injection.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/StrawberryShake/CodeGeneration/test/CodeGeneration.Razor.Tests/snapshots/RazorGeneratorTests.Query_And_Mutation.snap Updates expected generated output to inject IGetBarsQuery instead of GetBarsQuery.
src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/RazorSubscriptionGenerator.cs Switches subscription component Operation injection type from runtime type to interface type.
src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/RazorQueryGenerator.cs Switches query component Operation injection type from runtime type to interface type.

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

Token(SyntaxKind.PartialKeyword))
.AddGeneratedAttribute()
.AddMembers(CreateOperationProperty(descriptor.RuntimeType.ToString()));
.AddMembers(CreateOperationProperty(descriptor.InterfaceType.ToString()));
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.

Strawberry Shake Razor Components use RuntimeType instead of InterfaceType for Operation

2 participants