AppSync Flashcards
What is AppSync?
AWS AppSync is a fully managed GraphQL service that simplifies application data delivery by handling real-time updates, offline access, and data synchronization. Consider an e-commerce platform with multiple clients (web, mobile) requiring consistent product inventory and user information in a real-world scenario.
What is a resolver in AppSync?
Types of Resolvers:
Query Resolver: Handles GraphQL queries and retrieves data from the data source.
Mutation Resolver: Manages updates or changes to the data source based on GraphQL mutations.
Subscription Resolver: Controls how data changes are pushed to clients in real-time when they subscribe to specific events.
Resolver Mapping Template:
Resolvers use a mapping template, written in Apache Velocity Template Language (VTL), to define how the GraphQL request and response should be mapped to and from the data source.
The mapping template specifies how to interact with the data source, perform queries or mutations, and shape the data for the GraphQL response.
Data Source Integration:
Resolvers are associated with a specific data source, such as Amazon DynamoDB, AWS Lambda, or an HTTP endpoint.
Depending on the data source type, the resolver’s mapping template will include instructions on how to interact with that data source.
Pipeline Resolvers:
AppSync supports pipeline resolvers, which allow you to chain multiple resolvers together to perform complex operations.
Each function in the pipeline can manipulate the data or execute specific logic before passing it to the next function.
Authorization and Security:
Resolvers play a role in enforcing security and authorization rules defined in the GraphQL schema.
You can specify who can access certain operations based on authentication and authorization settings in your resolver configuration.
Caching:
AppSync provides caching mechanisms to improve performance. Resolvers can be configured to use caching strategies, and you can control how the cache is invalidated or updated.
What is the offline access in AppSync?
AWS AppSync also provides features for offline support. Clients can continue interacting with the app and receive real-time updates even when temporarily disconnected from the network. Once the connection is reestablished, changes are synchronized.
What is the real-time subscription in Appsync?
GraphQL Subscriptions: GraphQL supports real-time data updates through a feature called subscriptions. With subscriptions, clients can subscribe to specific events or changes in the data, and the server will push updates to the subscribed clients when those events occur.
AppSync Real-time Capabilities: AWS AppSync uses WebSocket connections to provide real-time capabilities. When a client subscribes to a particular event or data, the AppSync service establishes a WebSocket connection with the client. When there are updates to the subscribed data, the server can push those updates over the WebSocket connection to the client, enabling real-time communication.
Security and Authorization in Appsync
AppSync ensures that real-time updates are secure and adhere to the defined authorization rules. It uses AWS Identity and Access Management (IAM) and Amazon Cognito for authentication and authorization.
How many data sources can Appsync connect to as compared to RestAPI?
AppSync supports multiple data sources like AWS Lambda, DynamoDB, or any HTTP data source, whereas API Gateway primarily integrates with Lambda and other AWS services.
What is the difference between AppSync and RestAPI in terms of real-time updates?
AppSync provides real-time updates through subscriptions, enabling clients to receive data changes instantly. API Gateway lacks this feature.
What is the difference between AppSync and RestAPI in terms of off-offline updates?
AppSync offers built-in offline support for mobile and web applications, allowing users to interact with apps even without connectivity. API Gateway doesn’t provide offline capabilities.
What is the difference between AppSync and RestAPI in terms of Schema definition?
AppSync uses GraphQL schema to define the structure of API requests and responses, offering flexibility in querying data. API Gateway relies on predefined REST endpoints.
Fine-grained access control in AppSync?
AppSync allows granular control over data access using AWS Identity and Access Management (IAM), Amazon Cognito, or OpenID Connect. API Gateway mainly uses IAM and custom authorizers