Currently, I am developing a front-end app in Next.js, but I need to figured out how can use the before and after cursor results without using a UDF in a graphql query, this is an example of what I try to do in my Api call:
Hey ! Can you provide more information of how you call this query ? (A proper example)
Also how is the q.Index('some_index') implemented (which is somewhat important) ?
Hi @n44ps sorry for my ambiguous question, I want to know how to handle before and after cursor in a frontend application only using fauna FQL, for example in my API using a query similar to this:
Using this query as an example, the first call returns the appropriate cursor (after), I want to know how to implement the cursor to use it in the next operation…
If your result set spans three pages of results, and you have just requested paged 2, that response will contain both a before and an after. You should not specify both in a query, and only your application logic knows whether it wants to move forward or backwards through the pages.
As @n44ps notes, before and after are ignored if null, but your logic should nullify whichever parameter is appropriate for the direction of pagination that is in use.
hi @ewan , maybe this is an old topic, but I still figured out the best way to use the he before and after cursor dynamically from the client side, maybe in a useEffect function or with another data fetch library like swr… in a pure front-end app using nextJS… any guide for this??
We don’t provide any framework-specific examples. There are so many in use… we simply don’t have enough resources to cover them adequately.
Handling pagination is, typically, a sequential task. You might know head of time how many entries exist, but probably not where all of the page boundaries lie. In this respect, Fauna is not very different from other APIs where values in one response need to be used in a subsequent query. There are likely examples for your framework that demonstrate the principles/practices involved in such a workflow, and which should be amenable to modification to handle Fauna queries.
Hopefully, someone else can provide an example for you.