Code Monkey home page Code Monkey logo

Comments (5)

SachaG avatar SachaG commented on July 19, 2024

I found one here:

enum UserOrderByInput {
  # ascending and descending for all non-list scalar fields
}

query { users(orderBy: UserOrderByInput): [User!]}

query { users(orderBy: NAME_ASC) {name}}

I don't know if I'm a fan of NAME_ASC though? What about { name : 1 } or { name: -1 } like in Mongo?

from opencrud.

GromNaN avatar GromNaN commented on July 19, 2024

The naming fieldName_ASC is concise and consistant with other parts of OpenCRUD like filtering.

There is an issue if we need to sort on several fields or on a field from a relation.

Proposition : orderBy could accept a list of fields:

query { users(orderBy: [UserOrderByInput] ): [User!]}
query { users(orderBy: [role_ASC, name_DESC] ) {name}}

GitHub style:

query  {
  user(login:"GromNaN") {
    issues(first:100, orderBy:{field:COMMENTS, direction:ASC}) {
      edges {
        node {
          id
          title
        }
      }
    }
  }
}

from opencrud.

Jannis avatar Jannis commented on July 19, 2024

Could the orderBy input type be a union, like this?

orderBy: UserOrderByInput! | [UserOrderByInput!]!

Assuming GraphiQL and other tools handle this right, they would still provide auto-completion for orderBy this way, especially in cases where only one attribute is needed.

from opencrud.

GromNaN avatar GromNaN commented on July 19, 2024

Input type be a union is not supported (yet). graphql/graphql-spec#488

from opencrud.

sorenbs avatar sorenbs commented on July 19, 2024

While GraphQL does not support union input types, a single input element is actually coerced into a single item list, so in this case we don't need a union type :-) See: prisma/prisma#95 (comment)

from opencrud.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.