# AppSync

## Icon

![AppSync](https://icon.icepanel.io/AWS/svg/App-Integration/AppSync.svg)

## About

* It is a managed service, that helps to built `GraphQL` APIs.
* [`GraphQL`](https://graphql.org/learn/) makes it easy for application to get exactly the data they need, using `GraphQL` queries _(another way of making API)_.
* This includes combining data from one or more sources.
  * `NoSQL` data stores, Relational database, HTTP APIs.
  * It integrates with `DynamoDB`, `Aurora`, `OpenSearch` and others.
  * Custom sources can also used with AWS Lambda.
* Retrieve data in real-time with WebSocket or MQTT on Websocket.
* For mobile apps if you need local data access and data synchronization, _(its basically a replacement for `Cognito Sync`)_
* `GraphQL` schema is required to get started with `AppSync`.
* For custom domain && HTTPs, use CloudFront in front of `AppSync`.

## Working

* `AppSync` receives `GraphQL` queries send by clients and forwards it to resolver like `DynamoDb` resolver.
* `AppSync` knows how to return all the query details as per query in `json` form.

![AppSync Working](https://574639531-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJDnjsv52I3fJ56WbLgHu%2Fuploads%2Fgit-blob-4c999f4149f8b0b616515aaab5d18f4c5f42138e%2FAppSyncWorking.png?alt=media)

## Integration Diagram

*   Different integrations possible with `AppSync`.

    ![Integration](https://574639531-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJDnjsv52I3fJ56WbLgHu%2Fuploads%2Fgit-blob-0440a9696f613950676b61c679ed1c36f8e8ad4b%2FAppSyncIntegration.png?alt=media)

## Security

* There are four ways one can authorize applications to interact with your AWS `AppSync` GraphQL API.
  * `API KEY`
  * `AWS IAM` : Use roles, users, cross-account access
  * `OPENID_CONNECT` : Using OpenID connect provider/JSON Web Token
  * `AMAZON_COGNITO_USER_POOLS`
  * Lambda authorizor

## Caching

* API Responses can be cached. Three types of caching are supported.
  * No Cache
  * Full request cache
  * Per-resolver cache

## Monitoring

* `Appsync` is integrated with `CloudWatch` and captures logs and metrics.
* A dashboard capturing metrics is available.
