@graphql-mesh/string-interpolation
Advanced tools
Comparing version 0.2.0 to 0.3.0-alpha-4b3f4b8da.0
# @graphql-mesh/string-interpolation | ||
## 0.3.0-alpha-4b3f4b8da.0 | ||
### Minor Changes | ||
- a8f4b0209: Add interpolation strings to the generated MeshContext type | ||
## 0.2.0 | ||
@@ -4,0 +10,0 @@ |
@@ -192,15 +192,18 @@ 'use strict'; | ||
const args = {}; | ||
const contextVariables = []; | ||
const contextVariables = {}; | ||
for (const interpolationKey of interpolationKeys) { | ||
const interpolationKeyParts = interpolationKey.split('.'); | ||
const varName = interpolationKeyParts[interpolationKeyParts.length - 1]; | ||
if (interpolationKeyParts[0] === 'args') { | ||
const argType = argTypeMap && varName in argTypeMap ? argTypeMap[varName] : 'ID'; | ||
args[varName] = { | ||
type: argType, | ||
}; | ||
const initialObject = interpolationKeyParts[0]; | ||
const argType = argTypeMap && varName in argTypeMap ? argTypeMap[varName] : interpolationKeyParts.length > 2 ? 'JSON' : 'ID'; | ||
switch (initialObject) { | ||
case 'args': | ||
args[varName] = { | ||
type: argType, | ||
}; | ||
break; | ||
case 'context': | ||
contextVariables[varName] = `Scalars['${argType}']`; | ||
break; | ||
} | ||
else if (interpolationKeyParts[0] === 'context') { | ||
contextVariables.push(varName); | ||
} | ||
} | ||
@@ -207,0 +210,0 @@ return { |
{ | ||
"name": "@graphql-mesh/string-interpolation", | ||
"version": "0.2.0", | ||
"version": "0.3.0-alpha-4b3f4b8da.0", | ||
"description": "Dynamic string manipulation", | ||
@@ -10,3 +10,3 @@ "sideEffects": false, | ||
"dependencies": { | ||
"dayjs": "1.11.2", | ||
"dayjs": "1.11.3", | ||
"json-pointer": "0.6.2", | ||
@@ -13,0 +13,0 @@ "lodash.get": "4.4.2" |
@@ -12,9 +12,9 @@ import { GraphQLInputType, GraphQLResolveInfo } from 'graphql'; | ||
export declare function getInterpolationKeys(...interpolationStrings: string[]): any[]; | ||
export declare function parseInterpolationStrings(interpolationStrings: string[], argTypeMap?: Record<string, string | GraphQLInputType>): { | ||
export declare function parseInterpolationStrings(interpolationStrings: Iterable<string>, argTypeMap?: Record<string, string | GraphQLInputType>): { | ||
args: Record<string, { | ||
type: string | GraphQLInputType; | ||
}>; | ||
contextVariables: string[]; | ||
contextVariables: Record<string, string>; | ||
}; | ||
export declare function getInterpolatedStringFactory(nonInterpolatedString: string): ResolverDataBasedFactory<string>; | ||
export declare function getInterpolatedHeadersFactory(nonInterpolatedHeaders?: Record<string, string>): ResolverDataBasedFactory<Record<string, string>>; |
{ | ||
"name": "@graphql-mesh/string-interpolation", | ||
"version": "0.2.0", | ||
"version": "0.3.0-alpha-4b3f4b8da.0", | ||
"description": "Dynamic string manipulation", | ||
@@ -27,3 +27,3 @@ "sideEffects": false, | ||
"json-pointer": "0.6.2", | ||
"dayjs": "1.11.2", | ||
"dayjs": "1.11.3", | ||
"lodash.get": "4.4.2" | ||
@@ -30,0 +30,0 @@ }, |
@@ -22,3 +22,3 @@ import { stringInterpolator } from './index'; | ||
export function parseInterpolationStrings( | ||
interpolationStrings: string[], | ||
interpolationStrings: Iterable<string>, | ||
argTypeMap?: Record<string, string | GraphQLInputType> | ||
@@ -29,3 +29,3 @@ ) { | ||
const args: Record<string, { type: string | GraphQLInputType }> = {}; | ||
const contextVariables: string[] = []; | ||
const contextVariables: Record<string, string> = {}; | ||
@@ -35,9 +35,14 @@ for (const interpolationKey of interpolationKeys) { | ||
const varName = interpolationKeyParts[interpolationKeyParts.length - 1]; | ||
if (interpolationKeyParts[0] === 'args') { | ||
const argType = argTypeMap && varName in argTypeMap ? argTypeMap[varName] : 'ID'; | ||
args[varName] = { | ||
type: argType, | ||
}; | ||
} else if (interpolationKeyParts[0] === 'context') { | ||
contextVariables.push(varName); | ||
const initialObject = interpolationKeyParts[0]; | ||
const argType = | ||
argTypeMap && varName in argTypeMap ? argTypeMap[varName] : interpolationKeyParts.length > 2 ? 'JSON' : 'ID'; | ||
switch (initialObject) { | ||
case 'args': | ||
args[varName] = { | ||
type: argType, | ||
}; | ||
break; | ||
case 'context': | ||
contextVariables[varName] = `Scalars['${argType}']`; | ||
break; | ||
} | ||
@@ -44,0 +49,0 @@ } |
Sorry, the diff of this file is not supported yet
32128
810
+ Addeddayjs@1.11.3(transitive)
- Removeddayjs@1.11.2(transitive)
Updateddayjs@1.11.3