Skip to content

Commit

Permalink
Use named arrow functions for all middlewares, including GraphiQL.
Browse files Browse the repository at this point in the history
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]: apollographql/apollo-server#827
  • Loading branch information
abernix committed Apr 18, 2018
1 parent 74fb75a commit 3b00ed6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/lambdaApollo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function graphqlLambda(
);
}

return async (
const graphqlHandler = async (
event,
lambdaContext: lambda.Context,
callback: lambda.Callback,
Expand Down Expand Up @@ -73,6 +73,8 @@ export function graphqlLambda(
});
}
};

return graphqlHandler;
}

export interface LambdaGraphiQLOptionsFunction {
Expand All @@ -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 => {
Expand All @@ -115,4 +121,6 @@ export function graphiqlLambda(
},
);
};

return graphiqlHandler;
}

0 comments on commit 3b00ed6

Please sign in to comment.