Closed MattKleinsmith closed 1 year ago
Relay wants it:
https://relay.dev/graphql/connections.htm
To conform with pagination best practices:
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
}
]
}
}
Okay, I am learning. This is a feature of Relay.
Here's the mental model that Relay wants:
And here's how they implement it in GraphQL (which doesn't allow properties on edges):
This diagram clicks even more with the graphene-sqlalchemy behavior I'm seeing:
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
Hi @erikwrede, thank you for replying. Yes, please tag me in the PR.
Hi @MattKleinsmith, the first PR is here: https://github.com/graphql-python/graphene/pull/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 :)
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.
I would like to be able to use syntax like this:
But instead I must do something like this:
Another example:
From another person wanted the same thing here: https://github.com/graphql-python/graphene-sqlalchemy/issues/374
Will keep poking at examples and the code to try to find a way. Which package is responsible for the edges-node syntax? Is it graphene-sqlalchemy or graphene itself?