Skip to content

Subsequent arrays serialized using previous type (when multiple arrays in same object) #1

Description

@bduncanj

What? When generating the GraphQL Object for a struct, subsequent fields of type Array inherit the type of the first field of type Array on that object.

Why? There's an issue with the encoding caching such that types with no name are added to the dictionary. As such, the type of first array field on an object to be parsed will become the type of the next field.

Example:

type Animal struct {
  Legs []Leg
  Arms []Arm
}

When serialized, both of these will be of type Leg (if that was the first to be parsed).

The fix I propose is a guard when adding and querying the cache to ensure the lookup key (the field type name) is a non-zero length string.

So an array field (with no type name in this code) will always causes built with Encoder::ArrayOf(...).

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