@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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @graphql-mesh/string-interpolation
2
2
 
3
+ ## 0.3.0-alpha-4b3f4b8da.0
4
+
5
+ ### Minor Changes
6
+
7
+ - a8f4b0209: Add interpolation strings to the generated MeshContext type
8
+
3
9
  ## 0.2.0
4
10
 
5
11
  ### Minor Changes
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
- if (interpolationKeyParts[0] === 'args') {
197
- const argType = argTypeMap && varName in argTypeMap ? argTypeMap[varName] : 'ID';
198
- args[varName] = {
199
- type: argType,
200
- };
201
- }
202
- else if (interpolationKeyParts[0] === 'context') {
203
- contextVariables.push(varName);
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
- if (interpolationKeyParts[0] === 'args') {
191
- const argType = argTypeMap && varName in argTypeMap ? argTypeMap[varName] : 'ID';
192
- args[varName] = {
193
- type: argType,
194
- };
195
- }
196
- else if (interpolationKeyParts[0] === 'context') {
197
- contextVariables.push(varName);
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.2.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.2",
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[], argTypeMap?: Record<string, string | GraphQLInputType>): {
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.2.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.2",
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
- if (interpolationKeyParts[0] === 'args') {
34
- const argType = argTypeMap && varName in argTypeMap ? argTypeMap[varName] : 'ID';
35
- args[varName] = {
36
- type: argType,
37
- };
38
- } else if (interpolationKeyParts[0] === 'context') {
39
- contextVariables.push(varName);
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