Is it able to sort by subfields in directus v9 Graphql Query

Viewed 394

I am trying to sort a Graphql Query in Directus v9 by a subfield.

There is a small description how to do this... but not for subfields:

https://docs.directus.io/reference/query/#sort

my query looks like this:

query {
  invoices(sort: ["customer__name"] ) {
    id
    status
    customer {
      id
      name
    }
  }
}

I have tried multiple forms like customer:name, ```customer_name``.

if i sort by field "status" in ascending order the query looks like this and it works:

query {
  invoices(sort: ["status"] ) {
    id
    status
    customer {
      id
      name
    }
  }
}

if i sort by field "status" in descending order the query looks like this and it works:

query {
  invoices(sort: ["-status"] ) {
    id
    status
    customer {
      id
      name
    }
  }
}

has anyone tried this?

1 Answers
Related