0

Hi I am using the graphql-yoga integration with AWS Lambda sample from this Link

I am unable to access the response object in the context function. I would like to access it in the AWS Lambda Integration so it can be passed onto the resolvers.

const yoga = createYoga<{
    event: APIGatewayEvent;
    lambdaContext: Context;
}>({
    // specify the path to the lambda function
    graphqlEndpoint: '/graphql',
    schema: createSchema({
        typeDefs,
        resolvers,
    }),
    context: async (params: any) => {
        const { request, response } = params;
        // response is not there 
        const cookies = request.headers.get('Cookies');
        // response needs to be passed to resolvers,
        // so that a cookie can be created and attached to it in there
        return { request, response };
    },
});

I want to grab the response object in the context function, which I believe is available in node.js environment, but not sure if it is available in the lambda env or not. If not is there a way to send cookies with the actual response after generating them from within a resolver?

I could potentially use the node.js version of graphql-yoga with lambda integration so that I have access to the response object in addition to the request. Is that possible?

Nosh
  • 485
  • 7
  • 24

0 Answers0