Graphql select relation

Given this example, https://docs.fauna.com/fauna/current/tutorials/graphql/relations if we had thousands of ToDos, how would one query ToDo’s (and paginate) for a given list?

Default size for a Page is 50. You can use after as _cursor to get more ToDos for a given List

Here is an example.

Get First 5 Todos

Get Next set of 5 Todos.

1 Like

This is perfect, and pretty simple. Thanks!

@Jay-Fauna What if I also wanted to use an index to say sort my Todos by something like Title or DueDate?

@scottyob

You should

  1. Define a resolver.
  2. Create a sorted Index.
  3. Update the User Defined Function to use this Index.
  4. Use Pagination in GraphQL.

Hope this helps.

It does, just a lot more work than anticipating :frowning: And even then, given the examples it’s still unclear what I’d need to do the sorting and resolver on the sub-collection. I’ll have a play in my spare time this week and see if I can figure it out, otherwise I might just drop using graphql as too complicated to work out at this time and move my code to direct FQL.