-
-
Notifications
You must be signed in to change notification settings - Fork 62
Closed
Labels
Description
Partial updates are useful for allowing a single mutation function update only the fields provided in the input payload instead of arbitrarily setting the missing fields to null. But in the current GraphQL Conventions framework there is no way to detect whether a given field was provided by the client.
The proposal is to add an Optional wrapper that can be applied to the input fields of partial update mutations that exposes an IsSpecified property for checking whether the client included that field.
Below is an example of an input type using the proposed wrapper:
[InputType]
public class ProfileInput
{
public Optional<string> FirstName { get; set; }
public Optional<string> LastName { get; set; }
}
And this code snippet shows how the IsSpecified property might be used for processing the update:
if (input.FirstName.IsSpecified)
{
dto.FirstName = input.FirstName.Value;
}
if (input.LastName.IsSpecified)
{
dto.LastName = input.LastName.Value;
}
I have already implemented this in a fork and will be submitting a PR shortly.
BilyachenkoOY and shoe-diamente