Search code examples
postgresqlamazon-web-servicesgraphqlaws-appsyncpostgraphile

How to connect self hosted PostgreSQL on AWS EKS to AWS AppSync with auto schema generation and hot reload?


I have research it for several days but could not find a definitive answer for it.

My use case is I have a PostgreSQL database hosted on AWS EKS and I want to expose it using GraphQL, which generally leads to AWS AppSync.

I understand that AppSync can be auto imported from DynamoDB only however I am not using that. From several articles it suggested a Lambda Function to connect between AppSync and PostgreSQL. Which I tried, but I need the two feature which is:

  • Auto Generated Schema
  • Hot reload of the schema whenever there is changes in the database

Currently I am using PostGraphile for these two features however I am not sure AppSync can be connected to that, as I understand we need to push the schema generated by PostGraphile to AppSync, but I need it to be automatic.

Eg: I create a new table in PostgreSQL -> PostGraphile Lambda Function reload the schema -> Reflects on AppSync schema automatically -> User call new table via AppSync

Can this flow be achieved? Is there anything I can use as reference?

Thank you!


Solution

  • If anyone still wondering, I found a resource from AWS seems to be able to achieve this with some tweaks and changes: https://github.com/aws-samples/appsync-with-postgraphile-rds