Skip to content

Proposal: Object serialization #431

@SerafimArts

Description

@SerafimArts

I propose the possibility of serializing composite types (like Object) into scalar values. This functional will be useful in those cases when some object can be represented in a scalar value, but it provides (can) a functional (a set of fields).

We can use the name __toScalar field as the serializable value name. Double underline at the beginning is compatible with the standard adopted for system names.

For example:

Definition

type DateTimeObject {
    year: Int!
    month: Int!
    # ...
    ago: String!
    format(format: String!): String!
    __toScalar: DateTime!
}

Usage

As Object

{
    date {
        year
        month
    }
}
{
    "date": {
        "year": 2018,
        "month": 04
    }
}

As Scalar

{
    date # __toScalar field usage
}
{
    "date": "2018-04-28T04:53:23+03:00"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions