AWS AppSync FAQs
AppSync GraphQL
Do I need to know GraphQL to get started?
No, AWS AppSync can automatically setup your entire API, schema, and connect data sources with a simple UI builder that allows you to type in your data model in seconds. You can then immediately begin using the endpoint in a client application. The console also provides many sample schema and data sources for fully functioning applications.
What type of data sources can I use with AWS AppSync?
You can use AWS AppSync with new or existing AWS resources, like tables, functions, and domains from Amazon DynamoDB, AWS Lambda and Amazon OpenSearch Service with a GraphQL schema. You can also connect to any data sources and services that provide an HTTP API. AWS AppSync allows you configure the interactions with your resolvers written in JavaScript.
How do I write my AWS AppSync business logic?
GraphQL requests execute as "resolvers" and need to be converted into the appropriate message format for the different AWS Services that AWS AppSync integrates. For example, a GraphQL query on a field will need to be converted into a unique format for Amazon DynamoDB, AWS Lambda, and Amazon OpenSearch Service respectively. AWS AppSync allows you to write the custom logic for your resolvers using JavaScript, and to execute your code on a custom AppSync JavaScript runtime. This allows you to define how an incoming request should be transformed to interact with your data sources, and how responses from your data sources should be mapped back into a GraphQL response.
How do I verify the behavior of my JavaScript code?
You can verify the behavior of your code directly from the console. From the console, you can use mock data to test the evaluation of your resolvers without interacting with your data sources. AppSync also provides remote APIs that you can use to evaluate your JavaScript code with mock data. You can leverage these APIs from the AWS CLI or the AWS SDKs. This allows you to evaluate your resolvers inside your favorite test framework and to run unit tests. You can also use the console’s query editor to test GraphQL queries, mutations, and subscriptions and live stream log data for each request in realtime.
Should I use JavaScript resolvers to access my data sources directly? Or should I use a Lambda data source to handle my business logic?
With JavaScript resolvers, you can write your own code, that implements your custom business logic to access your data sources. This makes it easy for you to directly interact with data sources like Amazon DynamoDB, Amazon Aurora Serverless, Amazon OpenSearch Service, HTTP APIs, and other AWS services, without having to deploy additional compute services or infrastructure. AWS AppSync also makes it easy to interact with an AWS Lambda function by configuring a Lambda data source. Lambda data sources allow you to run complex business logic using AWS Lambda’s full set capabilities to resolve a GraphQL request. In most cases, an AppSync function directly connected to its target data source will provide all of the functionality you need. In situations where you need to implement complex business logic that is not supported by the JavaScript resolvers, you can use a Lambda data source as a proxy to interact with your target data source.
Does AWS AppSync support API federation?
Yes, API federation is supported in AWS AppSync via the Merged APIs feature. A Merged API is a single GraphQL API composed from multiple source GraphQL APIs, representing different services or data sources. With a Merged API an organization can provide a single API schema to data consumers, while enabling independent evolution of sub-schemas by the teams that are most familiar with its related data domain. For teams sharing development of a single AppSync API, the Merged APIs feature allows them to collaborate seamlessly while operating independently.
Can I use AWS AppSync with my existing AWS resources?
Yes. With AWS AppSync you can use existing tables, functions, and domains from Amazon DynamoDB, AWS Lambda and Amazon OpenSearch Service with a GraphQL schema. AWS AppSync allows you to create data sources using existing AWS resources and configure the interactions using Mapping Templates.
How is data secured with AWS AppSync?
Application data is stored at rest in your AWS account and not in the AWS AppSync service. You can protect access to this data from applications by using security controls with AWS AppSync including AWS Identity and Access Management (IAM), as well as Amazon Cognito User Pools. Additionally, user context can be passed through for authenticated requests so that you can perform fine-grained access control logic against your resources with Mapping Templates in AWS AppSync.
Can I make my data real-time with AWS AppSync?
Yes. Subscriptions are supported with AWS AppSync against any of the data sources, so that when a mutation occurs, the results can be passed down to clients subscribing to the event stream immediately using over WebSockets.
How can I do complex queries with AWS AppSync?
The data sources available to AWS AppSync allow you to take full advantage of capabilities provided by Amazon DynamoDB, Amazon OpenSearch Service, and AWS Lambda when using GraphQL. Features such as indexing and conditional checks, return comprehensive results from DynamoDB. Use cases such as fuzzy searches, geo searches and more that Amazon OpenSearch Service offers are available to your application. Finally, Lambda can be used for serial or batched requests to return data from other sources such as Amazon Aurora.
What AWS Regions are available for AWS AppSync?
AWS AppSync is available in different regions around the globe, please refer to the AWS Regions table for more details.
Can I import existing Amazon DynamoDB tables?
AWS AppSync can automatically generate a GraphQL schema from an existing DynamoDB table, including the inference of your table’s key schema and indexes. Once the import is complete GraphQL queries, mutations, and subscriptions can be used with zero coding. AppSync will also “auto-map” non-key attributes from your GraphQL types to DynamoDB attributes.
Can AWS AppSync create a database for me?
Customers can create a GraphQL schema, either by hand or using the console, and AWS AppSync can automatically provision Amazon DynamoDB tables and appropriate indexes for you. Additionally, it will connect the data sources to "GraphQL resolvers" allowing you to just focus on your application code and data structures.
What clients can I use to connect my application to my AppSync API?
You can use any HTTP or GraphQL client to connect to a GraphQL API on AppSync. We do recommend using the Amplify clients which are optimized to connect to the AppSync backend. There are some options depending on your application's use case:
- For DynamoDB data sources, use the DataStore category in the Amplify client. It provides the best developer experience and built-in conflict detection and resolution.
- For non-DynamoDB data sources in scenarios where you have no offline requirements, use the API (GraphQL) category in the Amplify client.
- For non-DynamoDB data sources in scenarios where you have offline requirements, use the AppSync SDK.
Can I use my own domain name to access my AppSync GraphQL endpoint?
AWS AppSync enables customers to use custom domain names with their AWS AppSync API to access their GraphQl endpoint and real-time endpoint. To create a custom domain name in AppSync, you simply provide a domain name you own and indicate a valid AWS Certificate Manager (ACM) certificate that covers your domain. Once the custom domain name is created, you can associate the domain name with any available AppSync API in your account. After you have updated your DNS record to map to to the AppSync-provided domain name, you can configure your applications to use the new GraphQL and real-time endpoints. You can change the API association on your custom domain at any time without having to update your applications. When AppSync receives a request on the custom domain endpoint, it routes it to the associated API for handling.
Can I create private APIs with AppSync?
Yes, AWS AppSync supports private APIs. With private APIs, you can create GraphQL APIs that can only be accessed from your Amazon Virtual Private Cloud (VPC).
AppSync Events
What is an event?
An "event" is a data record expressing an occurrence and its context. Events are routed from an event producer (the source) to interested event consumers. AppSync Events gives developers the ability to publish events using the HTTP protocol and JSON format. Subscribing is done over WebSocket channels.
What is a channel?
A channel is a routing concept. It is the logical destination of an event. It allows a publisher to say: “this is where my event should be routed.” It allows a subscriber to say: “this is the route that I want to monitor for arriving events”.
What is a namespace?
A namespace is a logical construct that is used to define capabilities shared by channels that live within it. For example, you can define multiple authorization modes for your Event API, then attach specific modes on your namespaces (e.g.: only allow IAM_AUTH mode on namespace /chat).
I need to transform my events when they are published. Is that possible?
Yes. Simply attach an Event Handler that specifies an onPublish function. In that handler, implement your transformation logic.
What is an Event Handler?
Event Handlers allow you to define the runtime behavior of your API. Event Handlers are optional and provide logic that is executed in response to system events.
You can attach Event Handlers to your existing namespaces. The onSubscribe handler is called any time a client subscribes to a channel in the namespace. You can authorize the subscription, and apply filters. The onPublish handler is called for events published to your channels in the namespace. You can transform the event before it is forwarded to subscribed clients. In your onPublish handler, you can drop messages by simply returning null.
Learn more about AWS AppSync Customers
- Select