-
-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add infinite query example #69
base: main
Are you sure you want to change the base?
Conversation
@kroucher is attempting to deploy a commit to the trpc Team on Vercel. A member of the Team first needs to authorize it. |
I don't like the idea of relying on an external api for something like this. Does the demo lose anything if it just uses an array of lorem ipsum sentences or something like that? |
I understand what you mean, I was tossing up between faux data and a real API and the main reason is that I didn't want to give the wrong impression/idea about the cursor - that it should come from the external service you're interacting with (which indicates there are more results), not just generated on your backend. If the example showed a cursor being generated and passed through, I fear people will see that and think that's how cursors work. It was also why the Aww subreddit was chosen as the external service - if there's any external service that will always be available, it's Reddit, and if there's a subreddit that won't have any undesirable content being returned, it's the Aww subreddit :P |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've completely missed this!! Thanks.
Definitely a good addition
.input( | ||
z.object({ | ||
limit: z.number().min(1).max(100), | ||
cursor: z.string().optional(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cursor should be validated so you can't inject anything into the url
This PR adds an additional sample to the kitchen sink collection, utilizing the infinite query procedure.
The Reddit /r/Aww subreddit is used as the API endpoint, which returns a cursor in the form of an
after
property.There is basic styling to show similarities to a Reddit post, and a native intersection observer to call the
fetchNextPage
function. More than happy to make any changes to code or styling as requested.Screenshots
Homepage
Infinite Query Page - Initial Loading State
Infinite Query Page - Content loaded