apollo-server-lambda does not support API Gateway payloadFormatVersion 2.0
See original GitHub issueWhen 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:
- Created 2 years ago
- Comments:13 (6 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is released in Apollo Server 2.23.0.
@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.