aws-cdk-lib.aws_appsync.SchemaFile
static from
class SchemaFile
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.AppSync.SchemaFile |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awsappsync#SchemaFile |
![]() | software.amazon.awscdk.services.appsync.SchemaFile |
![]() | aws_cdk.aws_appsync.SchemaFile |
![]() | 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
const api = new appsync.GraphqlApi(stack, 'EventBridgeApi', {
name: 'EventBridgeApi',
schema: appsync.SchemaFile.fromAsset(path.join(__dirname, 'appsync.eventbridge.graphql')),
});
const bus = new events.EventBus(stack, 'DestinationEventBus', {});
const dataSource = api.addEventBridgeDataSource('NoneDS', bus);
dataSource.createResolver('EventResolver', {
typeName: 'Mutation',
fieldName: 'emitEvent',
requestMappingTemplate: appsync.MappingTemplate.fromFile('request.vtl'),
responseMappingTemplate: appsync.MappingTemplate.fromFile('response.vtl'),
});
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.