ChilliCream / graphql-platform

Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Banana Cake Pop the awesome Monaco based GraphQL IDE.
https://chillicream.com
MIT License
5.26k stars 745 forks source link

StrawberryShake: Reset isSet Flags Fluent Method #3602

Closed braidenstiller closed 2 years ago

braidenstiller commented 3 years ago

Is your feature request related to a problem? Please describe. In Blazor, data-binding can be achieved with the mutable input classes SS generates. This usually involves constructing a new instance of an input object with the values from the immutable query object. The dataform then binds to these fields. Because the input object needs to be constructed with some initial state, this causes all the properties isSet flags to be set to true and does not allow for partial updates.

Describe the solution you'd like A way to construct an input object with some initial state, without the isSet flags being set, so that any binding that occurs after construction, is considered actual changes. This can be achieved with a fluent style "ResetFlags" method.

Describe alternatives you've considered Currently I've implemented this in a partial class like follows:

public partial class FooInput
{
    public FooInput ResetFlags()
    {
        this._set_bar = false;
        ... etc

        return this;
    }
}

Using it:

FooInput foo = new FooInput
{
    bar = "some value",
}.ResetFlags();

Having SS auto-generate the resetFlags helper method instead would be beneficial.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.