Closed
Description
The need come from displaying the user a list of nodes that she should be able to sort/filter.
I'd like to get a better grasp on the philosophy behind Connection
s and how would one go in building a backend to support the {before,after,first,last}
pagination along with ordering/filtering.
From graphql/graphql-spec#4 I understand that GraphQL per se doesn't really care on how you handle pagination/filtering/ordering. Hence I'm writing here even if I realize that this is not strictly in the Relay scope.
My general question is: how do you go in handling filtering and especially sorting the Relay way (if at all) and why?
Lets say we could query with a Relay server like:
currentUser {
friends(first:10, after:"opaque-cursor", order:AGE) {
edges: [ ... ]
}
}
I guess my questions are:
- would that connection make sense (in that example
AGE
would be an Enum value) or would be querying for a differentfirendsOrderedByAge
connection be more aligned with Relay philosophy? Or what else? - say you want to combine multiple ordering, how would you go about that? I'm currently trying with ie:
friends(order:[AGE,POSTCOUNT], ...)
- as the API I'm currently trying to proxy via a Relay server does not map well with the
Connection
model, how would you go in building a backend API that does? - I'm trying to cut all the way to the SQL to at least make this work. say you get back
{after_age, after_id}
from your opaque cursor in theafter
parameter; would a pseudo-SQL like this make sense?SELECT * FROM a_table WHERE (age, id) > (after_age, after_id) ORDER BY age ASC, id ASC LIMIT first
Thank you all!