@@ -7,6 +7,7 @@ import { IncomingHttpHeaders } from 'http';
77import { DocumentNode , parse , print , getOperationAST } from 'graphql' ;
88import { AxiosTransformer , AxiosInstance , AxiosRequestConfig } from 'axios' ;
99import * as express from 'express' ;
10+ import { encode } from 'punycode' ;
1011
1112const PATH_VARIABLES_REGEX = / : ( [ A - Z a - z ] + ) / g
1213
@@ -268,14 +269,15 @@ export default class Route implements IMountableItem {
268269 //
269270 // This method will iterate through all variables, check their definition type from the spec
270271 // and typecast them
271- private typecastVariables ( variables : { [ key : string ] : string } ) : { [ key : string ] : any } {
272+ private typecastVariables ( variables : { [ key : string ] : string } , encoder ?: Function ) : { [ key : string ] : any } {
272273 const parsedVariables : { [ key : string ] : any } = { } ;
273274
274275 Object . entries ( variables ) . forEach (
275276 ( [ variableName , value ] ) => {
276277 const variableDefinition = this . operationVariables [ variableName ] ;
278+ const typecastValue = typecastVariable ( value , variableDefinition ) ;
277279
278- parsedVariables [ variableName ] = typecastVariable ( value , variableDefinition ) ;
280+ parsedVariables [ variableName ] = encoder ? encode ( typecastValue ) : typecastValue ;
279281 }
280282 ) ;
281283
@@ -287,7 +289,7 @@ export default class Route implements IMountableItem {
287289 const { query, params, body } = req ;
288290
289291 const parsedQueryVariables = this . typecastVariables ( query ) ;
290- const parsedPathVariables = this . typecastVariables ( params ) ;
292+ const parsedPathVariables = this . typecastVariables ( params , encodeURI ) ;
291293
292294 const providedVariables = { ...parsedQueryVariables , ...parsedPathVariables , ...body } ;
293295
0 commit comments