@graphql-mesh/string-interpolation 0.2.0 → 0.3.0-alpha-4b3f4b8da.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.
- package/CHANGELOG.md +6 -0
- package/dist/index.js +12 -9
- package/dist/index.mjs +12 -9
- package/dist/package.json +2 -2
- package/dist/resolver-data-factory.d.ts +2 -2
- package/package.json +2 -2
- package/src/resolver-data-factory.ts +14 -9
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -189,18 +189,21 @@ function getInterpolationKeys(...interpolationStrings) {
|
|
|
189
189
|
function parseInterpolationStrings(interpolationStrings, argTypeMap) {
|
|
190
190
|
const interpolationKeys = getInterpolationKeys(...interpolationStrings);
|
|
191
191
|
const args = {};
|
|
192
|
-
const contextVariables =
|
|
192
|
+
const contextVariables = {};
|
|
193
193
|
for (const interpolationKey of interpolationKeys) {
|
|
194
194
|
const interpolationKeyParts = interpolationKey.split('.');
|
|
195
195
|
const varName = interpolationKeyParts[interpolationKeyParts.length - 1];
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
196
|
+
const initialObject = interpolationKeyParts[0];
|
|
197
|
+
const argType = argTypeMap && varName in argTypeMap ? argTypeMap[varName] : interpolationKeyParts.length > 2 ? 'JSON' : 'ID';
|
|
198
|
+
switch (initialObject) {
|
|
199
|
+
case 'args':
|
|
200
|
+
args[varName] = {
|
|
201
|
+
type: argType,
|
|
202
|
+
};
|
|
203
|
+
break;
|
|
204
|
+
case 'context':
|
|
205
|
+
contextVariables[varName] = `Scalars['${argType}']`;
|
|
206
|
+
break;
|
|
204
207
|
}
|
|
205
208
|
}
|
|
206
209
|
return {
|
package/dist/index.mjs
CHANGED
|
@@ -183,18 +183,21 @@ function getInterpolationKeys(...interpolationStrings) {
|
|
|
183
183
|
function parseInterpolationStrings(interpolationStrings, argTypeMap) {
|
|
184
184
|
const interpolationKeys = getInterpolationKeys(...interpolationStrings);
|
|
185
185
|
const args = {};
|
|
186
|
-
const contextVariables =
|
|
186
|
+
const contextVariables = {};
|
|
187
187
|
for (const interpolationKey of interpolationKeys) {
|
|
188
188
|
const interpolationKeyParts = interpolationKey.split('.');
|
|
189
189
|
const varName = interpolationKeyParts[interpolationKeyParts.length - 1];
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
190
|
+
const initialObject = interpolationKeyParts[0];
|
|
191
|
+
const argType = argTypeMap && varName in argTypeMap ? argTypeMap[varName] : interpolationKeyParts.length > 2 ? 'JSON' : 'ID';
|
|
192
|
+
switch (initialObject) {
|
|
193
|
+
case 'args':
|
|
194
|
+
args[varName] = {
|
|
195
|
+
type: argType,
|
|
196
|
+
};
|
|
197
|
+
break;
|
|
198
|
+
case 'context':
|
|
199
|
+
contextVariables[varName] = `Scalars['${argType}']`;
|
|
200
|
+
break;
|
|
198
201
|
}
|
|
199
202
|
}
|
|
200
203
|
return {
|
package/dist/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/string-interpolation",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-alpha-4b3f4b8da.0",
|
|
4
4
|
"description": "Dynamic string manipulation",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"graphql": "*"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"dayjs": "1.11.
|
|
10
|
+
"dayjs": "1.11.3",
|
|
11
11
|
"json-pointer": "0.6.2",
|
|
12
12
|
"lodash.get": "4.4.2"
|
|
13
13
|
},
|
|
@@ -9,11 +9,11 @@ export declare type ResolverData<TParent = any, TArgs = any, TContext = any, TRe
|
|
|
9
9
|
};
|
|
10
10
|
export declare type ResolverDataBasedFactory<T> = (data: ResolverData) => T;
|
|
11
11
|
export declare function getInterpolationKeys(...interpolationStrings: string[]): any[];
|
|
12
|
-
export declare function parseInterpolationStrings(interpolationStrings: string
|
|
12
|
+
export declare function parseInterpolationStrings(interpolationStrings: Iterable<string>, argTypeMap?: Record<string, string | GraphQLInputType>): {
|
|
13
13
|
args: Record<string, {
|
|
14
14
|
type: string | GraphQLInputType;
|
|
15
15
|
}>;
|
|
16
|
-
contextVariables: string
|
|
16
|
+
contextVariables: Record<string, string>;
|
|
17
17
|
};
|
|
18
18
|
export declare function getInterpolatedStringFactory(nonInterpolatedString: string): ResolverDataBasedFactory<string>;
|
|
19
19
|
export declare function getInterpolatedHeadersFactory(nonInterpolatedHeaders?: Record<string, string>): ResolverDataBasedFactory<Record<string, string>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/string-interpolation",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-alpha-4b3f4b8da.0",
|
|
4
4
|
"description": "Dynamic string manipulation",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"json-pointer": "0.6.2",
|
|
27
|
-
"dayjs": "1.11.
|
|
27
|
+
"dayjs": "1.11.3",
|
|
28
28
|
"lodash.get": "4.4.2"
|
|
29
29
|
},
|
|
30
30
|
"author": "Arda TANRIKULU <ardatanrikulu@gmail.com>",
|
|
@@ -19,24 +19,29 @@ export function getInterpolationKeys(...interpolationStrings: string[]) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export function parseInterpolationStrings(
|
|
22
|
-
interpolationStrings: string
|
|
22
|
+
interpolationStrings: Iterable<string>,
|
|
23
23
|
argTypeMap?: Record<string, string | GraphQLInputType>
|
|
24
24
|
) {
|
|
25
25
|
const interpolationKeys = getInterpolationKeys(...interpolationStrings);
|
|
26
26
|
|
|
27
27
|
const args: Record<string, { type: string | GraphQLInputType }> = {};
|
|
28
|
-
const contextVariables: string
|
|
28
|
+
const contextVariables: Record<string, string> = {};
|
|
29
29
|
|
|
30
30
|
for (const interpolationKey of interpolationKeys) {
|
|
31
31
|
const interpolationKeyParts = interpolationKey.split('.');
|
|
32
32
|
const varName = interpolationKeyParts[interpolationKeyParts.length - 1];
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
const initialObject = interpolationKeyParts[0];
|
|
34
|
+
const argType =
|
|
35
|
+
argTypeMap && varName in argTypeMap ? argTypeMap[varName] : interpolationKeyParts.length > 2 ? 'JSON' : 'ID';
|
|
36
|
+
switch (initialObject) {
|
|
37
|
+
case 'args':
|
|
38
|
+
args[varName] = {
|
|
39
|
+
type: argType,
|
|
40
|
+
};
|
|
41
|
+
break;
|
|
42
|
+
case 'context':
|
|
43
|
+
contextVariables[varName] = `Scalars['${argType}']`;
|
|
44
|
+
break;
|
|
40
45
|
}
|
|
41
46
|
}
|
|
42
47
|
|