Implementing the entry point

With the addition of a new Lambda function that will respond to requests at the /graphql endpoint, we need one new entry in our existing handler.py file. For consistency with the other handlers in this file, the function will do the following:

  • Extract the HTTP method and payload from the request
  • Hand the HTTP method and payload to another function for processing
  • Construct and return the final response to API Gateway:
        def graphql(event, context):        http_method = event['httpMethod']        response = handle_graphql(http_method, event)        status_code = 200        response = {          'statusCode': status_code,          'body': json.dumps(response),          'headers': CORS_HEADERS,        }        return response

There isn't much to do in this function and one can see ...

Get Serverless Design Patterns and Best Practices now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.