I've been trying to get apollo-server-lambda worki...
# help
I've been trying to get apollo-server-lambda working with the SST, but I'm running into some problems. I have tried deploying it as a sst.Function with a apigateway.LambdaRestApi and with sst.Api (had to change to ApiPayloadFormatVersion v1 to get it working) with no luck. I get the graphql playground running on the endpoint url, but get a
when querying for the schema. No other errors. Any ideas what I'm missing here? Here's a basic example using it with the CDK: https://github.com/tlakomy/cdk-graphql-lambda-example
Were you able to get the basic example working?
No, not with the sst.Function unfortunately. It should work as a direct replacement for lambda.Function, right?
Yeah. If you can get the CDK version to work described in the post https://tlakomy.com/build-a-simple-graphql-server-with-apollo-and-cdk, I’m pretty sure we can get it to work with SST.
Migrating a CDK project to SST is super straigt forward
Ah, ok. I got it working with the CDK, heres the generated template: https://gist.github.com/ameistad/1ebb05a84af532a4b60b740ef476bc50
Okay lemme go give it a try over the weekend
I’m not too famiilar with GraphQL. So if i follow this guide step by step https://tlakomy.com/build-a-simple-graphql-server-with-apollo-and-cdk, do I need to setup anything else to set it up?
And how should I curl the endpoint url to reproduce the 
response you were getting?
Awesome! Yep, all I did was to clone the repo and run npm install, npm run build and cdk deploy. Apollo-server comes with the graphql playground built-in, which you can use to query the endpoint. Just open up the endpoint url in a browser, and the playground should start automatically. You might encounter a bug in the playground where it doesn't use the right endpoint url. I had to append /prod/ to the url the playground wanted to use.
The playground will query the endpoint to get the schema automatically. I got the null response when I tried that with the sst.
Got it! 🙏
@Frank or @Andreas did you ever work this out by any chance? We’re having this exact same issue and then found this thread 🙏
@Matt Vagni I will try to look at this today and get back to you guys!
We seem to have narrowed it down to the overall event body size of the event actually.
Let me get some more details - one sec
We were going to open a proper bug/reproducible issue but in short:
Copy code
import { APIGatewayProxyResult } from 'aws-lambda';
function random(length: number) {
  let result = '';
  const characters =
  const charactersLength = characters.length;
  for (let i = 0; i < length; i++) {
    result += characters.charAt(Math.floor(Math.random() * charactersLength));
  return result;
export async function handler(): Promise<APIGatewayProxyResult> {
  return {
    statusCode: 200,
    // 8097 - fine
    // 8098 - breaks
    body: random(8098),
    headers: { 'Content-Type': 'text/plain' },
you can use this to reproduce (courtesy of @Akos)
This might be a complete red herring however!
Yeah, what Matt and I uncovered was this bug that's been fixed: https://github.com/serverless-stack/serverless-stack/pull/190
@Matt Vagni Thanks for putting in the work pinning down the issue. Can you try SST 0.9.15 and see if the issue still happens to you?
@Frank it does!
We’ve just tried this 👍
Oh nice!
@Andreas can you give 0.9.15 a try and see if the issue is fixed for you?
I'm actually getting this error with 0.9.15:
TypeError: Cannot read property 'type' of undefined
at returnLambdaResponse (/Users/andreas/projects/apollo-server-lambda/node_modules/@serverless-stack/cli/scripts/start.js:1149:24)
at ChildProcess.<anonymous> (/Users/andreas/projects/apollo-server-lambda/node_modules/@serverless-stack/cli/scripts/start.js:1186:5)
at ChildProcess.emit (events.js:311:20)
at ChildProcess.EventEmitter.emit (domain.js:482:12)
at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
But, if it's working for @Matt Vagni there is probably something wrong with my setup. I'll look into it.
hmm.. what’s ur OS/Node version?
can you DM me your debug log at
Sure 👍