question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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 ‘/<function path>’

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
glassercommented, Apr 14, 2021

This is released in Apollo Server 2.23.0.

2reactions
glassercommented, Apr 9, 2021

@brianleroux Thanks, that’s helpful.

apollo-server-lambda is largely authored by external contributors who actually use Lambda, but that does mean that it’s challenging for us to review changes as non-Lambda experts (which is why I’m hoping to remove most of the complexity from this package soon).

It looks like what your link says is that there are two API Gateway lambda payload versions, and the current code only supports version 1.0. This seems like something I can plausibly fix today and get into v2.23.0 which should be out today or Monday.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deploying with AWS Lambda - Apollo GraphQL Docs
The @as-integrations/aws-lambda package is compatible with Lambda's API Gateway V1 (REST) and V2 (HTTP). However, it does not let you customize HTTP behavior ......
Read more >
API Gateway: Explaining Lambda Payload version 2.0 in ...
HTTP API has been GA on Mar 12. The blog described new features and changes including Lambda payload version 2.0 which would be...
Read more >
apollo-server-lambda | Yarn - Package Manager
This is the AWS Lambda integration of GraphQL Server. Apollo Server is a community-maintained open-source GraphQL server that works with many Node.js HTTP ......
Read more >
GraphQLApi
warning. The GraphQLApi construct is deprecated, and will be removed in SST v2. Use the Api construct with a graphql route instead.
Read more >
Use graphQL with API Gateway (apollo-server-lambda) vs. ...
It depends on how much control you want over your backend service execution, how much code you feel like writing, and then of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found