[WIP] (feat: api-gateway): Smithy-like syntax and Velocity-Template DSL for Api Gatewau #111
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Excited with where this change is going! A total re-work of the API Gateway stuff and preparation for AppSync/GraphQL.
Closes #110
The idea is to entirely abstract VTL transformation done by API Gateway as ordinary function calls and data operations. Let's look at an example.
First, define some record types.
Create a Service and an Endpoint:
Create a callable API hosted in our Lambda Endpoint.
Add an "Operation" to the service (static function call, not resourceful yet):
This operation accepts a
GetUserRequest
and returns aGetUserResponse
by proxying the call to the Lambda Function.What if the lambda only accepted a
string
instead of aGetUserRequest
? We can express VTL transformation in a very simple, type-safe way:Same is true for the output of an API integration:
Where this really starts to shine is with service proxies like DynamoDB or SQS:
So far, we've only configured static operations on the API. Taking inspiration from Smithy, you can also add resources to the service:
And then configure operations for
get
,create
,update
andlist
: