Skip to content

Commit

Permalink
feat(data): Add HttpOptions to EntityActionOptions to allow finer con…
Browse files Browse the repository at this point in the history
…trol over HttpClient requests (ngrx#3663)

 - fixed warnig message and made it coniitional
  • Loading branch information
Cameron Maunder committed Feb 1, 2023
1 parent 2aa9a48 commit a6aa56f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions modules/data/src/dataservices/default-data.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, Optional } from '@angular/core';
import { Injectable, isDevMode, Optional } from '@angular/core';
import {
HttpClient,
HttpErrorResponse,
Expand Down Expand Up @@ -111,9 +111,7 @@ export class DefaultDataService<T> implements EntityCollectionDataService<T> {
? { fromString: queryParams }
: { fromObject: queryParams };
const params = new HttpParams(qParams);
console.warn(
'Warning: options.httpParams will be merged with queryParams when both are are provided to getWithQuery(). In the event of a conflict HttpOptions.httpParams will override queryParams`. The queryParams parameter of getWithQuery() will be removed in next major release.'
);

return this.execute(
'GET',
this.entitiesUrl,
Expand Down Expand Up @@ -163,6 +161,12 @@ export class DefaultDataService<T> implements EntityCollectionDataService<T> {
// from the deprecated options parameter
let mergedOptions: any = undefined;
if (options || ngHttpClientOptions) {
if (isDevMode() && options && ngHttpClientOptions) {
console.warn(
'@ngrx/data: options.httpParams will be merged with queryParams when both are are provided to getWithQuery(). In the event of a conflict HttpOptions.httpParams will override queryParams`. The queryParams parameter of getWithQuery() will be removed in next major release.'
);
}

mergedOptions = {};
if (ngHttpClientOptions?.headers) {
mergedOptions.headers = ngHttpClientOptions?.headers;
Expand Down

0 comments on commit a6aa56f

Please sign in to comment.