From c2737610702436a1df9b16c08db4291827cddbf4 Mon Sep 17 00:00:00 2001 From: Josh GM Walker <56300765+Josh-Walker-GM@users.noreply.github.com> Date: Mon, 14 Aug 2023 17:43:36 +0100 Subject: [PATCH] Move yoga for perf --- .../graphql-server/src/functions/graphql.ts | 47 +++++++++---------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/packages/graphql-server/src/functions/graphql.ts b/packages/graphql-server/src/functions/graphql.ts index 05af9270a8d9..c42b5d8f91b0 100644 --- a/packages/graphql-server/src/functions/graphql.ts +++ b/packages/graphql-server/src/functions/graphql.ts @@ -42,6 +42,29 @@ export const createGraphQLHandler = ({ schemaOptions, openTelemetryOptions, }: GraphQLHandlerOptions) => { + const { yoga, logger } = createGraphQLYoga({ + healthCheckId, + loggerConfig, + context, + getCurrentUser, + onException, + generateGraphiQLHeader, + extraPlugins, + authDecoder, + cors, + services, + sdls, + directives, + armorConfig, + allowedOperations, + allowIntrospection, + allowGraphiQL, + defaultError, + graphiQLEndpoint, + schemaOptions, + openTelemetryOptions, + }) + const handlerFn = async ( event: APIGatewayProxyEvent, requestContext: LambdaContext @@ -50,30 +73,6 @@ export const createGraphQLHandler = ({ requestContext.callbackWaitsForEmptyEventLoop = false let lambdaResponse: APIGatewayProxyResult - - const { yoga, logger } = createGraphQLYoga({ - healthCheckId, - loggerConfig, - context, - getCurrentUser, - onException, - generateGraphiQLHeader, - extraPlugins, - authDecoder, - cors, - services, - sdls, - directives, - armorConfig, - allowedOperations, - allowIntrospection, - allowGraphiQL, - defaultError, - graphiQLEndpoint, - schemaOptions, - openTelemetryOptions, - }) - try { // url needs to be normalized const [, rest = ''] = event.path.split(graphiQLEndpoint)