Graphene: orderBy multiple fields

Created on 5 Jul 2016  路  6Comments  路  Source: graphql-python/graphene

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?

Most helpful comment

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

All 6 comments

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

@ivlevdenis helpful. "inherit" is very "beautiful" solutions, thank you so much.

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()

Looks like some workable solutions have been suggested for this issue. Closing

great solutions, thanks

Was this page helpful?
0 / 5 - 0 ratings