Skip to content

Only serialize properties that have been assigned #118

Description

@NickStrupat

Currently, ZeroQL will serialize a model to JSON text with all the properties, regardless of whether or not they've been assigned, except properties that have a value of null.

This is a problem for any nullable properties that should, during a mutation, be assigned to a value of null.

I propose that models should track which properties have been assigned, and only properties that have been assigned should be in the resulting payload to the server.

Below is an example of a possible implementation of what the generated model code would be...

class Foo
{
    private readonly Dictionary<string, object> assignedProperties = new(); // all models would have this field

    private string? text;
    public string? Text { get => text; set => assignedProperties["Text"] = text = value; }

    private int count;
    public int Count { get => text; set => assignedProperties["Count"] = text = value; }
}

And then whenever serialization happens, it would serialize foo.assignedProperties instead of foo itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions