Getting Started With AWS AppSync

AWS AppSync Sep 18, 2020

AWS AppSync uses GraphQL to create flexible API to secure access and manipulate data.

AWS AppSync stays in between client app instance and AWS web services, so let's AWS web service AWS DynamoDB, AWS Aurora, AWS Elasticsearch like so are connected using AppSync.

Here is the official diagram of how AppSync works. On the left side of the diagram there are client applications and on right there are AWS web service and in middle of both AWS AppSync is there which acts like Facilitator.

Benefits of using AWS AppSync

  1. Fast setup
  2. Real-time subscription and offline access
  3. Secure access

In order to make our instance secure we can add authentication using AWS Cognito . let's see how we can set AppSync for our client instance

Prerequisites

  1. AWS account
  2. GraphQL basic understanding

Setup

let's jump into little bit of getting started with AWS AppSync here.

This is how the main AWS AppSync looks like. you can find it by searching for AWS AppSync in AWS console.

This is the basic default schema that is created by AWS AppSync. In the left there are 7 options available. let's understand important options

  1. Schema: For changing schema
  2. Data Sources: List of AWS DynamoDB tables that are created on creating resource
  3. Functions: For embedding AWS Lambda functions
  4. Queries: For accessing GraphQL queries that are created by AWS AppSync according to schema
  5. Settings: In this section there are API details, authentication mode, logging option etc

After updating schema click on > Save Schema > Create Resource. While creating resource you will be asked for two option Define new type and Use existing type select Use existing type this will show list of GraphQL type that were added in schema. The create resource screen will have list of pre-built GraphQL query, mutation, subscription and other method for selected schema type. On clicking Create button AWS AppSync will build AWS DynamoDB table.

Also you can test you GraphQL api from Queries section.

Above GraphQL api are not secure as authentication is not added. you can add authentication from Settings section and choose any of the given option

To use AWS Cognito user pool we must have to create pool. if you don't know how to create user pool refer below documentation

https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools.html

After setting up cognito user in Settings section when to go Queries Section you will see authorization provider as Amazon Cognito Pool which means that now all GraphQL endpoints are secured.

So, this is the most basic flow to get started with AWS AppSync. To use AWS AppSync offline you can use AWS Amplify which have some more concepts and different setup.

To learn more about AppSync security, please check our documentation. To get started with building applications and APIs with Amplify, refer to the Amplify Framework documentation. It provides a CLI, libraries and the GraphQL Transform that you can use to get started with developing critical security functionality in your application.

Tags

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.