Giter VIP home page Giter VIP logo

Comments (4)

leebyron avatar leebyron commented on April 28, 2024 1

Thanks, @devknoll. Right on point. A field argument like order or orderBy means as much to GraphQL as fooBar. It's just a key/value pair that gets provided to the underlying function.

In the example @devknoll provided, you might imagine the backing function looking something like:

function (user, { first, order }) {
  return doSomeWorkToGetEventsForUser(user, { limit: first, orderByKey: order });
}

Where that function does something interesting like a mongodb, sql, or parse query. where ensures the understood semantics for an ordering is applied.

This is important as different backing stores have different semantics for ordering and different orderings may be more expensive and shouldn't be exposed (e.g. large tables where some columns don't have indexes, or a field that is derived information) so the implementing type system may completely choose how to represent and resolve this.

from graphql-spec.

devknoll avatar devknoll commented on April 28, 2024

I believe that something like this popped up in one of @leebyron's slides at ReactEurope. The gist of it is that you would expose the type of sorting that you want through field arguments.

{
  user(id: 4) {
    events(first: 1, order: IMPORTANT) {
      ...
    }
  }
}

That is, GraphQL itself doesn't have any notion of sorting. If you want results to be sorted, you would implement the appropriate arguments and semantics that you want. The reason being that GraphQL is storage and backend independent and can't really reason about that.

from graphql-spec.

KyleAMathews avatar KyleAMathews commented on April 28, 2024

Cool! Seems very reasonable.

from graphql-spec.

gajus avatar gajus commented on April 28, 2024

Would be nice if this somehow got standardised.

from graphql-spec.

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.