class SchemaFile
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.AppSync.SchemaFile |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsappsync#SchemaFile |
Java | software.amazon.awscdk.services.appsync.SchemaFile |
Python | aws_cdk.aws_appsync.SchemaFile |
TypeScript (source) | aws-cdk-lib » aws_appsync » SchemaFile |
Implements
ISchema
The Schema for a GraphQL Api.
If no options are configured, schema will be generated code-first.
Example
import * as acm from 'aws-cdk-lib/aws-certificatemanager';
import * as route53 from 'aws-cdk-lib/aws-route53';
const myDomainName = 'api.example.com';
const certificate = new acm.Certificate(this, 'cert', { domainName: myDomainName });
const schema = new appsync.SchemaFile({ filePath: 'mySchemaFile' })
const api = new appsync.GraphqlApi(this, 'api', {
name: 'myApi',
definition: appsync.Definition.fromSchema(schema),
domainName: {
certificate,
domainName: myDomainName,
},
});
// hosted zone and route53 features
declare const hostedZoneId: string;
declare const zoneName = 'example.com';
// hosted zone for adding appsync domain
const zone = route53.HostedZone.fromHostedZoneAttributes(this, `HostedZone`, {
hostedZoneId,
zoneName,
});
// create a cname to the appsync domain. will map to something like xxxx.cloudfront.net
new route53.CnameRecord(this, `CnameApiRecord`, {
recordName: 'api',
zone,
domainName: api.appSyncDomainName,
});
Initializer
new SchemaFile(options: SchemaProps)
Parameters
- options
Schema
Props
Properties
Name | Type | Description |
---|---|---|
definition | string | The definition for this schema. |
definition
Type:
string
The definition for this schema.
Methods
Name | Description |
---|---|
bind(api, _options?) | Called when the GraphQL Api is initialized to allow this object to bind to the stack. |
static from | Generate a Schema from file. |
bind(api, _options?)
public bind(api: IGraphqlApi, _options?: SchemaBindOptions): ISchemaConfig
Parameters
- api
IGraphql
— The binding GraphQL Api.Api - _options
Schema
Bind Options
Returns
Called when the GraphQL Api is initialized to allow this object to bind to the stack.
Asset(filePath)
static frompublic static fromAsset(filePath: string): SchemaFile
Parameters
- filePath
string
— the file path of the schema file.
Returns
Generate a Schema from file.