I’m working on implementing a “Load More” functionality directly within a RedwoodJS Cell component. My goal is to allow users to fetch additional data upon clicking a “Load More” button, and then append these new results to the already displayed list of items, effectively accumulating the results without navigating away or reloading the entire dataset.
Here’s the challenge:
I am fairly new to Redwood and Graphql. I understand that Redwood Cells encapsulate the data fetching lifecycle and don’t directly expose functions like fetchMore as you might find in Apollo Client’s useQuery hook. Given this, I’m seeking guidance on the best way to achieve the following within a Cell:
Trigger Additional Fetches: My thought was to just call a “fetchMore” like method from within the cell from a button and merge data together manually. But I don’t think “fetchMore” is exposed.
Best Practices: Are there any recommended patterns or practices within the RedwoodJS framework for achieving this kind of functionality while maintaining the benefits of using Cells?
I have looked at a few posts like :
But I don’t understand the approaches mentioned there.
Any examples, suggestions, or insights on how to approach this would be greatly appreciated.
And then the <LoadMoreButton> can be used anywhere you want to show more results as long as you pass it a bunch of results and the fetchMore() function:
I have a little more logic in the real code for determining if there are actually more to show (and hide the button if not), display a loading spinner while they’re incoming, etc.