Connecting AppSync to existing RDS for Mobile Application state changes - graphql

I have a mobile application (Native iOS and Android) that I'd like to have receive realtime state information on whether or not to display certain things in the UI.
Our current backend runs Sails and has a MySQL Database. Sails is deployed over EC2 and the MySQL DB uses AWS RDS. I've been reading about AWS AppSync and believe it's a viable solution to pushing realtime state information from the MySQL DB up to the frontends.
My question is, is it possible to connect AppSync to subscribe to the RDS instance, and if so, does the solution require a Lambda function to run the actual querying against the DB? The entire concept is still new to me & today's the first time I've heard of GraphQL, so any and all information on how AppSync works and how this could be implemented would be great!
Currently I believe I'd create a GraphQL Schema that matches the state information I need, AppSync would expose an API for me to subscribe to with their mobile SDKs?, and I could use my Sails backend to send GraphQL mutations to AppSync which would then (somehow?) update the mySQL DB? Is this a proper flow and could somebody please fill in the gaps here :)

Are you trying to update the database directly/bypassing AppSync?
If yes, the lambda solution you mentioned maybe useful.
If no, by setting up subscriptions and mutations to the database via AppSync is sufficient.

Related

How to use AWS Appsync with RDS Mysql database or with mysql aroura serverless database for real time syncing

I'm building an application that has Web(PHP-Laravel) as well as Android UI. I need real-time sync of data between both platforms. For that, I'm trying to use AWS Appsync but after reading the documentation I'm so much confused about which service I need to use. There are so many options for integration like AWS lambda, API Gateway. So which one is appropriate for my requirement? Secondly, I'm not able to figure out how to connect the RDS MySQL database with Appsync for real-time data. AWS documentation is so much confusing that I'm not able to get it. Kindly help me with this. Thanks in advance.

Is JDBC the only option to connect to aws hosted rds from aws lambda function

Like the title asks, im wondering if the only way of connecting to my aws hosted rds through aws lambda function in java is through a jdbc connection?
Does the aws sdk provide a way of doing this, querying the data and returning results without the need for jdbc?
I've looked through the aws api documentation but nothing is jumping out at me in terms of making a connection through the aws sdk alone, it seems to provide functions on more admin type tasks. .
The reason I ask is in the interest of speed, the jdbc connection takes a few seconds for a connection, but thought if the aws sdk could connect it may be quicker?
Depending on the kind of database you use there are different options.
If you want to reduce the connection latency, you could look into using RDS proxy, which will act as a reverse-proxy in from of the database instances and has a couple of connections ready for you to use.
It's also optimized to let you quickly establish connections through JDBC to it.
If you use Aurora Serverless, you might be able to use the Data API, which uses the AWS SDK to make requests to the database over HTTP. You can find more information on that in the docs: Using the Data API for Aurora Serverless.
You can also always use connection pooling in your lambda functions, which will at least make warm lambdas more performant but doesn't help you with cold starts.

Which instance is the best to create an Apollo Graphql microservice on AWS?

Looking to create an Apollo Graphql microservice on AWS and am looking for the best way to build this on AWS, AWS do have their own Graphql as a service called Apsync but this seems like a blunt tool. Have found lots of suggestions to use Lambda but not much else. The Graphql layer will resolve data from several other AWS microservices.
Certainly don't use AppSync. We used it for a year, and found it's difficult to configure and does not perform well in many types of queries. We ended up using the Apollo Server on top of Lambda. As we use DynamoDb, we wrote our own resolvers (not much effort) as part of using the Apollo Server.

How i can share data which i connected with Heroku connect with other salesforce users

I have my website in PHP and DB in MySQL. I want salesforce users to search on my database from within their salesforce. For that, heroku connect seems to be the option. So i am thinking of converting my MySQL DB to PostGre and then use heroku connect to share my data with my salesforce account. The question i have is, how can i share same data with other salesforce users ? Those users are my website clients and i don't want them to go through this process of heroku connect. Is there was of sharing my data with other salesforce users ?
You cannot and should not expose your database directly to your customers. That would allow them to change the data as well as read it.
Your solution here is to create a public API which exposes endpoints that will make it possible for anyone (with proper authentication hopefully) to query your data.
There are many ways you can design an API, whether it's a REST or a GraphQL one. This is something which can absolutely be done in PHP though.

AWS Appsync subscription reliable delivery?

We were thinking of using aws appsync for communicating alerts/messages to mobile and web apps using graphql subscription feature. I tried a small example in nodejs using appsync javascript sdk based on tutorial https://docs.aws.amazon.com/appsync/latest/devguide/building-a-client-app-node.html. This is my first time doing graphql and appsync.
Since they use MQTT over websockets, what is QoS used for subscribing? 1, 2
When we use appsyncclient.subscribe Is it our responsibility to verify if duplicate data is coming into the next callback or is it guaranteed based on ID.

Resources