Is it possible to create queries outside of context?
I have a load function in a
+layout.ts
I'm running a adapter-static, so all this is purely on the browser.
I'd like to send the query through as a store to the pages.
Unfortunately, it looks like @tanstack/svelte-query/context.ts
has a call getIsRestoringContext = (): Readable<boolean>
which results in a call to getContext in svelte - which throws.
Is this a bug in tanstacks context.ts, or just not possible with the design?2 Replies
like-goldOP•2y ago
I do have a a QueryClientProvider set in the root layout - and everything works well - just trying to avoid the boilerplate of recreating the query at the top of each page, instead of just getting it from the exposed
export let data;
The client itself is created in my root +layout.ts
and passed down to the QueryClientProvider via exposed export let data;
, and also available in the child load functionslike-goldOP•2y ago
Well, that was a fun experience. Did my first PR with gitpod 👍
https://github.com/TanStack/query/pull/6193
GitHub
fix(svelte-query): getIsRestoringContext not throw by softgripper ·...
Calling getIsRestoringContext could throw an error.
Now it can't.
The types usage is improved, and the method has a testcase
relates #6188