@ethlete/query 6.0.0-next.20 → 6.0.0-next.21

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @ethlete/query
2
2
 
3
+ ## 6.0.0-next.21
4
+
5
+ ### Patch Changes
6
+
7
+ - [#3038](https://github.com/ethlete-io/ethdk/pull/3038) [`0be9397`](https://github.com/ethlete-io/ethdk/commit/0be939765c6074a518c5c05a7110513f1e3e8ef0) Thanks [@TomTomB](https://github.com/TomTomB)! - Fix `ET301` on every legacy interop mutation. `LegacyQuery.execute()` translates v2's single `skipCache` into
8
+ `allowCache: options.skipCache !== true` for **every** method, so any `legacyPost*` / `legacyPut*` /
9
+ `legacyPatch*` / `legacyDelete*` executed without an explicit `skipCache: true` reached the repository with
10
+ `allowCache: true` and threw "This request is uncacheable, but allowCache is set to true".
11
+
12
+ `allowCache` is never read on the uncacheable path — there is no cache entry to reuse — so the throw was purely a
13
+ guard against a mistake in hand-written code. It stays for that, and gains a
14
+ `silenceUncacheableAllowCacheError` opt-out on `QueryConfig`, which `createLegacyQueryCreator` sets alongside the
15
+ `silenceMissingWithArgsFeatureError` it already passed. The cache-key guard is unaffected.
16
+
17
+ Note that dropping `allowCache: true` in the interop instead would have silently made every legacy `GET` refetch,
18
+ since an absent `allowCache` means "do not reuse the entry" rather than "use the default".
19
+
3
20
  ## 6.0.0-next.20
4
21
 
5
22
  ### Minor Changes
@@ -1014,6 +1014,7 @@ const queryExecute = (options) => {
1014
1014
  previousKey: executeState.previousKey(),
1015
1015
  runQueryOptions,
1016
1016
  isSecure,
1017
+ silenceUncacheableAllowCacheError: queryConfig.silenceUncacheableAllowCacheError,
1017
1018
  });
1018
1019
  executeState.previousKey.set(key);
1019
1020
  state.lastTimeExecutedAt.set(Date.now());
@@ -3401,7 +3402,11 @@ class LegacyQuery {
3401
3402
  this.newQuery.subtle.destroy();
3402
3403
  }
3403
3404
  execute(options = {}) {
3404
- untracked(() => this.newQuery.execute({ args: this._arguments, options: { allowCache: options.skipCache !== true } }));
3405
+ untracked(() =>
3406
+ // v2 had a single `skipCache` for every method, so this cannot tell whether the underlying request is
3407
+ // cacheable. The creator is built with `silenceUncacheableAllowCacheError`, which makes `allowCache` inert
3408
+ // on a mutation instead of throwing ET301.
3409
+ this.newQuery.execute({ args: this._arguments, options: { allowCache: options.skipCache !== true } }));
3405
3410
  return this;
3406
3411
  }
3407
3412
  abort() {
@@ -3612,6 +3617,8 @@ class LegacyQueryCreator {
3612
3617
  onlyManualExecution: true,
3613
3618
  injector,
3614
3619
  silenceMissingWithArgsFeatureError: true,
3620
+ // `LegacyQuery.execute()` forwards v2's `skipCache` as `allowCache` for every method, cacheable or not.
3621
+ silenceUncacheableAllowCacheError: true,
3615
3622
  });
3616
3623
  const legacyQuery = new LegacyQuery(newQuery, queryArgs, this.options.entity);
3617
3624
  if (args?.config?.destroyOnResponse) {
@@ -5723,8 +5730,11 @@ const createQueryRepository = (config) => {
5723
5730
  : shouldCacheQuery(options.method) || creatorOptions?.subtle?.useQueryRepositoryCache === true;
5724
5731
  if (!shouldCache && options.key)
5725
5732
  throw uncacheableRequestHasCacheKeyParam(options.key);
5726
- if (!shouldCache && runQueryOptions?.allowCache)
5733
+ // `allowCache` is never read on the uncacheable path below — there is no cache entry to reuse — so this throw
5734
+ // is purely a guard against a mistake in hand-written code. The legacy interop opts out of it.
5735
+ if (!shouldCache && runQueryOptions?.allowCache && !options.silenceUncacheableAllowCacheError) {
5727
5736
  throw uncacheableRequestHasAllowCacheParam();
5737
+ }
5728
5738
  const route = buildRoute({
5729
5739
  base: config.baseUrl,
5730
5740
  route: options.route,