Skip to content
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

V4: streamline cancel refetch #2937

Merged
merged 9 commits into from Nov 13, 2021
Merged

Commits on Nov 13, 2021

  1. feat: streamline cancelRefetch

    the following functions now default to true for cancelRefetch:
    
    - refetchQueries (+invalidateQueries, + resetQueries)
    - query.refetch
    - fetchNextPage (unchanged)
    - fetchPreviousPage (unchanged)
    TkDodo committed Nov 13, 2021
    Configuration menu
    Copy the full SHA
    d43557c View commit details
    Browse the repository at this point in the history
  2. feat: streamline cancelRefetch

    make sure that refetchOnReconnect and refetchOnWindowFocus do not cancel already running requests
    TkDodo committed Nov 13, 2021
    Configuration menu
    Copy the full SHA
    41c9b36 View commit details
    Browse the repository at this point in the history
  3. feat: streamline cancelRefetch

    update tests
    
    refetch and invalidate now both cancel previous queries, which is intended, so we get more calls to the queryFn in these cases
    TkDodo committed Nov 13, 2021
    Configuration menu
    Copy the full SHA
    c19eb3f View commit details
    Browse the repository at this point in the history
  4. feat: streamline cancelRefetch

    add more tests for cancelRefetch behavior
    TkDodo committed Nov 13, 2021
    Configuration menu
    Copy the full SHA
    ce67c20 View commit details
    Browse the repository at this point in the history
  5. feat: streamline cancelRefetch

    update docs and migration guide
    TkDodo committed Nov 13, 2021
    Configuration menu
    Copy the full SHA
    c248e49 View commit details
    Browse the repository at this point in the history
  6. feat: streamline cancelRefetch

    simplify conditions by moving the ?? true default down to fetch on observer level; all 3 callers (fetchNextPage, fetchPreviousPage and refetch) just pass their options down and adhere to this default; refetch also only has 3 callers:
    - refetch from useQuery, where we want the default
    - onOnline and onFocus, where we now explicitly pass false to keep the previous behavior
    
    and add more tests
    TkDodo committed Nov 13, 2021
    Configuration menu
    Copy the full SHA
    8ec3cc3 View commit details
    Browse the repository at this point in the history
  7. feat: streamline cancelRefetch

    we always call this.fetch() with options, so we can just as well make the mandatory
    
    also, streamline signatures by destructing values that can't be forwarded (and use empty object as default value) in options and just spread the rest
    TkDodo committed Nov 13, 2021
    Configuration menu
    Copy the full SHA
    e7013f3 View commit details
    Browse the repository at this point in the history
  8. feat: streamline cancelRefetch

    fix types for refetch
    
    it was accidentally made too wide and allowed all refetchFilters, like `predicate`; but with `refetch` on an obserserver, there is nothing to filter for, except the page, so that is what we need to accept via `RefetchPageFilters`
    TkDodo committed Nov 13, 2021
    Configuration menu
    Copy the full SHA
    8af0081 View commit details
    Browse the repository at this point in the history
  9. feat: streamline cancelRefetch

    refetch never took a queryKey as param - it is always bound to the observer
    TkDodo committed Nov 13, 2021
    Configuration menu
    Copy the full SHA
    9048c89 View commit details
    Browse the repository at this point in the history