wagmi icon indicating copy to clipboard operation
wagmi copied to clipboard

feat: Isolate wagmi query context from react-query default context

Open aj-may opened this issue 2 years ago • 5 comments

Description

Isolating the react-query context used by wagmi from the default context used by react-query.

Additional Information

For applications that are using both the wagmi and react-query libraries, both will typically end up using the same queryClient. This means that useQuery calls from within my application may inadvertently use the wagmi client, and the defaults it sets (if the wagmiConfig provider is the innermost provider), or wagmi calls to useQuery will end up using my applications queryClient and the defaults I have set.

This actually can cause a bit of a debugging nightmare as the persister set in the wagmi queryClient doesn't play nice with SSR frameworks like Next.js.

This lack of isolation was also discussed here: https://github.com/wagmi-dev/wagmi/discussions/661

This is my first contribution to this library so I'm not super familiar with the dev set-up. I ran the tests before and after my changes and got the same results, but I did have failing tests.

I also want to call out, I did overwrite options.context in useBaseQuery. I don't think this should have any negative consequences as I don't see context being passed as an option anywhere useBaseQuery was called. If this assumption is not true please let me know, happy to change the approach.

  • [x] I read the contributing docs (if this is your first contribution)

Your ENS/address: ajmay.eth

aj-may avatar Sep 18 '22 15:09 aj-may

🦋 Changeset detected

Latest commit: 6565dfd956deed04f8266e6d3f0d900819e1b35e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wagmi Patch

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

changeset-bot[bot] avatar Sep 18 '22 15:09 changeset-bot[bot]

@aj-may is attempting to deploy a commit to the wagmi Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Sep 18 '22 15:09 vercel[bot]

@tmm @jxom Thoughts on this PR? Any feedback?

aj-may avatar Sep 20 '22 16:09 aj-may

@jxom For some context, why is useQuery, useBaseQuery, etc. forked currently?

aj-may avatar Sep 21 '22 13:09 aj-may

@aj-may – We needed our own useBaseQuery as we wanted to modify the return value API of RQ without losing the tracked values behaviour.

jxom avatar Sep 21 '22 23:09 jxom

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
wagmi ✅ Ready (Inspect) Visit Preview Sep 25, 2022 at 8:12PM (UTC)

vercel[bot] avatar Sep 22 '22 21:09 vercel[bot]

If we can also get a changeset happening, that would be amazing!

pnpm changeset, and then make this one a patch 🙏

jxom avatar Sep 22 '22 21:09 jxom

@tmm updated based on comments. Take another look when you can

aj-may avatar Sep 25 '22 14:09 aj-may

@jxom Excellent! Any final changes needed from me here, or is this just waiting on another review and merge?

aj-may avatar Sep 27 '22 13:09 aj-may