Graphql error when sorting a linked entity on multiple fields

Hi!

I have encountered the following error since v10.11.0, and the bug is still there in the latest 10.11.2:

this query:

query {
  getHelmChartRelease(id: "web-api-0.2.5") {
    name
    workloadConfigs(
      first: 10
      order: { asc: _workloadType, then: { asc: _workloadName } }
    ) {
      id
    }
  }
}

caused the following error:

{
  "errors": [
    {
      "message": "Dgraph query failed because Dgraph execution failed because line 4 column 106: Expecting argument name. Got: lex.Item [13] \":\" at 4:106"
    }
  ],
  "data": {
    "getHelmChartRelease": null
  },
  "extensions": {
    "tracing": {
      "version": 1,
      "startTime": "2021-02-24T22:26:15.3953558Z",
      "endTime": "2021-02-24T22:26:15.3962141Z",
      "duration": 859400,
      "execution": {
        "resolvers": [
          {
            "path": [
              "getHelmChartRelease"
            ],
            "parentType": "Query",
            "fieldName": "getHelmChartRelease",
            "returnType": "HelmChartRelease",
            "startOffset": 168200,
            "duration": 512200,
            "dgraph": [
              {
                "label": "query",
                "startOffset": 261300,
                "duration": 328400
              }
            ]
          }
        ]
      }
    }
  }
}

However, sorting on a single field would work just fine:

query {
  getHelmChartRelease(id: "web-api-0.2.5") {
    name
    workloadConfigs(
      first: 10
      order: { asc: _workloadType }
    ) {
      id
    }
  }
}

And note that sorting on multiple fields at the top level would work too:

query {
  queryKubeWorkloadConfig(
      first: 10
      order: { asc: _workloadType, then: { asc: _workloadName } }    
  ) {
    id
  }
}

Thanks a lot for your help,

Morgan

Hi!
Any followup on my issue?
Thanks

Hi @livetocode , i reproduced this bug. Looks like something wrong in query rewriting.
I am accepting this and will fix it soon.

1 Like

Hi @livetocode , This bug is fixed in master branch, and will be available in 21.03 release.
PR:fix(GRAPHQL): fix query rewriting for multiple order on nested field. by JatinDevDG · Pull Request #7523 · dgraph-io/dgraph · GitHub

1 Like