apollo-server-integrations / apollo-server-integration-aws-lambda

An integration to use AWS Lambda as a hosting service with Apollo Server
MIT License
46 stars 9 forks source link

1.1.0 example returns 400 #60

Closed jakobloekke closed 1 year ago

jakobloekke commented 1 year ago

I've set up the basic getting started example and installed the latest version (1.1.0) from NPM, but running the example returns the following:

{
    "statusCode": 400,
    "body": "Search params not parsable from event"
}

If I downgrade "@as-integrations/aws-lambda" to version 1.0.1, I get the expected result:

{
    "statusCode": 200,
    "headers": {
        "cache-control": "no-store",
        "content-type": "application/json; charset=utf-8",
        "content-length": "27"
    },
    "body": "{\"data\":{\"hello\":\"world\"}}\n"
}

So I guess there's something I need to set up differently when using the latest version – something not mentioned in the example guide. Or, there's a bug in the latest version. :)

BlenderDude commented 1 year ago

Most likely a bug! Can you let me know which event type is causing the issue?

jakobloekke commented 1 year ago

I'm following the guide at https://www.apollographql.com/docs/apollo-server/deployment/lambda/#running-locally. The error happens when I execute the invoke command using the query.json as described.

BlenderDude commented 1 year ago

Looks like this is actually an issue with the documentation! I am working on updating the docs today but for now, here is the proper query.json example.

{
  "version": "2",
  "httpMethod": "POST",
  "path": "/",
  "headers": {
    "content-type": "application/json"
  },
  "requestContext": {},
  "rawQueryString": "",
  "body": "{\"operationName\": null, \"variables\": null, \"query\": \"{ hello }\"}"
}

Note that this version has the version and rawQueryString keys, both of which are required by our parser (and are always sent by lambda) but were missing in the example request.