Skip to content

Fields are not serialized in order #2943

Closed
@That3Percent

Description

@That3Percent

According to the GraphQL spec, fields should be serialized in order.

7.2.2 Serialized Map Ordering
Since the result of evaluating a selection set is ordered, the serialized Map of results should preserve this order by writing the map entries in the same order as those fields were requested as defined by selection set execution. Producing a serialized response where fields are represented in the same order in which they appear in the request improves human readability during debugging and enables more efficient parsing of responses if the order of properties can be anticipated.

The current implementation instead serializes the field in alphabetical order such that the query

{
  entities(first: 1) {
    owner
    id
  }
}

produces

{
  "data": {
    "entities": [
      {
        "id": "0x4027de966127af5f015ea1cfd6293a3583892668",
        "owner": "0x029aa20dcc15c022b1b61d420aacf7f179a9c73f"
      }
    ]
  }
}

with the field orders id and owner in reverse order from what the spec requires.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions