Repository navigation
Add the covariant field merging opt-in to StrawberryShake codegen - #10414
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved review comments were supplied, and the configuration, validation, and generation paths are covered by tests.
Review effort: Lite
Findings: None
What changed in this PR
Adds opt-in covariant field merging to StrawberryShake configuration and code generation.
Changes:
- Adds and documents
enableCovariantFieldMerging. - Propagates the option through validation and generation.
- Adds configuration, validation, generation, and snapshot tests.
| File | Description |
|---|---|
website/content/docs/strawberryshake/configuration.md |
Documents the new setting. |
src/StrawberryShake/Tooling/test/Configuration.Tests/GraphQLConfigTests.cs |
Tests configuration deserialization. |
src/StrawberryShake/Tooling/test/Configuration.Tests/__snapshots__/GraphQLConfigTests.Load_Json.snap |
Updates configuration snapshot. |
src/StrawberryShake/Tooling/test/Configuration.Tests/__snapshots__/GraphQLConfigTests.Load_Json_With_Transport_Profiles.snap |
Updates transport profile snapshot. |
src/StrawberryShake/Tooling/test/Configuration.Tests/__snapshots__/GraphQLConfigTests.Load_Json_With_Records.snap |
Updates records snapshot. |
src/StrawberryShake/Tooling/test/Configuration.Tests/__snapshots__/GraphQLConfigTests.Load_Json_With_Documents_Array.snap |
Updates documents array snapshot. |
src/StrawberryShake/Tooling/src/dotnet-graphql/GeneratorHelpers.cs |
Maps configuration to generator settings. |
src/StrawberryShake/Tooling/src/Configuration/StrawberryShakeSettings.cs |
Adds the configuration property. |
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/ResultTypeGeneratorTests.cs |
Tests covariant generated types. |
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/GeneratorTestHelper.cs |
Supports generator test setup. |
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/ErrorGeneratorTests.cs |
Tests validation errors. |
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ResultTypeGeneratorTests.Generate_Should_TypeFieldPerImplementation_When_CovariantMergingEnabled.snap |
Captures generated output. |
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ResultTypeGeneratorTests.Generate_Should_KeepInterfaceFragmentNullable_When_CovariantMergingEnabled.snap |
Captures nullable interface output. |
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__resources__/CovariantFieldsSchema.graphql |
Adds schema fixture. |
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__resources__/CovariantFieldsQuery.graphql |
Adds query fixture. |
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Utilities/OperationDocumentHelper.cs |
Configures document validation. |
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Analyzers/DocumentAnalyzer.cs |
Supports covariant merging during analysis. |
src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/CSharpGeneratorSettings.cs |
Adds the generator option. |
src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/CSharpGenerator.cs |
Applies covariant validation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
Patch coverage93.3% of changed lines covered (28/30)
Uncovered changed lines (JSON){
"sha": "1a398838ce9f8913c61fbf7bcaf9b8ecd88be3dc",
"files": [
{ "path": "src/StrawberryShake/CodeGeneration/src/CodeGeneration/Utilities/OperationDocumentHelper.cs", "ranges": [[70, 71]] }
]
}Project coverage: 58.4% (294410/504031 lines) |
This was referenced Oct 25, 2026
Merged
This was referenced Nov 1, 2026
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
enableCovariantFieldMergingsetting to thestrawberryShakeextension in.graphqlrc.json, off by default. When enabled, both document validators in the code generator (the one inCSharpGeneratorand the one behindDocumentAnalyzer) accept operations that merge fields whose return types differ only in nullability, matching the server-sideEnableCovariantFieldMergingschema option from Add opt-in covariant field merging to selection set validation #10413.String!getsstringwhile a sibling declaringStringgetsstring?, and a fragment on the interface keeps the interface's nullability.Test plan
.graphqlrc.jsondeserialization test covers the new key.StrawberryShake.CodeGenerationandStrawberryShake.Toolingsolutions built and tested with-p:EnforceCodeStyleInBuild=true.