Product
Hot Chocolate
Version
16.0.6
Link to minimal reproduction
https://github.com/faethto/hotchocolate-include-querycontext-repro
Steps to reproduce
Compare these two integration tests:
StaticIncludeTrue_ShouldReturnProjectedRecordFields
VariableIncludeTrue_ShouldReturnSameProjectedRecordFields
Both tests POST a GraphQL request to /graphql. The only relevant difference is the include directive on parent.child:
child @include(if: true) {
records {
id
sequence
label
}
}
versus:
query Repro($includeChild: Boolean!) {
parent {
child @include(if: $includeChild) {
records {
id
sequence
label
}
}
}
}
with variables:
What is expected?
@include(if: true) and @include(if: $includeChild) with includeChild = true should produce the same selected payload.
The records response should include the explicitly selected scalar fields:
{
"id": 1,
"sequence": 7,
"label": "alpha"
}
The variable-driven include should not alter the QueryContext<SampleRecord> selector for the nested records field when the directive evaluates to true.
What is actually happening?
The static include test passes, but the variable-driven include test fails.
The nested field is executed, and the correct record identity is present, but projected scalar fields are returned with default CLR values:
Assert.Equal() Failure: Values differ
Expected: 7
Actual: 0
Relevant log output
Additional context
No response
Product
Hot Chocolate
Version
16.0.6
Link to minimal reproduction
https://github.com/faethto/hotchocolate-include-querycontext-repro
Steps to reproduce
Compare these two integration tests:
StaticIncludeTrue_ShouldReturnProjectedRecordFieldsVariableIncludeTrue_ShouldReturnSameProjectedRecordFieldsBoth tests POST a GraphQL request to
/graphql. The only relevant difference is the include directive onparent.child:versus:
with variables:
{ "includeChild": true }What is expected?
@include(if: true)and@include(if: $includeChild)withincludeChild = trueshould produce the same selected payload.The
recordsresponse should include the explicitly selected scalar fields:{ "id": 1, "sequence": 7, "label": "alpha" }The variable-driven include should not alter the
QueryContext<SampleRecord>selector for the nestedrecordsfield when the directive evaluates to true.What is actually happening?
The static include test passes, but the variable-driven include test fails.
The nested field is executed, and the correct record identity is present, but projected scalar fields are returned with default CLR values:
Relevant log output
Additional context
No response