@ethlete/query 5.27.1 → 5.28.1

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,17 @@
1
1
  # @ethlete/query
2
2
 
3
+ ## 5.28.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`89cf913`](https://github.com/ethlete-io/ethdk/commit/89cf913eafd1ec1215ad857f92b22d6a5b95092b) Thanks [@TomTomB](https://github.com/TomTomB)! - Fix access of undefined error in query 3
8
+
9
+ ## 5.28.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`ef602b4`](https://github.com/ethlete-io/ethdk/commit/ef602b4265ab4d01c581772687172eb591abfa3e) Thanks [@TomTomB](https://github.com/TomTomB)! - Add `asReadonly` method to query object
14
+
3
15
  ## 5.27.1
4
16
 
5
17
  ### Patch Changes
@@ -3345,8 +3345,8 @@ const getQueryFeatureUsage = (options) => {
3345
3345
  ? shouldAutoExecuteGqlQuery(options.creatorInternals.method)
3346
3346
  : shouldAutoExecuteQuery(options.creatorInternals.method);
3347
3347
  const shouldAutoExecute = shouldAutoExecuteMethod && !queryConfig.onlyManualExecution;
3348
- const hasRouteFunction = typeof creatorInternals.route === 'function' ||
3349
- typeof creator.route === 'function';
3348
+ const hasRouteFunction = typeof creatorInternals?.route === 'function' ||
3349
+ typeof creator?.route === 'function';
3350
3350
  if (hasRouteFunction && !hasWithArgsFeature) {
3351
3351
  throw withArgsQueryFeatureMissingButRouteIsFunction();
3352
3352
  }
@@ -3383,6 +3383,19 @@ const createQueryObject = (options) => {
3383
3383
  const destroy = () => deps.injector.destroy();
3384
3384
  const setResponse = (response) => state.response.set(response);
3385
3385
  const createSnapshot = createQuerySnapshotFn({ state, deps, execute });
3386
+ const asReadonly = () => {
3387
+ const roQuery = {
3388
+ args: state.args.asReadonly(),
3389
+ response: state.response.asReadonly(),
3390
+ latestHttpEvent: state.latestHttpEvent.asReadonly(),
3391
+ loading: state.loading.asReadonly(),
3392
+ error: state.error.asReadonly(),
3393
+ lastTimeExecutedAt: state.lastTimeExecutedAt.asReadonly(),
3394
+ id: normalizeQueryRepositoryKey(execute.currentRepositoryKey),
3395
+ createSnapshot,
3396
+ };
3397
+ return roQuery;
3398
+ };
3386
3399
  const query = {
3387
3400
  execute,
3388
3401
  args: state.args.asReadonly(),
@@ -3394,6 +3407,7 @@ const createQueryObject = (options) => {
3394
3407
  id: normalizeQueryRepositoryKey(execute.currentRepositoryKey),
3395
3408
  createSnapshot,
3396
3409
  reset: execute.reset,
3410
+ asReadonly,
3397
3411
  subtle: {
3398
3412
  destroy,
3399
3413
  setResponse,