Skip to content

Conversation

@aantipov
Copy link
Contributor

@aantipov aantipov commented Jan 4, 2022

Hi,

I noticed a bug in useQueries hook: if a query is deleted from the list of provided queries, it isn't reflected in the result. The result doesn't match queries anymore.

This PR fixes the bug.

I also added a test which catches this problem.

Bonus: I made the function to accept Refs. I believe a common use case is constructing Queries as a computed value. This fix makes it possible to provide computed values

Lemme know what you think :)

Alexey

@vercel
Copy link

vercel bot commented Jan 4, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/damianosipiuk/vue-query/GasAQTXFz3hWdu7Zn5R2AH7hz7M4
✅ Preview: https://vue-query-git-fork-aantipov-improve-use-qu-1ad5d7-damianosipiuk.vercel.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jan 4, 2022

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 2215fa9:

Sandbox Source
DamianOsipiuk/vue-query: basic Configuration
DamianOsipiuk/vue-query: 2.x-basic Configuration
DamianOsipiuk/vue-query: nuxt-simple Configuration

@DamianOsipiuk
Copy link
Owner

Hi, thanks for the contribution!

I don't have access to PC right now, so I will take a look at this PR at the beginning of next week. Hope that is ok.

@aantipov
Copy link
Contributor Author

aantipov commented Jan 4, 2022

Hi, thanks for the contribution!

I don't have access to PC right now, so I will take a look at this PR at the beginning of next week. Hope that is ok.

Sure, that's ok, take your time! Thanks for the quick response.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@codecov
Copy link

codecov bot commented Jan 10, 2022

Codecov Report

Merging #105 (2215fa9) into main (51c8fed) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #105   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           13        13           
  Lines          210       213    +3     
  Branches        34        35    +1     
=========================================
+ Hits           210       213    +3     
Impacted Files Coverage Δ
src/vue/__tests__/test-utils.ts 100.00% <100.00%> (ø)
src/vue/useQueries.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 51c8fed...2215fa9. Read the comment docs.

Comment on lines +131 to +132
const queryClientKey = (unref(queries) as UseQueriesOptionsArg<T>)[0]
?.queryClientKey;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to do the as UseQueriesOptionsArg<T> assertions because typescript apparently can't properly derive the return type of unref

It works totally fine in my IDE, no ts failures.

Maybe the failure come from the way Typescript works with Rollup: maybe it can't infer the type from the function and has to rely on the function type (which apparently is not enough)

image

@DamianOsipiuk DamianOsipiuk merged commit bceb408 into DamianOsipiuk:main Jan 11, 2022
@github-actions
Copy link

🎉 This PR is included in version 1.16.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@aantipov
Copy link
Contributor Author

@DamianOsipiuk thanks a lot for fast PR merges and new versions releases! 🙏 💪

@aantipov aantipov deleted the improve-use-queries-hook branch January 11, 2022 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants