AppSync
Reference doc for the `sst.aws.AppSync` component.
The AppSync
component lets you add an Amazon AppSync GraphQL API to your app.
Create a GraphQL API
Add a data source
Add a resolver
Constructor
Parameters
-
name
string
-
args
AppSyncArgs
-
opts?
ComponentResourceOptions
AppSyncArgs
domain?
Type Input
<
string
|
Object
>
Set a custom domain for your AppSync GraphQL API.
Automatically manages domains hosted on AWS Route 53, Cloudflare, and Vercel. For other
providers, you’ll need to pass in a cert
that validates domain ownership and add the
DNS records.
By default this assumes the domain is hosted on Route 53.
For domains hosted on Cloudflare.
domain.cert?
Type Input
<
string
>
The ARN of an ACM (AWS Certificate Manager) certificate that proves ownership of the domain. By default, a certificate is created and validated automatically.
The certificate will be created in the us-east-1
region as required by AWS AppSync.
If you are creating your own certificate, you must also create it in us-east-1
.
To manually set up a domain on an unsupported provider, you’ll need to:
- Validate that you own the domain by creating an ACM certificate. You can either validate it by setting a DNS record or by verifying an email sent to the domain owner.
- Once validated, set the certificate ARN as the
cert
and setdns
tofalse
. - Add the DNS records in your provider to point to the API Gateway URL.
domain.dns?
Type Input
<
false
|
sst.aws.dns
|
sst.cloudflare.dns
|
sst.vercel.dns
>
Default sst.aws.dns
The DNS provider to use for the domain. Defaults to the AWS.
Takes an adapter that can create the DNS records on the provider. This can automate validating the domain and setting up the DNS routing.
Supports Route 53, Cloudflare, and Vercel adapters. For other providers, you’ll need
to set dns
to false
and pass in a certificate validating ownership via cert
.
Specify the hosted zone ID for the Route 53 domain.
Use a domain hosted on Cloudflare, needs the Cloudflare provider.
Use a domain hosted on Vercel, needs the Vercel provider.
domain.name
Type Input
<
string
>
The custom domain you want to use.
Can also include subdomains based on the current stage.
schema
Type Input
<
string
>
Path to the GraphQL schema file. This path is relative to your sst.config.ts
.
transform?
Type Object
Transform how this component creates its underlying resources.
transform.api?
Type GraphQLApiArgs
|
(
args
:
GraphQLApiArgs
,
opts
:
ComponentResourceOptions
,
name
:
string
)
=>
void
Transform the AppSync GraphQL API resource.
transform.domainName?
Type DomainNameArgs
|
(
args
:
DomainNameArgs
,
opts
:
ComponentResourceOptions
,
name
:
string
)
=>
void
Transform the AppSync domain name resource.
Properties
id
Type Output
<
string
>
The GraphQL API ID.
nodes
nodes.api
Type GraphQLApi
The Amazon AppSync GraphQL API.
url
Type Output
<
string
>
The URL of the GraphQL API.
SDK
Use the SDK in your runtime to interact with your infrastructure.
Links
This is accessible through the Resource
object in the SDK.
-
url
string
The URL of the GraphQL API.
Methods
addDataSource
Parameters
- Configure the data source.
Returns AppSyncDataSource
Add a data source to this AppSync API.
Add a Lambda function as a data source.
Customize the Lambda function.
Add a data source with an existing Lambda function.
Add a DynamoDB table as a data source.
addFunction
Parameters
Configure the function.args
AppSyncFunctionArgs
Returns AppSyncFunction
Add a function to this AppSync API.
Add a function using a Lambda data source.
Add a function using a DynamoDB data source.
addResolver
Parameters
The type and name of the operation.operation
string
Configure the resolver.args
AppSyncResolverArgs
Returns AppSyncResolver
Add a resolver to this AppSync API.
Add a resolver using a Lambda data source.
Add a resolver using a DynamoDB data source.
Add a pipeline resolver.
AppSyncDataSourceArgs
dynamodb?
Type Input
<
string
>
The ARN for the DynamoDB table.
elasticSearch?
Type Input
<
string
>
The ARN for the Elasticsearch domain.
eventBridge?
Type Input
<
string
>
The ARN for the EventBridge event bus.
http?
Type Input
<
string
>
The URL for the HTTP endpoint.
lambda?
Type Input
<
string
|
FunctionArgs
|
“arn:aws:lambda:${string}”
>
The handler for the Lambda function.
You can pass in the full function props.
You can also pass in the function ARN.
name
Type string
The name of the data source.
openSearch?
Type Input
<
string
>
The ARN for the OpenSearch domain.
rds?
Type Input
<
Object
>
Configure the RDS data source.
rds.cluster
Type Input
<
string
>
The ARN for the RDS cluster.
rds.credentials
Type Input
<
string
>
The ARN for the credentials secret store.
transform?
Type Object
Transform how this component creates its underlying resources.
transform.dataSource?
Type DataSourceArgs
|
(
args
:
DataSourceArgs
,
opts
:
ComponentResourceOptions
,
name
:
string
)
=>
void
Transform the AppSync DataSource resource.
transform.serviceRole?
Type RoleArgs
|
(
args
:
RoleArgs
,
opts
:
ComponentResourceOptions
,
name
:
string
)
=>
void
Transform the AppSync DataSource service role resource.
AppSyncFunctionArgs
code?
Type Input
<
string
>
The function code that contains the request and response functions.
dataSource
Type Input
<
string
>
The data source this resolver is using.
name
Type string
The name of the AppSync function.
requestMappingTemplate?
Type Input
<
string
>
The function request mapping template.
responseMappingTemplate?
Type Input
<
string
>
The function response mapping template.
transform?
transform.function?
Type FunctionArgs
|
(
args
:
FunctionArgs
,
opts
:
ComponentResourceOptions
,
name
:
string
)
=>
void
Transform the AppSync Function resource.
AppSyncResolverArgs
code?
Type Input
<
string
>
The function code that contains the request and response functions.
dataSource?
Type Input
<
string
>
The data source this resolver is using. This only applies for unit
resolvers.
functions?
Type Input
<
string
[]
>
The functions this resolver is using. This only applies for pipeline
resolvers.
kind?
Type Input
<
“
unit
”
|
“
pipeline
”
>
Default “unit”
The type of the resolver.
requestTemplate?
Type Input
<
string
>
For unit
resolvers, this is the request mapping template. And for pipeline
resolvers, this is the before mapping template.
responseTemplate?
Type Input
<
string
>
For unit
resolvers, this is the response mapping template. And for pipeline
resolvers, this is the after mapping template.
transform?
transform.resolver?
Type ResolverArgs
|
(
args
:
ResolverArgs
,
opts
:
ComponentResourceOptions
,
name
:
string
)
=>
void
Transform the AppSync Resolver resource.