I've seen examples of DynamoDB as the data source for AWS AppSync but I'm wondering if Aurora (specifically PostgreSQL) can be used? If yes, what would the resolvers look like for a basic example? Are there any resources that demonstrate doing this for Aurora PostgreSQL or even MySQL?
4 Answers
It can not. You can use Aurora Serverless as the data source which is driven by Data API (still in beta), this allows you to configure resolvers as database queries. That being said Data API is still very slow and Aurora Serverless has a cold-start of 30sec or so as it needs to run from VPC. I would recommend avoiding production but worth playing around.
You are much better of using Lambdas as resolvers or running HTTP RestFul calls from within the resolvers.
Ignore the comments provided in the answer, no disrespect, but the comments are coming from people who never managed production at scale. The fact you have a fully manage GraphQL service at scale as well as with high-security posture will save you months of maintenance nightmares when your product(s) will reach anything close to 1MIL revenue.

- 2,193
- 2
- 19
- 24
You can use the AWS Lambda resolver available in AWS AppSync to access Aurora Postgres. The code is similar to how you would access a relational database using any language. For example, you could use node-postgres with NodeJS to implement the Lambda function.

- 3,535
- 1
- 26
- 31
-
8At that point, why not just spin up [Graphile](https://www.graphile.org/postgraphile/) in a Lambda? Seems like AppSync isn't adding much value... – cazzer Feb 06 '18 at 16:57
-
3I expected aws to provide such an functionality too! Using Graphile, graphql-yoga or apollo-server always means you need to run instances for websockets and requires to scale them. I guess appsyncs is smarter on that. Other than that I agree cazzer – Manuel Mar 19 '18 at 16:44
-
1I guess that now is possible to do it directly without any Lambda. Isn't it? I'm a little confused about how to do it well... :/ – Aral Roca Dec 26 '18 at 12:27
-
1@cazzer Graphpille does not support subscriptions which is a driver for the use of graphql. AppSync also ties into AWS Cognito user pools and makes authentication easier across services. – wattry Feb 06 '20 at 17:12
yes this can be done.
Do take a look at this open-source repo that does exactly that: https://github.com/wednesday-solutions/appsync-rds-todo

- 83
- 1
- 7
-
Welcome to SO! Don't post links to websites, as it might be broken or taken down in future. Instead, explain the solution. – Abhishek Dutt Jul 12 '21 at 05:30
As of time of writing, yes but only if it is a Serverless Aurora RDS cluster set to Postgres compatibility. The reason for this is it's the only RDS instance type that supports the Data API. Other RDS instances would have to be configured as a different data source type, most commonly Lambda.

- 66
- 6