@ethlete/query 2.5.1 → 2.5.3

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.
@@ -601,7 +601,8 @@ const castQueryCreatorTypes = (config) => {
601
601
  const computeQueryMethod = (config) => {
602
602
  let method;
603
603
  if (isGqlQueryConfig(config.config)) {
604
- method = transformMethod({ method: config.config.method, transferVia: config.config.transferVia });
604
+ const transferVia = config.config.transferVia ?? config.client.config.request?.gql?.transferVia;
605
+ method = transformMethod({ method: config.config.method, transferVia });
605
606
  }
606
607
  else {
607
608
  method = transformMethod({ method: config.config.method });
@@ -615,7 +616,7 @@ const computeQueryBody = (config) => {
615
616
  config.method === 'OPTIONS' ||
616
617
  (isGqlQueryConfig(config.config) &&
617
618
  (config.config.transferVia === 'GET' ||
618
- (config.clientConfig.request?.gql?.transferVia === 'GET' && !config.config.transferVia)))) {
619
+ (config.client.config.request?.gql?.transferVia === 'GET' && !config.config.transferVia)))) {
619
620
  return undefined;
620
621
  }
621
622
  if (isGqlQueryConfig(config.config)) {
@@ -651,7 +652,7 @@ const computeQueryHeaders = (config) => {
651
652
  const computeQueryQueryParams = (config) => {
652
653
  if (isGqlQueryConfig(config.config) &&
653
654
  (config.config.transferVia === 'GET' ||
654
- (config.clientConfig.request?.gql?.transferVia === 'GET' && !config.config.transferVia))) {
655
+ (config.client.config.request?.gql?.transferVia === 'GET' && !config.config.transferVia))) {
655
656
  const queryTemplate = config.config.query;
656
657
  const query = transformGql(queryTemplate);
657
658
  let params = query(config.args?.variables);
@@ -742,10 +743,10 @@ class Query {
742
743
  meta,
743
744
  });
744
745
  this._updateUseResultInDependencies();
745
- const method = computeQueryMethod({ config: this._queryConfig });
746
+ const method = computeQueryMethod({ config: this._queryConfig, client: this._client });
746
747
  const body = computeQueryBody({
747
748
  config: this._queryConfig,
748
- clientConfig: this._client.config,
749
+ client: this._client,
749
750
  args: this._args,
750
751
  method,
751
752
  });
@@ -846,7 +847,12 @@ class Query {
846
847
  : interval(config.interval);
847
848
  this._pollingSubscription = _interval
848
849
  .pipe(takeUntil(config.takeUntil), finalize(() => this.stopPolling()))
849
- .subscribe(() => this.execute({ skipCache: true, _triggeredVia: 'poll' }));
850
+ .subscribe(() => {
851
+ if (this.state.type === "LOADING" /* QueryStateType.Loading */) {
852
+ return;
853
+ }
854
+ this.execute({ skipCache: true, _triggeredVia: 'poll' });
855
+ });
850
856
  return this;
851
857
  }
852
858
  stopPolling() {
@@ -1133,9 +1139,9 @@ class QueryDirective {
1133
1139
  }
1134
1140
  }
1135
1141
  }
1136
- QueryDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: QueryDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }, { token: i0.ErrorHandler }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
1137
- QueryDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.2", type: QueryDirective, isStandalone: true, selector: "[query]", inputs: { query: "query", cache: ["queryCache", "cache"] }, ngImport: i0 });
1138
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: QueryDirective, decorators: [{
1142
+ QueryDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.3", ngImport: i0, type: QueryDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }, { token: i0.ErrorHandler }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
1143
+ QueryDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.3", type: QueryDirective, isStandalone: true, selector: "[query]", inputs: { query: "query", cache: ["queryCache", "cache"] }, ngImport: i0 });
1144
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.3", ngImport: i0, type: QueryDirective, decorators: [{
1139
1145
  type: Directive,
1140
1146
  args: [{
1141
1147
  // eslint-disable-next-line @angular-eslint/directive-selector
@@ -1473,9 +1479,9 @@ class InfinityQueryDirective {
1473
1479
  this._data$.next([]);
1474
1480
  }
1475
1481
  }
1476
- InfinityQueryDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: InfinityQueryDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1477
- InfinityQueryDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.2", type: InfinityQueryDirective, isStandalone: true, selector: "[infinityQuery]", inputs: { infinityQuery: "infinityQuery" }, providers: [{ provide: INFINITY_QUERY_TOKEN, useExisting: InfinityQueryDirective }, DestroyService], exportAs: ["infinityQuery"], ngImport: i0 });
1478
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: InfinityQueryDirective, decorators: [{
1482
+ InfinityQueryDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.3", ngImport: i0, type: InfinityQueryDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1483
+ InfinityQueryDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.3", type: InfinityQueryDirective, isStandalone: true, selector: "[infinityQuery]", inputs: { infinityQuery: "infinityQuery" }, providers: [{ provide: INFINITY_QUERY_TOKEN, useExisting: InfinityQueryDirective }, DestroyService], exportAs: ["infinityQuery"], ngImport: i0 });
1484
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.3", ngImport: i0, type: InfinityQueryDirective, decorators: [{
1479
1485
  type: Directive,
1480
1486
  args: [{
1481
1487
  // eslint-disable-next-line @angular-eslint/directive-selector
@@ -1525,9 +1531,9 @@ class InfinityQueryTriggerDirective {
1525
1531
  this._observer.observe(this._elementRef.nativeElement);
1526
1532
  }
1527
1533
  }
1528
- InfinityQueryTriggerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: InfinityQueryTriggerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1529
- InfinityQueryTriggerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.2", type: InfinityQueryTriggerDirective, isStandalone: true, selector: "[infinityQueryTrigger], infinity-query-trigger", inputs: { scrollContainerSelector: "scrollContainerSelector" }, ngImport: i0 });
1530
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: InfinityQueryTriggerDirective, decorators: [{
1534
+ InfinityQueryTriggerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.3", ngImport: i0, type: InfinityQueryTriggerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1535
+ InfinityQueryTriggerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.3", type: InfinityQueryTriggerDirective, isStandalone: true, selector: "[infinityQueryTrigger], infinity-query-trigger", inputs: { scrollContainerSelector: "scrollContainerSelector" }, ngImport: i0 });
1536
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.3", ngImport: i0, type: InfinityQueryTriggerDirective, decorators: [{
1531
1537
  type: Directive,
1532
1538
  args: [{
1533
1539
  // eslint-disable-next-line @angular-eslint/directive-selector
@@ -1729,7 +1735,7 @@ class QueryClient {
1729
1735
  base: this._clientConfig.baseRoute,
1730
1736
  route: queryConfig.route,
1731
1737
  pathParams: args?.pathParams,
1732
- queryParams: computeQueryQueryParams({ config: queryConfig, clientConfig: this._clientConfig, args }),
1738
+ queryParams: computeQueryQueryParams({ config: queryConfig, client: this, args }),
1733
1739
  });
1734
1740
  const cacheKey = isGqlQueryConfig(queryConfig) ? buildGqlCacheKey(queryConfig, args) : route;
1735
1741
  if (shouldCacheQuery(queryConfig.method)) {
@@ -1791,11 +1797,11 @@ class QueryField {
1791
1797
  this.changes$ = this._setupChangesObservable();
1792
1798
  this._currentDebounceTimeout = null;
1793
1799
  }
1794
- setValue(value) {
1800
+ setValue(value, options) {
1795
1801
  if (this._currentDebounceTimeout !== null) {
1796
1802
  clearTimeout(this._currentDebounceTimeout);
1797
1803
  }
1798
- if (this.data.debounce) {
1804
+ if (this.data.debounce && !options?.skipDebounce) {
1799
1805
  this._currentDebounceTimeout = window.setTimeout(() => {
1800
1806
  this.control.setValue(value);
1801
1807
  }, this.data.debounce);
@@ -1830,7 +1836,7 @@ class QueryForm {
1830
1836
  }
1831
1837
  }));
1832
1838
  }
1833
- setFormValueFromUrlQueryParams() {
1839
+ setFormValueFromUrlQueryParams(options) {
1834
1840
  if (!this._activatedRoute) {
1835
1841
  throw new Error('Cannot set form value from url query params without ActivatedRoute');
1836
1842
  }
@@ -1842,7 +1848,7 @@ class QueryForm {
1842
1848
  continue;
1843
1849
  }
1844
1850
  const deserializedValue = field.data.queryParamToValueTransformFn?.(value) ?? value;
1845
- field.setValue(deserializedValue);
1851
+ field.setValue(deserializedValue, { skipDebounce: options?.skipDebounce ?? true });
1846
1852
  }
1847
1853
  }
1848
1854
  updateFormOnUrlQueryParamsChange() {