@ethlete/query 5.33.2 → 5.33.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.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @ethlete/query
|
|
2
2
|
|
|
3
|
+
## 5.33.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`c4f21f5`](https://github.com/ethlete-io/ethdk/commit/c4f21f5e69a6379d19989bc15ddfd86ca7eacdbd) Thanks [@TomTomB](https://github.com/TomTomB)! - Fix gql query param parsing
|
|
8
|
+
|
|
3
9
|
## 5.33.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -122,7 +122,10 @@ const buildQueryString = (params, config) => {
|
|
|
122
122
|
const ignoredValuesFns = config?.ignoredValuesFns ?? [isNaN$1, isEmptyString];
|
|
123
123
|
const queryParams = [];
|
|
124
124
|
function processValue(key, value) {
|
|
125
|
-
if (config?.
|
|
125
|
+
if (config?.objectNotation === 'json-stringify') {
|
|
126
|
+
if (value === undefined) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
126
129
|
if (ignoredValues.includes(value)) {
|
|
127
130
|
return false;
|
|
128
131
|
}
|
|
@@ -130,7 +133,8 @@ const buildQueryString = (params, config) => {
|
|
|
130
133
|
return false;
|
|
131
134
|
}
|
|
132
135
|
const encodedKey = encodeURIComponent(key);
|
|
133
|
-
const
|
|
136
|
+
const val = typeof value === 'object' ? JSON.stringify(value) : value;
|
|
137
|
+
const encodedValue = encodeURIComponent(val);
|
|
134
138
|
queryParams.push(`${encodedKey}=${encodedValue}`);
|
|
135
139
|
return true;
|
|
136
140
|
}
|
|
@@ -716,19 +720,12 @@ class QueryCreator {
|
|
|
716
720
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
717
721
|
// @ts-ignore
|
|
718
722
|
this.prepare = (args) => {
|
|
719
|
-
const shouldUseJsonStringifyForQs = isGqlQueryConfig(this._queryConfig) &&
|
|
720
|
-
(this._queryConfig.transferVia === 'GET' ||
|
|
721
|
-
(this._client.config.request?.gql?.transferVia === 'GET' && !this._queryConfig.transferVia));
|
|
722
|
-
const originalQueryParams = this._client.config.request?.queryParams;
|
|
723
|
-
const queryParamConfig = originalQueryParams
|
|
724
|
-
? { ...originalQueryParams, useJsonStringify: shouldUseJsonStringifyForQs }
|
|
725
|
-
: undefined;
|
|
726
723
|
const route = buildRoute({
|
|
727
724
|
base: this._client.config.baseRoute,
|
|
728
725
|
route: this._queryConfig.route,
|
|
729
726
|
pathParams: args?.pathParams,
|
|
730
727
|
queryParams: computeQueryQueryParams({ config: this._queryConfig, client: this._client, args }),
|
|
731
|
-
queryParamConfig,
|
|
728
|
+
queryParamConfig: this._client.config.request?.queryParams,
|
|
732
729
|
});
|
|
733
730
|
const cacheKey = (args?.config?.queryStoreCacheKey ?? '') + buildQueryCacheKey$1(route, args);
|
|
734
731
|
if (shouldCacheQuery$1(this._queryConfig.method) && !args?.config?.skipQueryStore) {
|
|
@@ -1007,17 +1004,19 @@ const getOpName = /(query|mutation) ?([\w\d-_]+)? ?\(.*?\)? \{/;
|
|
|
1007
1004
|
const transformGql = (str) => {
|
|
1008
1005
|
str = Array.isArray(str) ? str.join('') : str;
|
|
1009
1006
|
const name = getOpName.exec(str);
|
|
1010
|
-
return
|
|
1007
|
+
return (variables) => {
|
|
1011
1008
|
const data = { query: str };
|
|
1012
1009
|
if (variables)
|
|
1013
|
-
data['variables'] = variables;
|
|
1010
|
+
data['variables'] = JSON.stringify(variables);
|
|
1014
1011
|
if (name && name.length) {
|
|
1015
1012
|
const operationName = name[2];
|
|
1016
1013
|
if (operationName)
|
|
1017
1014
|
data['operationName'] = name[2];
|
|
1018
1015
|
}
|
|
1019
|
-
|
|
1020
|
-
|
|
1016
|
+
if (!isDevMode()) {
|
|
1017
|
+
// minify the query
|
|
1018
|
+
data.query = data.query.replace(/\s+/g, ' ').trim();
|
|
1019
|
+
}
|
|
1021
1020
|
return data;
|
|
1022
1021
|
};
|
|
1023
1022
|
};
|
|
@@ -4338,9 +4337,7 @@ const createQueryRepository = (config) => {
|
|
|
4338
4337
|
route: options.route,
|
|
4339
4338
|
pathParams: args?.pathParams,
|
|
4340
4339
|
queryParams: args?.queryParams,
|
|
4341
|
-
queryParamConfig:
|
|
4342
|
-
? { useJsonStringify: true }
|
|
4343
|
-
: config.queryString,
|
|
4340
|
+
queryParamConfig: config.queryString,
|
|
4344
4341
|
});
|
|
4345
4342
|
const key = shouldCache &&
|
|
4346
4343
|
buildQueryCacheKey(`${options.key ? options.key + '_' : ''}${route}`, {
|
|
@@ -4694,7 +4691,6 @@ const createGqlExecuteFn = (executeOptions) => {
|
|
|
4694
4691
|
options,
|
|
4695
4692
|
internalOptions: {
|
|
4696
4693
|
useQueryRepositoryCache: executeOptions.creatorInternals.method === 'QUERY',
|
|
4697
|
-
forceJsonStringifyInQueryParams: executeOptions.creatorInternals.method === 'QUERY',
|
|
4698
4694
|
},
|
|
4699
4695
|
transformResponse: (originalResponse) => {
|
|
4700
4696
|
if (originalResponse && 'data' in originalResponse) {
|