Lambda-backed endpoint

You can actually use a combination of API Gateway and Lambda to implement a GraphQL API. Within API Gateway, create a proxy endpoint with one route: /graphql. The following diagram shows that it looks much the same as the API Gateway and Lambda combination that we're already used to:

Non-REST-compliant API that exposes an endpoint with a /graphql route

This endpoint will send requests with the POST verb to the backend lambda for processing. Queries and mutations will be parsed and converted into the data source's native query language—whether that be SQL or an AWS SDK request.

In Node.js, there's a package called graphql that will be crucial to implementing the Lambda. In Python, there is a library called Graphene. And in Java, there is GraphQL Java. As usual, there's also a plugin for the Serverless Framework with a heap of features supported.

It's a lot of work to implement this by yourself in Lambda, even with the frameworks available. You need to write your own resolver and interfaces to your data sources. Luckily, there's an easier way.

Next, we will introduce you to a managed service that will streamline your graph implementation.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.36.221