Skip to content

apollo-server-lambda: JSON.parse errors when lambda event.isBase64Encoded=true #2599

@gobengo

Description

@gobengo

Today I just started using apollo-server-lambda. It works pretty well, and my GET request resulted in the GraphiQL playground showing. However, the POST method requests were all failing due to an error in the backend. I could see in Cloudwatch that there was an error when apollo-server-lambda/src/lambdaApollo does JSON.parse(event.body).

For one reason or another, my event had event.isBase64Encoded === true, and the event.body was a long base64 encoded string (that decoded to JSON), not a JSON string.

I was able to work around this error by rewriting all base64-encoed events upstream using this 'middleware' before passing the event into the apollo-lambda-server ApolloServer handler.

PR: #2600

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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions