Amazon Web Services – Creating an AppSync GraphQL API
AppSync is an AWS service that helps you by simplifying the process of developing/building applications by letting developers create flexible, secure, extensible, and real-time APIs. It helps developers to manage and integrate mobile application data in real-time across devices and users, and at the same time allows the data to be accessed and modified when the mobile device is in an offline state.
AppSync exists in between the client apps and the AWS web services which include DynamoDB, Amazon Aurora, Lambda, Amazon Elasticsearch service, etc.
GraphQL is a language for APIs in AppSync that enables us to query and manipulate data easily through built-in and flexible syntax.
Unlike root API the GraphQL user decides what to receive rather than the server it is also fast, flexible as well as easy.
Benefits of AppSync :
1. Fast set upscale up as needed :
There are no servers to manage, AppSync provides a fully managed GraphQL setup, which has built-in high availability serverless infrastructure. You can create a GraphQL API in seconds through AWS CLI, Console, Amplify CLI, or cloud formation.
2. Simple and secure data access :
In AppSync you can perform complex queries and aggregation across multiple data sources with a single network call by using GraphQL. AppSync helps us to secure app data by using multiple simultaneous authentication modes as well as allowing us to define security and fine-grained access control at the data structure level directly from GraphQL schema.
3. Real-time subscriptions :
AppSync provides real-time subscription as well as offline access to app data. When your offline device tries to reconnect AWS appsync automatically syncs only the updates that occurred when the device was not connected instead of fetching the entire data set. AppSync manages data conflicts by offering user-customizable server-side conflict detection and resolution.
Creating an AWS AppSync GraphQL API :
- AWS account (You can apply for free tier)
- Install Node.js (version 10.x)
- Install NPM (version 6.x)
Follow the below steps to create an AWS AppSync GraphQL API:
Step 1: Go to your AWS management console and search for AppSync. Now go to Create API on the AppSync dashboard.
Step 2: Choose Build from scratch in order to build your API from scratch and define your own schema.
Step 3: Give a name to your API
Step 4: You can check your API configuration or details like API URL, API ID, Primary Auth mode, Auth Key in Settings.
Step 3: Go to Schema -> Create Resources and define your Schema according to your data. Schema is a text file written in GraphQL schema language also called Schema Definition Language(SDL).
Step 4: Define your Schema first give a custom type name and then declare fields in it.
Step 5: Your Schema with given fields and Resolvers are created. Resolvers help AWS AppSync to translate GraphQL requests and fetch information from your AWS resources.
Step 6: Your TODO Table created, will hold data in the fields that you have defined in your schema.
Step 7: Select your TODO table given above to see your TODO table, you can delete your data manually here.
Your AWS AppSync GraphQL API is successfully created and ready to be integrated with your applications
Limitations of AppSync:
Amazon AppSync is a managed service that allows developers to build and deploy serverless GraphQL APIs. Some limitations of AppSync include:
- Limited scalability: AppSync is designed to scale to millions of requests per day, but it may not be suitable for extremely high-traffic applications that need to scale beyond this limit.
- Limited data storage: AppSync stores data in Amazon DynamoDB, which has a maximum item size of 400KB. This means that individual items in your AppSync data store cannot exceed 400KB in size.
- Limited query complexity: AppSync has limits on the complexity of GraphQL queries that can be executed against it. If a query exceeds these limits, it will fail with an error.
- Limited data retrieval: AppSync only allows data to be retrieved in the order in which it was written to the data store. It does not support sorting or filtering data in any other way.
- Limited data migration: AppSync does not provide any built-in tools for migrating data from one data store to another. If you need to migrate data between data stores, you will need to build your own custom solution.
- Limited offline support: AppSync does not provide built-in support for offline scenarios, such as when a device is not connected to the internet. If you need to support offline scenarios, you will need to implement your own offline logic.
Please Login to comment...