InputParsing with Strawberry Shake runtime types
Product
Hot Chocolate
Version
15.0.0
Link to minimal reproduction
https://github.com/jarlef/InputParsingUnsetOptionalFields
Steps to reproduce
We are trying to connect 2 graphql apis together using strawberry shake to fetch data from other. The api that is being called is exposing data with the ability to specify HC filtering and sorting. The consuming api invokes this api with forwarding / proxying the filters and sorting inputs from the user using Strawberry shake generated types. The issue is that the InputParser is setting all the properties on the Strawberry shake runtime type even though its not specified by the incoming payload, resulting in all the hidden set fields for the Strawberry shake is set to true
E.g incoming request
{
myItems(order: [ { Id: ASC } ]) {
id
title
}
}
The issue with the strawberry shake runtime type
public global::MyAPI.Generated.SortEnumType? Id
{
get => _value_id;
set
{
_set_id = true;
_value_id = value;
}
}
public global::MyAPI.Generated.SortEnumType? Title
{
get => _value_title;
set
{
_set_title = true; // <= this get set to true
_value_title = value;
}
}
Afterwards both the id and title is forwarded to the second api with titles sort value = null
What is expected?
Only the fields specified in the incoming payload to be marked as set. The InputParser seems overly eager in setting properties, even tough the value are null
What is actually happening?
The filter and sort inputs objects are not valid since they register every property as set in Strawberry Shake.
Relevant log output
Additional context
No response