Test for apollo-server-lambda - typescript

Hello,

I am working with apollo-server-lambda and is working fine the code using SAM AWS and deploying it to an AWS lambda. I have been trying to write a test to make sure it is working as expected when doing changes.

Apollo Server v3 has executeOperation which allows sending queries and returns, but does not replicate or allow to replicate event and context from the Lambda environment, because I am expecting headers that are coming with the request.

How can I write a test that will make sure to pass those into the Apollo Server?

I have the solution. The method executeOperation has a second parameter that accepts all the methods as the LambdaContextFunctionParams which are { event, context, express }.

By passing the following

{
    event: {
      headers: { header: "test" },
    },
};

It works as expected :slight_smile: