SchemaFile
- class aws_cdk.aws_appsync.SchemaFile(*, file_path)
Bases:
object
The Schema for a GraphQL Api.
If no options are configured, schema will be generated code-first.
- ExampleMetadata:
infused
Example:
import aws_cdk.aws_certificatemanager as acm import aws_cdk.aws_route53 as route53 # hosted zone and route53 features # hosted_zone_id: str zone_name = "example.com" my_domain_name = "api.example.com" certificate = acm.Certificate(self, "cert", domain_name=my_domain_name) schema = appsync.SchemaFile(file_path="mySchemaFile") api = appsync.GraphqlApi(self, "api", name="myApi", definition=appsync.Definition.from_schema(schema), domain_name=appsync.DomainOptions( certificate=certificate, domain_name=my_domain_name ) ) # hosted zone for adding appsync domain zone = route53.HostedZone.from_hosted_zone_attributes(self, "HostedZone", hosted_zone_id=hosted_zone_id, zone_name=zone_name ) # create a cname to the appsync domain. will map to something like xxxx.cloudfront.net route53.CnameRecord(self, "CnameApiRecord", record_name="api", zone=zone, domain_name=api.app_sync_domain_name )
- Parameters:
file_path (
str
) – The file path for the schema. When this option is configured, then the schema will be generated from an existing file from disk.
Methods
- bind(api)
Called when the GraphQL Api is initialized to allow this object to bind to the stack.
- Parameters:
api (
IGraphqlApi
) – The binding GraphQL Api.- Return type:
Attributes
- definition
The definition for this schema.
Static Methods
- classmethod from_asset(file_path)
Generate a Schema from file.
- Parameters:
file_path (
str
) – the file path of the schema file.- Return type:
- Returns:
SchemaAsset
with immutable schema defintion