@ethlete/query 2.3.0 → 2.5.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.
@@ -85,16 +85,26 @@ export type RestQueryConfig<Route extends RouteType<Arguments>, Response, Argume
85
85
  */
86
86
  route: Route;
87
87
  };
88
+ export type GqlTransferOption = 'GET' | 'POST';
88
89
  export interface GqlQueryConfig<Route extends RouteType<Arguments> | undefined, Response, Arguments extends BaseArguments | undefined, ResponseTransformer extends ResponseTransformerType<Response> | undefined> extends QueryConfigBase<Response, Arguments, ResponseTransformer> {
89
90
  /**
90
91
  * The graphql query to use for the query.
91
92
  */
92
93
  query: string;
94
+ /**
95
+ * Determines if the query should be sent via GET or POST.
96
+ * - `GET`: The query will be sent via query parameters.
97
+ * - `POST`: The query will be sent via the body.
98
+ * @default 'POST'
99
+ */
100
+ transferVia?: GqlTransferOption;
93
101
  /**
94
102
  * Subroute to use for the query.
95
103
  */
96
104
  route?: Route;
97
105
  }
106
+ export type AnyRestQueryConfig = RestQueryConfig<any, any, any, any>;
107
+ export type AnyGqlQueryConfig = GqlQueryConfig<any, any, any, any>;
98
108
  export type QueryConfigWithoutMethod<Route extends RouteType<Arguments>, Response, Arguments extends BaseArguments | undefined, ResponseTransformer extends ResponseTransformerType<Response> | undefined> = Omit<RestQueryConfig<Route, Response, Arguments, ResponseTransformer>, 'method'>;
99
109
  export type GqlQueryConfigWithoutMethod<Route extends RouteType<Arguments>, Response, Arguments extends BaseArguments | undefined, ResponseTransformer extends ResponseTransformerType<Response> | undefined> = Omit<GqlQueryConfig<Route, Response, Arguments, ResponseTransformer>, 'method'>;
100
110
  export type BaseArguments = WithHeaders & WithVariables & WithBody & WithQueryParams & WithPathParams;
@@ -1,7 +1,7 @@
1
1
  import { BehaviorSubject, Observable } from 'rxjs';
2
- import { AnyQueryCreator, QueryCreator, QueryCreatorArgs, QueryCreatorMethod, QueryCreatorResponse, QueryCreatorResponseTransformer, ResponseTransformerType } from '../query-client';
2
+ import { AnyQueryCreator, QueryClient, QueryClientConfig, QueryCreator, QueryCreatorArgs, QueryCreatorMethod, QueryCreatorResponse, QueryCreatorResponseTransformer, ResponseTransformerType } from '../query-client';
3
3
  import { Method, RequestHeaders, RequestHeadersMethodMap } from '../request';
4
- import { AnyQuery, AnyQueryCreatorCollection, AnyQueryOfCreatorCollection, BaseArguments, Cancelled, Failure, GqlQueryConfig, Loading, Prepared, QueryRawResponseType, QueryResponseType, QueryState, QueryStateData, QueryStateRawData, QueryStateType, RouteType, Success } from './query.types';
4
+ import { AnyGqlQueryConfig, AnyQuery, AnyQueryCreatorCollection, AnyQueryOfCreatorCollection, AnyRestQueryConfig, BaseArguments, Cancelled, Failure, GqlQueryConfig, Loading, Prepared, QueryRawResponseType, QueryResponseType, QueryState, QueryStateData, QueryStateRawData, QueryStateType, RouteType, Success } from './query.types';
5
5
  type OmitNull<T> = T extends null ? never : T;
6
6
  export declare function filterSuccess(): <T extends QueryState<unknown, unknown> | null, Response_1 extends QueryStateData<OmitNull<T>>, RawResponse extends QueryStateRawData<OmitNull<T>>>(source: Observable<T>) => Observable<Success<Response_1, RawResponse>>;
7
7
  export declare function ignoreAutoRefresh(): <T extends QueryState<unknown, unknown> | null>(source: Observable<T>) => Observable<T>;
@@ -36,4 +36,27 @@ export declare const castQueryCreatorTypes: <QC extends AnyQueryCreator, Argumen
36
36
  args?: OverrideArguments | undefined;
37
37
  response?: OverrideResponse | undefined;
38
38
  }) => QueryCreator<OverrideArguments, Method_1, OverrideResponse, Route, ResponseTransformer>;
39
+ export declare const computeQueryMethod: (config: {
40
+ config: AnyRestQueryConfig | AnyGqlQueryConfig;
41
+ }) => "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS" | "TRACE" | "CONNECT" | "PURGE" | "LINK" | "UNLINK" | "CUSTOM";
42
+ export declare const computeQueryBody: (config: {
43
+ config: AnyRestQueryConfig | AnyGqlQueryConfig;
44
+ clientConfig: QueryClientConfig;
45
+ args?: BaseArguments | undefined;
46
+ method: Method;
47
+ }) => unknown;
48
+ export declare const computeQueryAuthHeader: (config: {
49
+ config: AnyRestQueryConfig | AnyGqlQueryConfig;
50
+ client: QueryClient;
51
+ }) => Record<string, string> | null;
52
+ export declare const computeQueryHeaders: (config: {
53
+ config: AnyRestQueryConfig | AnyGqlQueryConfig;
54
+ client: QueryClient;
55
+ args?: BaseArguments | undefined;
56
+ }) => RequestHeaders | undefined;
57
+ export declare const computeQueryQueryParams: (config: {
58
+ config: AnyRestQueryConfig | AnyGqlQueryConfig;
59
+ clientConfig: QueryClientConfig;
60
+ args?: BaseArguments | undefined;
61
+ }) => import("../request").QueryParams | undefined;
39
62
  export {};
@@ -1,6 +1,6 @@
1
1
  import { BehaviorSubject } from 'rxjs';
2
2
  import { Query } from '../query/query';
3
- import { BaseArguments, EmptyObject, RouteType, WithHeaders, WithUseResultIn } from '../query/query.types';
3
+ import { BaseArguments, EmptyObject, GqlTransferOption, RouteType, WithHeaders, WithUseResultIn } from '../query/query.types';
4
4
  import { CacheAdapterFn, Method as MethodType, RequestHeaders, RequestHeadersMethodMap, RequestRetryFn } from '../request';
5
5
  import { QueryClient } from './query-client';
6
6
  export interface QueryClientConfig {
@@ -54,6 +54,18 @@ export interface QueryClientConfig {
54
54
  * @default shouldRetryRequest()
55
55
  */
56
56
  retryFn?: RequestRetryFn;
57
+ /**
58
+ * Configuration options for all graphql queries.
59
+ */
60
+ gql?: {
61
+ /**
62
+ * Determines if the query should be sent via GET or POST.
63
+ * - `GET`: The query will be sent via query parameters.
64
+ * - `POST`: The query will be sent via the body.
65
+ * @default 'POST'
66
+ */
67
+ transferVia?: GqlTransferOption;
68
+ };
57
69
  };
58
70
  /**
59
71
  * Parent query client.
@@ -14,7 +14,10 @@ export declare const isParamValid: (primitive: UnfilteredParamPrimitive) => bool
14
14
  export declare const extractExpiresInSeconds: (headers: RequestHeaders) => number | null;
15
15
  export declare const buildTimestampFromSeconds: (seconds: number | null) => number | null;
16
16
  export declare const serializeBody: (body: unknown) => ArrayBuffer | Blob | FormData | string | null;
17
- export declare const transformMethod: (method: Method) => "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS" | "TRACE" | "CONNECT" | "PURGE" | "LINK" | "UNLINK" | "CUSTOM";
17
+ export declare const transformMethod: (config: {
18
+ method: Method;
19
+ transferVia?: 'GET' | 'POST';
20
+ }) => "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS" | "TRACE" | "CONNECT" | "PURGE" | "LINK" | "UNLINK" | "CUSTOM";
18
21
  export declare const detectContentTypeHeader: (body: unknown) => string | null;
19
22
  export declare const hasHeader: (headers: RequestHeaders, header: string) => boolean;
20
23
  export declare const forEachHeader: (headers: RequestHeaders, callback: (value: string, key: string) => void) => void;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@ethlete/query",
3
- "version": "2.3.0",
3
+ "version": "2.5.0",
4
4
  "dependencies": {
5
5
  "tslib": "^2.5.0"
6
6
  },
7
7
  "peerDependencies": {
8
8
  "@angular/common": "^15.2.1",
9
9
  "@angular/core": "^15.2.1",
10
- "@ethlete/core": "1.4.3"
10
+ "@ethlete/core": "1.5.1"
11
11
  },
12
12
  "module": "fesm2015/ethlete-query.mjs",
13
13
  "es2020": "fesm2020/ethlete-query.mjs",