Written by Nicolás Tosolini | Associate Software Engineer @ DinoCloud
What is AppSync, and what is it used for?
AppSync is an AWS service that is responsible for simplifying application development. For example, if you use a front-end development, you have to deploy an API as quickly as possible. In the shortest possible time, AppSync gives you the possibility to deploy the API quickly, with a couple of clicks, and Amazon takes care of the maintenance. It is very efficient for front-end developments since it gives you the possibility of having flexible and secure access to the data with one or more origins. AppSync allows you to take all the data, which comes from different sources, gather it, modify it, and bring only the relevant information, which ends up being an essential feature since it offers more speed and allows the performance to be much more performant.
Another quality that AppSync provides is the management and synchronization of application data in real-time. For example, using subscriptions offers the possibility to the server that it is constantly listening to if there are databases or not, which is functional to create chats since it is constantly sending data in real-time. You have precise access to that data.
On the other hand, a feature that AppSync has is that it allows you to access and modify data offline, for example, if you have a mobile application. You run out of data, or you do not have Wi-Fi, it would be expected for you not to continue using it. However, from AppSync, It can continue to work. Once the internet connection is back, it will take care of merging the data from when you were offline, resolving conflicts, and syncing everything to the database.
Another clear example is when from enterprise apps, from web apps, mobile apps, or I oT devices, AppSync takes all your information and processes it with GraphQL Scheme or resolvers, being able to see that the source of information can come from any site, be it or not on AWS, which turns out to be valuable if you need information that is in four different databases, as with AppSync you can grab everything and put it in one call.
AppSync uses GraphQL as its query language, allowing the connection of different information sources, whether they are inside or outside of AWS. It has a high degree of security since it can use Amazon Cognito, IAM or the different possibilities of Amazon authentication, subscriptions to do real-time apps, and serverless caching.
GraphQL and its functions
GraphQL is simplified data access and queries, which means that the client only consults the data it needs and the format it wants. Searching, filtering and querying data would be three dominant aspects in this language. It provides all the information, filters it, and offers it to you, thus increasing the system’s speed enormously, especially if it is a mobile application and it is not connected to Wi-Fi.
Another feature of GraphQL are subscriptions, which mean updates and access in real-time, which gives you the possibility to run applications instantly, for example, a chat that when you send information, the other user has to see it instantly, giving you the possibility of synchronizing many data at the correct time.
AppSync is also relevant in caching since it gives you the ability to cache endpoints and resolvers, increasing the response speed.
What are the benefits of using AppSync?
- It is Effortless since you can get it up quickly, and you do not have to do server maintenance. If the application grows in size, it allows you to scale very quickly and have the entire AWS infrastructure.
- It has the advantage of providing you access offline and in real-time.
- Moreover, finally, unified access, which means you have resolvers, lambadas, and all services and data in one place.
Examples of possible applications to create
In a travel application where the user may or may not be connected to the Internet, especially if he is in another country, AppSync allows you to continue using the application since it will not give any error and then when connecting, it will synchronize all the information.
If it is a social media app, it will use lambda issues and access to different sources of information. Today Facebook has too much information, and this will allow you to access all those information points.
Also, in the case of chat apps, everything happens thanks to the so-called real-time subscriptions, where the user has to have an answer instantly. Thanks to the subscriptions, the request in these services is made much faster and more agile. It is also connected to amazon Cognito, which brings a further step in security.
What is the difference between GraphQL and Rest API?
GraphQL has the characteristic of having a single endpoint, allowing you to do everything from there. You have the option of giving it a query, mutation, or subscription, and the server will take care of returning that. It also gives you the possibility to bring only the information you want. For example, if you make a query and tell it that you only need one user and give it its ID, but in order that you only need three specific data, it will show you what you asked for and nothing else. Let us also think that having a single endpoint, you only have to make one call, and it brings you everything you need. Sometimes you may have the information stored in different places, so it is necessary to make several calls with Rest API to different endpoints. This brings you information that you do not need, which does not happen with GraphQL, since with its configuration, you ensure that it only shows you the relevant information you want and in the way you want. It is very optimal, especially when handling large volumes of information.
- A query language for APIs.
- It provides you with a complete and understandable description of your API data.
- It offers you the possibility of obtaining only the data you need in a single request.
- Schemas: facilitates how identities are decided, how they are related to each other, which ones are available to each client.
- Query: it performs the queries to the single entry point (endpoint).
- Mutation: insert, delete and edit elements.
- Subscriptions: This allows real-time connection with the server to be immediately informed about important events.
GraphQL Query Language
- You want to read data
- Mutations change data
- Subscriptions subscribe to real-time data
Cognito: What is it, and what is it for?
- Amazon Cognito provides authentication, authorization, and user management for your mobile and web applications.
- Users can log in directly with a username and password or through a third party such as Facebook, Amazon, Google or Apple (federation)
- User groups and entity groups
At DinoCloud, we take care of turning a company’s current infrastructure into a modern, scalable, high-performance, and low-cost infrastructure capable of meeting your business objectives. If you want more information, optimize how your company organizes and analyzes data, and reduce costs, you can contact us here.
Associate Software Engineer