Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Officail support / Documentation of Sort #1664

Closed
Fitmavincent opened this issue Jan 14, 2021 · 1 comment
Closed

Officail support / Documentation of Sort #1664

Fitmavincent opened this issue Jan 14, 2021 · 1 comment
Labels
docs Concerns the documentation

Comments

@Fitmavincent
Copy link

**The Problem: **
I've been looking around for a solution of sort in the official documentation, but I don't seem to find it.

**Possible solutions: **
After some Googling and found this post on Stack Overflow.

Stack Overflow: laravel-lighthouse-graphql-sorting-on-server-side

It works for me, but I'm not sure what's Repo owner/contributor on this. If this is by designed, can we make this into the official documentation?

Here's a quick look of the solution answer by: thekeymaster

type Query {
    user(firstName: String @eq orderBy: [OrderByClause!] @orderBy): [User!]! @paginate(type: "paginator" model: "App\\User")
}

type User {
    id: ID!
    firstName: String!
    lastName: String!
    birthDate: DateTime!
    email: String!
    created_at: DateTime!
    updated_at: DateTime!
}

input OrderByClause{
    field: String!
    order: SortOrder!
}

enum SortOrder {
    ASC
    DESC
}
query {
  user(count:20, firstName:"Foo", orderBy: [
        {
          field: "birthDate"
          order: DESC
        }
    ]) {
    data {
      name
      region
      birthDate
    }
  }
}
@spawnia spawnia added the docs Concerns the documentation label Jan 14, 2021
@spawnia
Copy link
Collaborator

spawnia commented Jan 14, 2021

@orderBy is the blessed solution, can you add a PR with a small section about it to https://github.com/nuwave/lighthouse/blob/master/docs/master/eloquent/getting-started.md?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Concerns the documentation
Projects
None yet
Development

No branches or pull requests

2 participants