-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Queries throw away data when skipped #2871
Comments
Yeah. It seems that before, the behavior was a bit unpredictable - sometimes going one way, sometimes another. And #2779 fixed it towards the tested behavior that didn't always apply. We should probably add a |
I would not expect to have Well.. maybe it should impact only |
@ivan-jelev Well, we had tests in place since the initial release of RTK Query that made sure that Honestly, I was unaware that it did return data in some circumstances. Still, now we are in a situation where we know that sometimes it returned data and sometimes it didn't - apparently based on some internal timing. The best way going forwards seems to ensure that the actual behavior always is the behavior we have always been testing for and that was also the intended behavior - and adding a new behavior for those that want the "sometimes accidental" behavior. |
Right.. it makes perfect sense for granular/atomic queries. However now there's more cases and with An option might be to make UPD: 2d option now looks better for me - |
I think that current behaviour is inconsistent between When it is necessary to get latest returned result regardless of trigger args and sometimes skip request, now it is necessary to use I personally find it more intuitive when |
@piotrlubecki You can't |
@phryneas Yes, there is no |
They behave exactly the same:
Those are the four cases both have common. There is one additional case: That additional case is not possible with PS: there is even an equivalent to 5. - you can call |
@phryneas I am thinking about this scenario:
I thought that above could be compared to this:
In this scenario, assuming that point 3 and 4 from your explanation were called at least once, I might been wrong to use |
Well, in your example, the I want to step back a bit and want to ask: why do you even want to use |
I am building online store, and simplifying the problem user is proving products, quantity and discount coupons. This values are used by backend to calculate price and return which products and coupons can be in cart (if quantity do not exceed quantity in stock and if coupons are applicable for this order). Response from server is sometimes modify original args (as quantity can be decreased or coupon can be incorrect). If backend response has modified any of the args, I used Since redux-toolkit 1.9.0 I rewritten the logic to BTW. @phryneas thank you for taking your time to discuss this issue and maintaining this great product, which I use at work and in hobby projects. |
As we see in documentation: https://redux-toolkit.js.org/rtk-query/usage/conditional-fetching |
That is a very good point - now we do have a problem 🤔 if this was actually documented, we might need to roll it back. |
@phryneas What about the rollback? |
@phryneas is there a problem if I use mutation instead of Query to call a GET end-point? with muation I dont have to deal with skip. |
@rubimbura : "queries" and "mutations" aren't about You can have a query that's a |
This has been a breaking change for my app, so wanted to add some notes in case its helpful in decision-making here. We were relying on a previously run query that then gets skipped to keep its We use a combination of
Before, this worked because we were still getting A note somewhere (release notes, docs) that behavior has changed would be super helpful for faster troubleshooting, I'd imagine. p.s. thank you for your hard work! |
@thesteady : for the record this is a "bug" and not an intended breaking change. We do need to fix this, but tbh it's kind of slipped off the radar due to the holidays, personal life, and other priorities. |
Cool thank you! I read through the comments and wasn't clear, my bad. |
Many thanks @markerikson. |
Could folks try out the CodeSandbox preview build in #3188 and let me know if that fixes the skipping issue? |
Nooooooooo! Absolutely preferred the new behaviour... :( Codebase is riddled with this type of usages: useAccountQuery(account ? { account: account.address } : skipToken); // Web3 use-case useSelectionDataQuery(selection ? { id: selection.id } : skipToken); // Form use-case |
@kasparkallas : then use |
Seems like the changes in #2779 broke some existing behavior:
The text was updated successfully, but these errors were encountered: