-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(react-query): make error to be shown when using queryOptions with initialData and skipToken in queryFn inside useSuspenseQueries #8665
Conversation
… initialData and skipToken in queryFn inside useSuspenseQueries
View your CI Pipeline Execution ↗ for commit 73ecec4.
☁️ Nx Cloud last updated this comment at |
it('queryOptions with initialData and skipToken in queryFn should not work on useSuspenseQueries', () => { | ||
const query1 = queryOptions({ | ||
queryKey: ['key1'], | ||
queryFn: skipToken, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be good to have a test that has a conditional skipToken:
queryFn: Math.random() > 0.5 ? skipToken : () => Promise.resolve(5)
because that’s a lot closer to a real world use-case
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #8665 +/- ##
===========================================
+ Coverage 46.28% 84.05% +37.76%
===========================================
Files 199 26 -173
Lines 7549 370 -7179
Branches 1729 108 -1621
===========================================
- Hits 3494 311 -3183
+ Misses 3675 50 -3625
+ Partials 380 9 -371
|
This PR introduced a TS change, and I'm not sure whether it was intended or not. Before this, you could do const { data } = useQuery({ queryKey: ['query-key'], initialData: 42 }) and |
That's very relevant, and we should also have type-tests for this |
I made an issue. Thank you for your report. |
closes #8664
Previously, the error was not shown when we used queryOptions with initialData and skipToken in queryFn inside useSuspenseQueries.
Now the error occurs.