2

I can deploy and run successfully my lambda with a GraphqlClient in the URL:

https://4er563if.execute-api.us-east-1.amazonaws.com/dev/zipcodes

As far as I understand, that passes through the AWS API gateway that triggers the lambda, the gateway takes the POST data and delivers it to the lambda.

But now I want to try the code directly on the Lambda browser console. There is the option "Configure test event", where I can define and send a JSON string to the lambda, but I don't know what info "event" and "context" should hold.

I tried:

 {
   "headers": {"origin":true},
    "context": "{ \"functionName\": \"getZipdata\",
                  \"method\": \"POST\",
                  \"query\": getZipdata(zip: \"04340\") {id, name}}"
  }

but I'm getting:

  "body": "Apollo Server supports only GET/POST requests."

1 Answer 1

3

I found the way!

{
    "headers": {
      "Accept": "application/json"
    },
    "path": "/zipcodes",
    "resource": "/zipcodes",
    "httpMethod": "POST",
    "body": "{\"query\":\"query {\\n  getZipdata(cp: \\\"78446\\\") {idmunicipio,municipio, asentamiento}\\n    }\",\"variables\":{},\"operationName\":null}"
  }
Sign up to request clarification or add additional context in comments.

1 Comment

A note: the path and the resource are set the the file where your handler is. if the entry point of the lambda is index.handler then it should be /index (but good work this helped me!)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.