0

I am trying to sort some of my results but using a string the sortby is ignored.

query ($limit: Int!, $categoryId: Int) {
  allAwards(first: $limit, orderBy: "DATE_DESC") {
    edges {

{
  "errors": [
    {
      "message": "Enum \"AwardsOrderBy\" cannot represent non-enum value: \"DATE_DESC\". Did you mean the enum value \"DATE_DESC\", \"DATE_ASC\", or \"IMAGES_DESC\"?",
      "locations": [
        {
          "line": 2,
          "column": 37
        }
      ]
    }
  ]
}

However if I use the enums it works:

allAwards(first: $limit, orderBy: DATE_DESC) {

But in my code, I do not have access to the enums in native JS. I do not use TS.

But then if I supply it as a string as a variable I get an error:

query ($limit: Int!, $categoryId: Int, $orderBy:[AwardInfosOrderBy!]) {
  allAwards(first: $limit, orderBy: $orderBy) {

//variables
{
  "orderBy": ["DATE_DESC"],
}
//error
{
  "errors": [
    {
      "message": "Variable \"$orderBy\" of type \"[AwardInfosOrderBy!]\" used in position expecting type \"[AwardsOrderBy!]\".",
      "locations": [
        {
          "line": 1,
          "column": 40
        },
        {
          "line": 2,
          "column": 37
        }
      ]
    }
  ]
}
Jamie Hutber
  • 26,790
  • 46
  • 179
  • 291
  • 1
    It's telling you to declare the variable as `AwardsOrderBy` instead of `AwardInfosOrderBy` – Bergi Feb 26 '23 at 00:30

0 Answers0