logaretm / villus

🏎 A tiny and fast GraphQL client for Vue.js
https://villus.dev
MIT License
790 stars 31 forks source link

fix: make skip work when execute overrides variables #213

Open mzgajner opened 2 months ago

mzgajner commented 2 months ago

I noticed the following issue - when skip callback uses variables being passed in, only the default variables that were passed in when useQuery was called are checked.

const { data, execute } = useQuery({
  query: MyQueryDocument,
  fetchOnMount: false,
  variables: () => { id: 'invalid-id' }
  skip: ({ id }) => id === 'invalid-id' 
})

If I try to override variables when using execute...

execute({
  variables: { 
    id: "completely-valid-id" 
  }
})`

...the query is still skipped even though the variables passed to execute are OK.

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 47.32%. Comparing base (f2b6c7b) to head (19ca662).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #213 +/- ## ======================================= Coverage 47.32% 47.32% ======================================= Files 49 49 Lines 3250 3250 Branches 308 307 -1 ======================================= Hits 1538 1538 Misses 1712 1712 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.