feat: queryception#15952
Draft
elliott-with-the-longest-name-on-github wants to merge 4 commits into
Draft
Conversation
🦋 Changeset detectedLatest commit: ab6a630 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Allows returning
query,query.live, andprerenderinstances from queries, commands, and forms.prerenderinstances can also return otherprerenderinstances*.This was born of frustration when working with hierarchical data. Imagine you're building out the GitHub PRs view at https://github.com/sveltejs/kit/pulls. You want to be able to fetch 25 pulls per page, which means making a batch query to the server to figure out which pulls to display. However, it would be quite useful to be able to make each row of the response a query itself -- that is, you want a
get_pullsquery that returnsget_pullqueries. This way, when you click through to a pull request, theget_pullquery cache is already cached. And, crucially, you can single-flight mutate, refresh, or override (via .set) individualget_pullinstances to update the individual row.When implementing the
/{repo}/pull/{number}page, you already have warm data from theget_pullcache, so depending on the performance characteristics you want for your application, you could choose whether to preload all of the pull details (like commits, comments, etc.) inget_pulls. Or you could choose to have anotherget_pull_detailsremote function to get the additional data, but you'd still be able to instantly navigate to the pull page with the basic pulls data and skeleton-load-in theget_pull_detailsdata. It's very flexible.Concretely, this looks like:
And usage in your Svelte component looks like:
You could also wrap each row in its own pending snippet if you wanted to have control over things that happen when you
.refreshan individualget_pullinstance.You can also return queries from
commandandformresponses, because why wouldn't you be able to do that!You can also technically have recursive query responses. But... come on. Show some restraint.
TODO explain limitations with prerender
TODO add better tests