@tanstack/vue-query 4.14.3 → 4.15.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.
@@ -802,14 +802,16 @@
802
802
  this.queryHash = config.queryHash;
803
803
  this.initialState = config.state || getDefaultState$1(this.options);
804
804
  this.state = this.initialState;
805
- this.meta = config.meta;
805
+ }
806
+
807
+ get meta() {
808
+ return this.options.meta;
806
809
  }
807
810
 
808
811
  setOptions(options) {
809
812
  this.options = { ...this.defaultOptions,
810
813
  ...options
811
814
  };
812
- this.meta = options == null ? void 0 : options.meta;
813
815
  this.updateCacheTime(this.options.cacheTime);
814
816
  }
815
817
 
@@ -1039,8 +1041,7 @@
1039
1041
  options: this.options,
1040
1042
  queryKey: this.queryKey,
1041
1043
  state: this.state,
1042
- fetchFn,
1043
- meta: this.meta
1044
+ fetchFn
1044
1045
  };
1045
1046
  addSignalProperty(context);
1046
1047
  (_this$options$behavio = this.options.behavior) == null ? void 0 : _this$options$behavio.onFetch(context); // Store state in case the current fetch needs to be reverted
@@ -1274,8 +1275,7 @@
1274
1275
  queryHash,
1275
1276
  options: client.defaultQueryOptions(options),
1276
1277
  state,
1277
- defaultOptions: client.getQueryDefaults(queryKey),
1278
- meta: options.meta
1278
+ defaultOptions: client.getQueryDefaults(queryKey)
1279
1279
  });
1280
1280
  this.add(query);
1281
1281
  }
@@ -1381,11 +1381,14 @@
1381
1381
  this.logger = config.logger || defaultLogger;
1382
1382
  this.observers = [];
1383
1383
  this.state = config.state || getDefaultState();
1384
- this.meta = config.meta;
1385
1384
  this.updateCacheTime(this.options.cacheTime);
1386
1385
  this.scheduleGc();
1387
1386
  }
1388
1387
 
1388
+ get meta() {
1389
+ return this.options.meta;
1390
+ }
1391
+
1389
1392
  setState(state) {
1390
1393
  this.dispatch({
1391
1394
  type: 'setState',
@@ -1630,8 +1633,7 @@
1630
1633
  mutationId: ++this.mutationId,
1631
1634
  options: client.defaultMutationOptions(options),
1632
1635
  state,
1633
- defaultOptions: options.mutationKey ? client.getMutationDefaults(options.mutationKey) : undefined,
1634
- meta: options.meta
1636
+ defaultOptions: options.mutationKey ? client.getMutationDefaults(options.mutationKey) : undefined
1635
1637
  });
1636
1638
  this.add(mutation);
1637
1639
  return mutation;
@@ -1750,7 +1752,7 @@
1750
1752
  const queryFnContext = {
1751
1753
  queryKey: context.queryKey,
1752
1754
  pageParam: param,
1753
- meta: context.meta
1755
+ meta: context.options.meta
1754
1756
  };
1755
1757
  addSignalProperty(queryFnContext);
1756
1758
  const queryFnResult = queryFn(queryFnContext);
@@ -2759,6 +2761,10 @@
2759
2761
  return this.observers.map(observer => observer.getCurrentQuery());
2760
2762
  }
2761
2763
 
2764
+ getObservers() {
2765
+ return this.observers;
2766
+ }
2767
+
2762
2768
  getOptimisticResult(queries) {
2763
2769
  return this.findMatchingObservers(queries).map(match => match.observer.getOptimisticResult(match.defaultedQueryOptions));
2764
2770
  }
@@ -2886,19 +2892,26 @@
2886
2892
  }
2887
2893
 
2888
2894
  createResult(query, options) {
2889
- var _state$data, _state$data2, _state$fetchMeta, _state$fetchMeta$fetc, _state$fetchMeta2, _state$fetchMeta2$fet;
2895
+ var _state$fetchMeta, _state$fetchMeta$fetc, _state$fetchMeta2, _state$fetchMeta2$fet, _state$data, _state$data2;
2890
2896
 
2891
2897
  const {
2892
2898
  state
2893
2899
  } = query;
2894
2900
  const result = super.createResult(query, options);
2901
+ const {
2902
+ isFetching,
2903
+ isRefetching
2904
+ } = result;
2905
+ const isFetchingNextPage = isFetching && ((_state$fetchMeta = state.fetchMeta) == null ? void 0 : (_state$fetchMeta$fetc = _state$fetchMeta.fetchMore) == null ? void 0 : _state$fetchMeta$fetc.direction) === 'forward';
2906
+ const isFetchingPreviousPage = isFetching && ((_state$fetchMeta2 = state.fetchMeta) == null ? void 0 : (_state$fetchMeta2$fet = _state$fetchMeta2.fetchMore) == null ? void 0 : _state$fetchMeta2$fet.direction) === 'backward';
2895
2907
  return { ...result,
2896
2908
  fetchNextPage: this.fetchNextPage,
2897
2909
  fetchPreviousPage: this.fetchPreviousPage,
2898
2910
  hasNextPage: hasNextPage(options, (_state$data = state.data) == null ? void 0 : _state$data.pages),
2899
2911
  hasPreviousPage: hasPreviousPage(options, (_state$data2 = state.data) == null ? void 0 : _state$data2.pages),
2900
- isFetchingNextPage: state.fetchStatus === 'fetching' && ((_state$fetchMeta = state.fetchMeta) == null ? void 0 : (_state$fetchMeta$fetc = _state$fetchMeta.fetchMore) == null ? void 0 : _state$fetchMeta$fetc.direction) === 'forward',
2901
- isFetchingPreviousPage: state.fetchStatus === 'fetching' && ((_state$fetchMeta2 = state.fetchMeta) == null ? void 0 : (_state$fetchMeta2$fet = _state$fetchMeta2.fetchMore) == null ? void 0 : _state$fetchMeta2$fet.direction) === 'backward'
2912
+ isFetchingNextPage,
2913
+ isFetchingPreviousPage,
2914
+ isRefetching: isRefetching && !isFetchingNextPage && !isFetchingPreviousPage
2902
2915
  };
2903
2916
  }
2904
2917