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(...).
What? When generating the GraphQL Object for a struct, subsequent fields of type
Arrayinherit the type of the first field of typeArrayon 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:
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(...).