Giter Site home page Giter Site logo

Comments (9)

erikwrede avatar erikwrede commented on June 12, 2024 1

Hey Matt, good to see that you've familiarized yourself with the Relay spec 😊 I agree that it is confusing at first, but once you've got the intuition, it makes a lot more sense-
However, I think you've got a point with your statements. Sometimes you don't need all the pagination info but just want to get the benefits of a connection (e.g. filtering or other constraints), but don't need the edges. Currently prototyping an optional nodes field on the connections:

{
    pets {
        nodes {
              name
        }
    }
}

This way you can get rid of the additional nesting layer in cases where you really don't need it. Please LMK if you're interested in that, so I can tag you for PR review once it's ready in a few weeks. 🙂

If you have some specific points of that could be improved on the graphene-sqlalchemy docs, I'd appreciate any PRs bringing improvements.

Cheers

from graphene-sqlalchemy.

MattKleinsmith avatar MattKleinsmith commented on June 12, 2024

graphql-python/graphene#1073

from graphene-sqlalchemy.

MattKleinsmith avatar MattKleinsmith commented on June 12, 2024

Relay wants it:

https://relay.dev/graphql/connections.htm

To conform with pagination best practices:

https://graphql.org/learn/pagination/

from graphene-sqlalchemy.

MattKleinsmith avatar MattKleinsmith commented on June 12, 2024

Re-opening because I'd like to know how to turn off pagination, if it's possible. The edge-node syntax makes sense to me for relationships, but I would like to turn it off for basic queries, like getting all product prices.

Instead of this:

{
    "data": {
        "allProducts": {
            "edges": [
                {
                    "node": {
                        "price": 39.99
                    }
                },
                {
                    "node": {
                        "price": 49.95
                    }
                }
            ]
        }
    }
}

Would prefer:

{
    "data": {
        "allProducts": [
                {
                    "price": 39.99
                },
                {
                    "price": 49.95
                }
          ]
    }
}

from graphene-sqlalchemy.

MattKleinsmith avatar MattKleinsmith commented on June 12, 2024

Okay, I am learning. This is a feature of Relay.

Here's the mental model that Relay wants:

image

And here's how they implement it in GraphQL (which doesn't allow properties on edges):

image

https://relay.dev/docs/tutorial/connections-pagination/

from graphene-sqlalchemy.

MattKleinsmith avatar MattKleinsmith commented on June 12, 2024

This diagram clicks even more with the graphene-sqlalchemy behavior I'm seeing:

image

from graphene-sqlalchemy.

MattKleinsmith avatar MattKleinsmith commented on June 12, 2024

Hi @erikwrede, thank you for replying. Yes, please tag me in the PR.

from graphene-sqlalchemy.

erikwrede avatar erikwrede commented on June 12, 2024

Hi @MattKleinsmith, the first PR is here: graphql-python/graphene#1499
Another PR will be necessary to add native support in graphene-sqlalchemy, but this change enables us to work with the native graphene-relay Connections. Please LMK what you think :)

from graphene-sqlalchemy.

github-actions avatar github-actions commented on June 12, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related topics referencing this issue.

from graphene-sqlalchemy.

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.