apollo-server-integrations / apollo-server-integration-aws-lambda

An integration to use AWS Lambda as a hosting service with Apollo Server
MIT License
46 stars 9 forks source link

README is wrong for how to define context function #133

Closed cubabit closed 10 months ago

cubabit commented 11 months ago

The documentation says this is how you supply the function to define context:

export default startServerAndCreateLambdaHandler(
  server,
  handlers.createAPIGatewayProxyEventV2RequestHandler({
    context: async ({ event }) => {
      // Do some parsing on the event (parse JWT, cookie, auth header, etc.)
      return {
        isAuthenticated: true,
      };
    },
  }),
);

But handlers.createAPIGatewayProxyEventV2RequestHandler does not accept an argument. The correct syntax is:

export default startServerAndCreateLambdaHandler(
  server,
  handlers.createAPIGatewayProxyEventV2RequestHandler(),
  {
    context: async ({ event }) => {
      // Do some parsing on the event (parse JWT, cookie, auth header, etc.)
      return {
        isAuthenticated: true,
      };
    },
  }
);
trevor-scheer commented 11 months ago

Thanks @cubabit - do you want to submit a PR for the fix? I'm happy to otherwise.

acbellini commented 10 months ago

@trevor-scheer could you kindly fix this? I just wasted quite a bit of time on this problem... :)

trevor-scheer commented 10 months ago

@acbellini this is fixed now. This is a public repository, PRs to fix these kinds of issues are always welcome and preferred (and usually will get problems fixed in a much more timely manner). You can even edit files and open a PR directly in GitHub if you want to skip all of the repo setup / cloning.