Skip to content

Load More Pagination using Prisma, Urql & React? #1550

Answered by JoviDeCroock
deadcoder0904 asked this question in Q&A
Discussion options

You must be logged in to vote

Depending on what cache you use there are a few options, one of them outlined in the documentation and two of them using your FE style of choice.

In graphCache you can use a custom resolver

You can also just use a usePagination helper:

const usePagination = (query, variables) => {
  const [skip, setSkip] = React.useState(0)
  const [data] = React.useState([])
  const [result] = useQuery({ query, variables: { ...variables, skip} })
  
  React.useEffect(() => {
    if (!result.fetching && result.data) {
      // write to data state
    }
  }, [result]);

  return [data]
}

The above probably needs some tweaking, it's more meant to give you a rough idea.

You can also use a VDOM based approac…

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@deadcoder0904
Comment options

@JoviDeCroock
Comment options

@deadcoder0904
Comment options

@JoviDeCroock
Comment options

@deadcoder0904
Comment options

Answer selected by JoviDeCroock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants