AWS Appsync subscription reliable delivery? - graphql

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.

Related

Do I need to two links when building graphql subscription server?

I am planning to build a graphql application in ApolloServer to support query, mutation, subscription. I have read a lot of articles that subscription is done by websocket. All demos mention that I need to create 2 links, one for http, the other one is for ws.
based on my understanding, graphql spec doesn't include transport layer. I should be able to build one websocket transport to support all query, mutation, subscription.
Is it doable?
Is there any downside if I only use websocket link?

GraphQl federation server that supports subscriptions

I'm currently evaluating different GraphQl servers in order to find one that supports subscriptions on a federated schema.
Apollo and HotChocolate don't support that. HotChocolate is going to (its on the roadmap) but I can't wait; and Apollo wants me to run a seperate subscription service which I'd like to avoid.
Anybody know of a service that allows me to use subscriptions this way, now?
To be clear: I only need the federation server that supports subscriptions. The single schemas behind may still be served thru hot chocolate.
https://tyk.io/docs/getting-started/key-concepts/graphql-subscriptions/#how-we-are-ahead-of-everyone-else
After some digging, I found this. Looks very promising. They claim to support subscriptions on federation.
have you tried https://github.com/sammysaglam/federation-with-subscriptions?
disclaimer: i am the author of this library.
it uses apollo server express under the hood, and supports federation with subscriptions. it works using schema stitching by converting federation SDL into schema-stitching SDL, allowing full gateway to microservice subscriptions support.

Connecting AppSync to existing RDS for Mobile Application state changes

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.

Unit Test GraphQL schemas/queries made in AWS AppSync?

I have a simple question: is there a way/program/method to create unit tests to test the API Url generated on AWS AppSync to verify the validity of created GraphQL schemas, queries, mutations, etc?
There is an open-source AppSync Serverless plugin which has offline emulator support. You may find it useful: https://github.com/sid88in/serverless-appsync-plugin#offline-support
Another good recommendation is to have two separate AppSync APIs. One API is hosting you production traffic. The other is to test changes before they go to production. This is significantly easier if you use Cloudformation (highly recommended) to manage your infrastructure.
If you want to validate your API is working periodically (every minute or so), you could create a canary like the following:
Create a Lambda function which runs on a schedule. This lambda function will make various GraphQL requests. It can emit success/failure metrics to CloudWatch.
Setup a CloudWatch alarm so you can be notified if your success/failure metric is out of the ordinary.
For the canary use-case see:
https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/RunLambdaSchedule.html
https://docs.aws.amazon.com/lambda/latest/dg/with-scheduled-events.html
There is also amplify amplify-appsync-simulator package that is supposed to help with testing appsync, but there is no documentation on how you should use it. It is used by serverless-appsync-simulator Michael wrote and Amplify itself.

why Botkit stores data in json_file_store?

So, we are trying to implement slack integration with our product, botkit uses json_file_store to store channel, team, user related information, why does botkit stores such data? Is there way to avoid storing such data on production environment? or should I use any other slack bot client?
You can read more about how and why Botkit stores data here:
https://botkit.ai/docs/storage.html
Youll want to use at least the simple storage to keep track of things like team/user/channel id in slack, especially if the bot is to be installed or interact with multiple teams or users. This data does not persist like using a dedicated storage connector, and if you are worried about data leakage you can use the Events API in concert with Botkit middleware to limit the data that is sent to the app too and from slack.
https://botkit.ai/docs/readme-pipeline.html

Resources