From 3b00ed614e2846aa31fc8c8b12ed145c0a6f06de Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Wed, 4 Apr 2018 22:56:07 +0300 Subject: [PATCH] Use named arrow functions for all middlewares, including GraphiQL. As originally reported in [0], this should make debugging performance issues easier, since the name of the function will be properly displayed/shown in flame-graphs. [0]: https://github.com/apollographql/apollo-server/pull/827 --- src/lambdaApollo.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lambdaApollo.ts b/src/lambdaApollo.ts index 61776ae1..e576480c 100755 --- a/src/lambdaApollo.ts +++ b/src/lambdaApollo.ts @@ -34,7 +34,7 @@ export function graphqlLambda( ); } - return async ( + const graphqlHandler = async ( event, lambdaContext: lambda.Context, callback: lambda.Callback, @@ -73,6 +73,8 @@ export function graphqlLambda( }); } }; + + return graphqlHandler; } export interface LambdaGraphiQLOptionsFunction { @@ -95,7 +97,11 @@ export interface LambdaGraphiQLOptionsFunction { export function graphiqlLambda( options: GraphiQL.GraphiQLData | LambdaGraphiQLOptionsFunction, ) { - return (event, lambdaContext: lambda.Context, callback: lambda.Callback) => { + const graphiqlHandler = ( + event, + lambdaContext: lambda.Context, + callback: lambda.Callback, + ) => { const query = event.queryStringParameters; GraphiQL.resolveGraphiQLString(query, options, event, lambdaContext).then( graphiqlString => { @@ -115,4 +121,6 @@ export function graphiqlLambda( }, ); }; + + return graphiqlHandler; }