Open In App

Amazon Web Services – Creating an AppSync GraphQL API

Improve
Improve
Like Article
Like
Save
Share
Report

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. 

AppSync

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 :

Prerequisite:

Implementation:

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.

AppSync Dashboard

Step 2: Choose Build from scratch in order to build your API from scratch and define your own schema. 

Build API from scratch

Step 3: Give a name to your API

Give 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.

Your API configuration

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).

Create Schema by clicking on create resources

Step 4: Define your Schema first give a custom type name and then declare fields in it.

define schema

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.

Schema and resolver created successfully

Step 6: Your TODO Table created, will hold data in the fields that you have defined in your schema.

TODO table

Step 7: Select your TODO table given above to see your TODO table, you can delete your data manually here.

TODO Table

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:

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.


Last Updated : 27 Mar, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads