-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
apollo-server-lambda: JSON.parse errors when lambda event.isBase64Encoded=true #2599
Comments
…ase64Encoded Resolves apollographql#2599
…ase64Encoded Resolves apollographql#2599
PR: #2600 |
Interesting!
Do you have any idea how or why this is the case? Not to say that we can't accept the PR, but the need seems be a bit unsubstantiated / not fully understood. I'd like just like to understand the reasoning so we can make sure we account for it property going forward. |
It’s the case because that’s the event AWS handed to the lambda function. The http request itself originated from the GraphiQL playground that Apollo server renders.
As for a how or why, I think AWS just reserves the right to decide arbitrarily how it translates incoming requests to lambda events.
…Sent from my iPhone
On May 13, 2019, at 9:20 AM, Jesse Rosenberger ***@***.***> wrote:
Interesting!
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.
Do you have any idea how or why this is the case? Not to say that we can't accept the PR, but the need seems be a bit unsubstantiated / not fully understood. I'd like just like to understand the reasoning so we can make sure we account for it property going forward.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@abernix Here’s one case I ran into: lambda@edge provides the Request Body as a base64 encoded string. I would love to have apollo-server-lambda automatically handle it. |
This issue stung me this weekend. I am building my first Apollo server app and want to stick it on a lambda. I followed the guide to the letter. When it deploys the |
I experienced the same problem and can confirm the associated PR #2600 resolves the problem. |
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 theevent.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
The text was updated successfully, but these errors were encountered: