Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Support for partial update mutations #128

@braudabaugh

Description

@braudabaugh

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions