question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

orderBy multiple fields

See original GitHub issue

I’m just trying to construct a query with multiple ordering fields (I’m using the django example btw).

Here’s what I have right now …

{
  allCategories(orderBy: "name")
  edges {
    node {
      id
      name
      slug
    }
  }
}

This works fine, but I like to order by multiple fields …

allCategories(orderBy: "name, slug")
allCategories(orderBy: ["name", "slug"])

Am I using the wrong syntax or is this not even possible?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
syrusakbarycommented, Jul 6, 2016

Graphene doesn’t support that yet, it might be a good case to add!

5reactions
heyrictcommented, Jan 28, 2018

I’m using this resolve function to handle a list of orderBy.

    def resolve_all_users(self, info, **kwargs):
        orderBy = kwargs.get("orderBy", None)

        if orderBy:
            return User.objects.order_by(*orderBy)
        else:
            return User.objects.all()
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Order By Two Columns in SQL? - LearnSQL.com
After the ORDER BY keyword, add the name of the column by which you'd like to sort records first (in our example, salary)....
Read more >
SQL multiple column ordering - Stack Overflow
After the ORDER BY keyword, add the name of the column by which you'd like to sort records first (in our example, salary)....
Read more >
SQL Server ORDER BY clause By Practical Examples
First, you specify a column name or an expression on which to sort the result set of the query. If you specify multiple...
Read more >
SQL - Multiple Column Ordering - GeeksforGeeks
It is used to sort the result-set in ascending or descending order. It sorts the records in ascending order by default. To sort...
Read more >
Sorting on multiple columns - IBM
You can also ORDER BY two or more columns, which creates a nested sort . The default is still ascending, and the column...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found