feat(solid-query-persist-client): Solid.js implementation of client persistence#5858
feat(solid-query-persist-client): Solid.js implementation of client persistence#5858ardeora merged 31 commits intoTanStack:betafrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 3c0d1c0:
|
|
I updated the tests to Vitest, something that I missed. I can't get two tests to pass, but I will work on them tomorrow. |
|
@TkDodo @ardeora The only test that does not pass is the persistence being maintained upon the const [client, setClient] = createSignal(new QueryClient());
<QueryClientProvider client={client}>
{props.children}
</QueryClientProvider>
// calling useQueryClient returns an Accessor
const client = useQueryClient();
client()...Otherwise, I would appreciate any feedback on the PR. Thanks! |
|
awesome work, thank you. please look at the failed formatting, and let's wait for @ardeora to review |
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 3c0d1c0. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch
Sent with 💌 from NxCloud. |
|
Thank you so much for working on this! I am currently in the middle of moving to a new city so I would be unavailable for a review till this Sunday 😬 Hope that's not an issue. If it's something urgent I can take a look at it tomorrow or day after 😅 |
|
@ardeora No worries. Just pushed the formatting fix. Thanks! |
|
@aadito123 Awesome work! It looks like the query can hydrate data from persisters but it doesn't do a background re-fetch after hydration. Any idea why? I'm taking a closer look to see why that happens! |
|
@ardeora Odd. I assumed the Edit: also noticed that tests that were passing are now failing |
|
Took me a while to figure out where the refetch wasn't happening but it should be okay now. @ardeora Let me know if it works now. |
|
@ardeora Seems the only test failing is This is all ignoring the fact that the Edit: Nevermind, I can circumvent the undefined issue with |
|
Oh wow! This is so strange I never noticed before. Apparently, https://playground.solidjs.com/anonymous/35ce36ae-e070-4cc5-b2cd-0b876e934271 Hmm 🤔 I'm not sure how I feel about Also not sure why would we ever want to switch queryClients during runtime? Is there a specific use case that I'm not understanding? |
|
Should also note that this would be a breaking change for only the solid-query package of the v5 beta. I could go either way on this matter because I don't personally rely on the query client being reactive, however, this is something that react-query does do, so for the sake of feature parity, it might be worthwhile. Only use case I've seen for runtime query client changes has been to maintain different caches for clients with different cache settings. For example, client 1 might hold data in the cache for a day, whereas client 2 would hold it for an hour. This way, you can switch options without having to throw away the cache for either. |
|
@aadito123 I think I have a way to preserve backwards compat and make queryClient reactive without breaking changes. How about we preserve reactivity inside the implementation detail? https://playground.solidjs.com/anonymous/90507ec4-3060-40b5-8cdd-514d20107fed This way const queryClient = useQueryClient()
// queryClient will still be the actual query clientIn the above approach the queryClient will still be queryClient object but it wont be reactive. Similar to how const [count, setCount] = createSignal(20)
const countCopy = count()
If you want to get a queryClient that can switch during runtime. You can track it in a reactive scope and it will work like so const reactiveClient = createMemo(() => useQueryClient())
createEffect(() => {
console.log('Will run everytime queryClient reference changes')
console.log('Client Changed:', reactiveClient())
})Does this make sense? This change can be adopted for this PR too. Let me know what are your thoughts on it! |
|
@ardeora Makes perfect sense, I should have thought about that. The reactivity is a bit hidden outside the library but I am sure documentation can cover that. I made the change and it still passes the tests. |
|
So weird. The same tests are failing on the base |
sadly, some tests are flaky. I think the react-query ones only run because of the change in the devtools-core package. You can ignore it for now |
|
This is looking great! Thank you so much for working on this 😄 ❤️ Do you have a twitter handle? Would you mind if we give you a shout out on twitter? |
|
@ardeora My handle is @SwagMaster19 but I'm not all that active. Would be happy with the shout-out, nonetheless. Thanks! |
Implemented the
query-persist-client-corefor Solid.js.Also made changes to the base
solid-querypackage so thatisRestoringcan be respected.Translated the tests from the React implementation, and they all pass.
Addresses the following: #5463