Skip to content

Unexpected order of properties in response #3256

@EmrysMyrddin

Description

@EmrysMyrddin

The problem

GraphQL operation results content should be stable, in particular the field order should be respected based on the query. This is a requirement of the GraphQL spec

Discussed in #3218

Originally posted by marceloverdijk March 31, 2024
I noticed having a query like:

query MyQuery {
  countries(first:100) {
    totalCount
    nodes {
      code
      name
      continent {
        name
      }
    }
  }
}

the response is:

{
  "data": {
    "countries": {
      "totalCount": 249,
      "nodes": [
        {
          "name": "Afghanistan",
          "code": "AF",
          "continent": {
            "name": "Asia"
          }
        },
        {
          "name": "Åland Islands",
          "code": "AX",
          "continent": {
            "name": "Europe"
          }
        },
  ..

In the response I would expect the order of the fields in the same order as requested.

But in the response the name field is before the code field.

This is quite annoying when testing an server, or even thinking about exposing a GraphQL service to (semi) business people that e.g. before used SQL to query data.

Is this something that can be configured?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions