You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The invalidate function only re-runs load if fetch is used. This is not possible in cases where an APIClient does not allow for customization of the fetching process or when using non REST APIs like GraphQL.
Solution
Add a dependencies array to the LoadOutput (suggested by @Rich-Harris in #1709).
The dependencies will be registered the in the same way fetch does it. This allows not only to invalidate real resources but entire pages or groups of pages.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
This message body should clearly illustrate what problems it solves.
Ideally, include a test that fails without this PR but passes with it.
Tests
Run the tests with pnpm test and lint the project with pnpm lint and pnpm check
Changesets
If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpx changeset and following the prompts. All changesets should be patch until SvelteKit 1.0
@icalvin102 just a quick question....
Is this problem not solved by page endpoints?
To the best of my understanding this should generate a load function on build.
By moving the $lib/myapi integration to the endpoint there should be no trouble on calling the load again 😉
@dreitzner page endpoints will only work if your API is written in sveltekit AFAIK.
Page endpoints wont work in SPA mode and/or when using third party APIs that rely on browser state like cookies that are not accessible from the sveltekit server.
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
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.
Closes #1684
Problem
The
invalidatefunction only re-runsloadif fetch is used. This is not possible in cases where anAPIClientdoes not allow for customization of the fetching process or when using non REST APIs like GraphQL.Solution
Add a
dependenciesarray to theLoadOutput(suggested by @Rich-Harris in #1709).The dependencies will be registered the in the same way
fetchdoes it. This allows not only toinvalidatereal resources but entire pages or groups of pages.Example Usage
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpx changesetand following the prompts. All changesets should bepatchuntil SvelteKit 1.0