@tanstack/query-core 5.35.5 → 5.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/build/legacy/hydration.d.cts +1 -1
  2. package/build/legacy/hydration.d.ts +1 -1
  3. package/build/legacy/index.d.cts +1 -1
  4. package/build/legacy/index.d.ts +1 -1
  5. package/build/legacy/infiniteQueryBehavior.d.cts +1 -1
  6. package/build/legacy/infiniteQueryBehavior.d.ts +1 -1
  7. package/build/legacy/infiniteQueryObserver.cjs +14 -7
  8. package/build/legacy/infiniteQueryObserver.cjs.map +1 -1
  9. package/build/legacy/infiniteQueryObserver.d.cts +1 -1
  10. package/build/legacy/infiniteQueryObserver.d.ts +1 -1
  11. package/build/legacy/infiniteQueryObserver.js +14 -7
  12. package/build/legacy/infiniteQueryObserver.js.map +1 -1
  13. package/build/legacy/mutation.d.cts +1 -1
  14. package/build/legacy/mutation.d.ts +1 -1
  15. package/build/legacy/mutationCache.d.cts +1 -1
  16. package/build/legacy/mutationCache.d.ts +1 -1
  17. package/build/legacy/mutationObserver.d.cts +1 -1
  18. package/build/legacy/mutationObserver.d.ts +1 -1
  19. package/build/legacy/queriesObserver.d.cts +1 -1
  20. package/build/legacy/queriesObserver.d.ts +1 -1
  21. package/build/legacy/query.d.cts +1 -1
  22. package/build/legacy/query.d.ts +1 -1
  23. package/build/legacy/queryCache.d.cts +1 -1
  24. package/build/legacy/queryCache.d.ts +1 -1
  25. package/build/legacy/queryClient.d.cts +1 -1
  26. package/build/legacy/queryClient.d.ts +1 -1
  27. package/build/legacy/queryObserver.d.cts +1 -1
  28. package/build/legacy/queryObserver.d.ts +1 -1
  29. package/build/legacy/retryer.d.cts +1 -1
  30. package/build/legacy/retryer.d.ts +1 -1
  31. package/build/legacy/{types-Br-AgPmc.d.ts → types-B0i0SaOM.d.ts} +59 -0
  32. package/build/legacy/{types-Ya7vXgfL.d.cts → types-D3f-7LPM.d.cts} +59 -0
  33. package/build/legacy/types.cjs.map +1 -1
  34. package/build/legacy/types.d.cts +1 -1
  35. package/build/legacy/types.d.ts +1 -1
  36. package/build/legacy/utils.d.cts +1 -1
  37. package/build/legacy/utils.d.ts +1 -1
  38. package/build/modern/hydration.d.cts +1 -1
  39. package/build/modern/hydration.d.ts +1 -1
  40. package/build/modern/index.d.cts +1 -1
  41. package/build/modern/index.d.ts +1 -1
  42. package/build/modern/infiniteQueryBehavior.d.cts +1 -1
  43. package/build/modern/infiniteQueryBehavior.d.ts +1 -1
  44. package/build/modern/infiniteQueryObserver.cjs +13 -6
  45. package/build/modern/infiniteQueryObserver.cjs.map +1 -1
  46. package/build/modern/infiniteQueryObserver.d.cts +1 -1
  47. package/build/modern/infiniteQueryObserver.d.ts +1 -1
  48. package/build/modern/infiniteQueryObserver.js +13 -6
  49. package/build/modern/infiniteQueryObserver.js.map +1 -1
  50. package/build/modern/mutation.d.cts +1 -1
  51. package/build/modern/mutation.d.ts +1 -1
  52. package/build/modern/mutationCache.d.cts +1 -1
  53. package/build/modern/mutationCache.d.ts +1 -1
  54. package/build/modern/mutationObserver.d.cts +1 -1
  55. package/build/modern/mutationObserver.d.ts +1 -1
  56. package/build/modern/queriesObserver.d.cts +1 -1
  57. package/build/modern/queriesObserver.d.ts +1 -1
  58. package/build/modern/query.d.cts +1 -1
  59. package/build/modern/query.d.ts +1 -1
  60. package/build/modern/queryCache.d.cts +1 -1
  61. package/build/modern/queryCache.d.ts +1 -1
  62. package/build/modern/queryClient.d.cts +1 -1
  63. package/build/modern/queryClient.d.ts +1 -1
  64. package/build/modern/queryObserver.d.cts +1 -1
  65. package/build/modern/queryObserver.d.ts +1 -1
  66. package/build/modern/retryer.d.cts +1 -1
  67. package/build/modern/retryer.d.ts +1 -1
  68. package/build/modern/{types-Br-AgPmc.d.ts → types-B0i0SaOM.d.ts} +59 -0
  69. package/build/modern/{types-Ya7vXgfL.d.cts → types-D3f-7LPM.d.cts} +59 -0
  70. package/build/modern/types.cjs.map +1 -1
  71. package/build/modern/types.d.cts +1 -1
  72. package/build/modern/types.d.ts +1 -1
  73. package/build/modern/utils.d.cts +1 -1
  74. package/build/modern/utils.d.ts +1 -1
  75. package/package.json +1 -1
  76. package/src/__tests__/infiniteQueryObserver.test-d.tsx +2 -0
  77. package/src/infiniteQueryObserver.ts +16 -8
  78. package/src/types.ts +59 -0
package/src/types.ts CHANGED
@@ -473,6 +473,13 @@ export interface ResultOptions {
473
473
  }
474
474
 
475
475
  export interface RefetchOptions extends ResultOptions {
476
+ /**
477
+ * If set to `true`, a currently running request will be cancelled before a new request is made
478
+ *
479
+ * If set to `false`, no refetch will be made if there is already a request running.
480
+ *
481
+ * Defaults to `true`.
482
+ */
476
483
  cancelRefetch?: boolean
477
484
  }
478
485
 
@@ -486,10 +493,26 @@ export interface InvalidateOptions extends RefetchOptions {}
486
493
  export interface ResetOptions extends RefetchOptions {}
487
494
 
488
495
  export interface FetchNextPageOptions extends ResultOptions {
496
+ /**
497
+ * If set to `true`, calling `fetchNextPage` repeatedly will invoke `queryFn` every time,
498
+ * whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored.
499
+ *
500
+ * If set to `false`, calling `fetchNextPage` repeatedly won't have any effect until the first invocation has resolved.
501
+ *
502
+ * Defaults to `true`.
503
+ */
489
504
  cancelRefetch?: boolean
490
505
  }
491
506
 
492
507
  export interface FetchPreviousPageOptions extends ResultOptions {
508
+ /**
509
+ * If set to `true`, calling `fetchPreviousPage` repeatedly will invoke `queryFn` every time,
510
+ * whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored.
511
+ *
512
+ * If set to `false`, calling `fetchPreviousPage` repeatedly won't have any effect until the first invocation has resolved.
513
+ *
514
+ * Defaults to `true`.
515
+ */
493
516
  cancelRefetch?: boolean
494
517
  }
495
518
 
@@ -712,15 +735,41 @@ export interface InfiniteQueryObserverBaseResult<
712
735
  TData = unknown,
713
736
  TError = DefaultError,
714
737
  > extends QueryObserverBaseResult<TData, TError> {
738
+ /**
739
+ * This function allows you to fetch the next "page" of results.
740
+ */
715
741
  fetchNextPage: (
716
742
  options?: FetchNextPageOptions,
717
743
  ) => Promise<InfiniteQueryObserverResult<TData, TError>>
744
+ /**
745
+ * This function allows you to fetch the previous "page" of results.
746
+ */
718
747
  fetchPreviousPage: (
719
748
  options?: FetchPreviousPageOptions,
720
749
  ) => Promise<InfiniteQueryObserverResult<TData, TError>>
750
+ /**
751
+ * Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option).
752
+ */
721
753
  hasNextPage: boolean
754
+ /**
755
+ * Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option).
756
+ */
722
757
  hasPreviousPage: boolean
758
+ /**
759
+ * Will be `true` if the query failed while fetching the next page.
760
+ */
761
+ isFetchNextPageError: boolean
762
+ /**
763
+ * Will be `true` while fetching the next page with `fetchNextPage`.
764
+ */
723
765
  isFetchingNextPage: boolean
766
+ /**
767
+ * Will be `true` if the query failed while fetching the previous page.
768
+ */
769
+ isFetchPreviousPageError: boolean
770
+ /**
771
+ * Will be `true` while fetching the previous page with `fetchPreviousPage`.
772
+ */
724
773
  isFetchingPreviousPage: boolean
725
774
  }
726
775
 
@@ -734,6 +783,8 @@ export interface InfiniteQueryObserverPendingResult<
734
783
  isPending: true
735
784
  isLoadingError: false
736
785
  isRefetchError: false
786
+ isFetchNextPageError: false
787
+ isFetchPreviousPageError: false
737
788
  isSuccess: false
738
789
  status: 'pending'
739
790
  }
@@ -749,6 +800,8 @@ export interface InfiniteQueryObserverLoadingResult<
749
800
  isLoading: true
750
801
  isLoadingError: false
751
802
  isRefetchError: false
803
+ isFetchNextPageError: false
804
+ isFetchPreviousPageError: false
752
805
  isSuccess: false
753
806
  status: 'pending'
754
807
  }
@@ -764,6 +817,8 @@ export interface InfiniteQueryObserverLoadingErrorResult<
764
817
  isLoading: false
765
818
  isLoadingError: true
766
819
  isRefetchError: false
820
+ isFetchNextPageError: false
821
+ isFetchPreviousPageError: false
767
822
  isSuccess: false
768
823
  status: 'error'
769
824
  }
@@ -779,6 +834,8 @@ export interface InfiniteQueryObserverRefetchErrorResult<
779
834
  isLoading: false
780
835
  isLoadingError: false
781
836
  isRefetchError: true
837
+ isFetchNextPageError: false
838
+ isFetchPreviousPageError: false
782
839
  isSuccess: false
783
840
  status: 'error'
784
841
  }
@@ -794,6 +851,8 @@ export interface InfiniteQueryObserverSuccessResult<
794
851
  isLoading: false
795
852
  isLoadingError: false
796
853
  isRefetchError: false
854
+ isFetchNextPageError: false
855
+ isFetchPreviousPageError: false
797
856
  isSuccess: true
798
857
  status: 'success'
799
858
  }