AWS AppSync with the Serverless Framework.

Before starting on AppSync we must have knowledge of GraphQL — 

So GraphQL is a query language for your API and a server-side runtime for executing queries using a type system you define for your data. GraphQL isn’t tied to any specific database or storage engine and is instead backed by your existing code and data.

What is AWS AppSync?

AWS AppSync provides a robust, scalable GraphQL interface for application developers to combine data from multiple sources, including Amazo

n DynamoDB, AWS Lambda, and HTTP APIs.

The system supplying data to a GraphQL API is rarely a single application. Instead, the backend is usually composed of multiple microservices, and the GraphQL API layer is responsible for gathering all the necessary data from the various applications and returning the combined result to the API requester. This GraphQL API layer must be able to parse the GraphQL requests, know where to get the data for each portion and merge the data to produce a response.

Before talking about appsync with serverless, let’s talk a little bit about serverless.

Serverless is a cloud-native development model that allows developers to build and run applications without having to manage servers. There are still servers in serverless, but they are abstracted away from app development.

How does AppSync work with the Serverless Framework?

The Serverless Framework provides an AWS AppSync component that makes it easy to get started with AppSync. The component supports all available data sources and authentication methods while giving you an excellent Serverless Framework developer experience when working with AppSync.

Many APIs managed with AppSync also rely on AWS Lambda functions as their data sources, and the Serverless Framework is a great fit for creating those Lambda functions, from design through deployment to monitoring and debugging.

Benefits of using AppSync

As a developer, how do you stand to benefit the most from using AppSync? We believe there are three main advantages:

Fully managed GraphQL API layer. AppSync allows you to skip the creation of your own GraphQL resolvers and data-source connections, resulting in significant time savings when setting up new GraphQL APIs and in faster iteration once you have customers, internal or external, using your APIs.

Real-time subscriptions and offline functionality are built in. Using AppSync allows for GraphQL subscriptions, which are a great way to build applications that always present the most up-to-date state of the data. When using AppSync with the Amplify framework, you can combine subscriptions with offline functionality to create auto-updating web and mobile apps that can correctly handle unstable mobile network connections without much additional work.

Integrations with core AWS services. Since AppSync integrates with AWS Lambda, RDS, and DynamoDB, chances are you won’t need to write custom code to connect to your databases. This speeds up development for your teams using AppSync, allowing them to focus more on business logic and less on connection layers for the underlying services.

Drawbacks to using AppSync

Using AppSync certainly has some drawbacks, and you should consider the following carefully before using AppSync in production.

Additional tooling you’ll need to use. Much of the useful functionality of AppSync is available only when using specialized GraphQL tooling, like the Amplify framework. This is a result of the complexity of the GraphQL protocol and its real-world implementations. This means that getting the maximum benefit out of using GraphQL in general and AppSync specifically will bring with it additional dependencies and a steep learning curve.

Lack of transparency in performance. AppSync is a managed service, and as such you don’t get access to performance settings for your GraphQL API layer. If your API layer is your company’s frontline interface for your customers, not having control over your key component’s performance attributes may pose a serious risk. AppSync can add significant overhead to your API response times, and in certain cases (e.g., if you haven’t configured the collection of tracing information in your API) you may not have any data to help you debug the increased latency.

Not all data sources are supported out of the box. If your data stores run outside of AWS, or if you are using a type of database that isn’t supported by AppSync by default, you may need to spend extra time implementing a data connection layer in your AWS Lambda functions just so you can use your data stores in AppSync.

What is AppSync good for?

AppSync focuses on GraphQL APIs, so naturally the applications and services that would benefit from providing GraphQL APIs are most likely to be a good fit for AppSync.

Should you be providing a GraphQL API instead of a REST API? This is a choice best made with your team while considering exactly what you are trying to achieve.

A GraphQL API greatly simplifies requesting many different entities from your API at the same time. If you are building a complex web application and want to make it quick and responsive both at load time and during normal operation, then GraphQL may be a good choice. At the same time, GraphQL is quite different from the REST model, has its own tooling, and requires something of a paradigm shift when building a GraphQL API instead of a REST API for the first time.

How does AppSync integrate with other AWS services?

The native data-source integrations provided with AppSync are:

  • AWS Lambda functions: map a Lambda function to a GraphQL resolver.
  • DynamoDB tables: supply data from a DynamoDB table to the GraphQL API.
  • Amazon Elastic search domains: Use an Elasticsearch domain as the data source for your GraphQL queries.
  • AWS RDS: Connect to SQL and NoSQL database instances available within RDS, and use databases and tables from that service as data sources.

AppSync also supports a number of authentication integrations:

  • AWS Cognito User Pools: Implement an authentication and authorization mechanism for your GraphQL API in AppSync.
  • AWS IAM: Manage API access by creating IAM users.
  • OpenID Connect: authenticate API users using the OpenID identity service.

In addition to these integrations, many other integrations are possible by implementing them within an AWS Lambda function and using Lambda’s own integration to connect to it from AppSync.

AWS AppSync pricing

The AWS free tier includes 250,000 GraphQL queries or data modifications, plus 250,000 real-time updates and 600,000 connection minutes during the first 12 months after your AWS account is created.

Latest

SENTRY integration in your React Native App for Error/Crash tracking

Sentry captures data by using an SDK within your...

Recall the concepts of useCallback.

useCallback hook is one of the best hooks offered...

Value of Comments in the code!!

During my journey of Software Development, I am always...

YOLO:Bullet Paced Algorithm

http://sh017.hostgator.tempwebhost.net/media/33949d0e61af4b50f374c534713f56b3 According to world health organization, more than 1.35 million...

Featured

Developing Enterprise Application in Node.js – CJS Vs ESM

Node.js is a popular runtime environment for building server-side...

Integrating your web react applications with their React Native(android and IOS) apps using QR code

Integrating a web application with Android and iOS apps...

YOLO: Bullet Paced Algorithm – popular choice for object detection in autonomous vehicles 

According to world health organization, more than 1.35 million...

LEAVE A REPLY

Please enter your comment!
Please enter your name here