Skip to content

apollo-server-lambda does not support API Gateway payloadFormatVersion 2.0 #5084

@pratiksyngenta

Description

@pratiksyngenta

When I add integration: lambda and authorizer it is throwing TypeError: event.path.endsWith is not a function error

graphql:
    handler: handlers/graphql/handler.graphqlHandler
    events:
    - http:
        path: graphql
        method: post
        cors: true
        integration: lambda
        authorizer:
          arn: arn:aws:cognito-idp:${env:COGNITO_USER_POOL_ARN}
          claims:
            - email
            - nickname
    - http:
        path: graphql
        method: get
        cors: true

As per my observation, without integration lambda and authorizer, I get event.path = {} whereas nornally it is '/'

dependency:
"apollo-server-lambda": "^2.22.2", "serverless": "2.31.0",

handler:

const { ApolloServer } = require('apollo-server-lambda');
import { dbConnect, models } from '../../db';
import { default as typeDefs } from '../../graphql/types';
import { default as resolvers } from '../../graphql/resolvers';

const createHandler = async () => {
  const db = await dbConnect();
  const server = new ApolloServer({
    typeDefs,
    resolvers,
    context: { models, db }
   });
  return server.createHandler();
};

export const graphqlHandler = (event, context, callback) => {
  createHandler().then(handler => handler(event, context, callback));
};

Expected:
Should not break with TypeError: event.path.endsWith is not a function error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions