aws-cdk-lib.aws_appsync.SchemaFile

class SchemaFile

LanguageType name
.NETAmazon.CDK.AWS.AppSync.SchemaFile
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsappsync#SchemaFile
Javasoftware.amazon.awscdk.services.appsync.SchemaFile
Pythonaws_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

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 SchemaProps

Properties

NameTypeDescription
definitionstringThe definition for this schema.

definition

Type: string

The definition for this schema.

Methods

NameDescription
bind(api, _options?)Called when the GraphQL Api is initialized to allow this object to bind to the stack.
static fromAsset(filePath)Generate a Schema from file.

bind(api, _options?)

public bind(api: IGraphqlApi, _options?: SchemaBindOptions): ISchemaConfig

Parameters

  • api IGraphqlApi — The binding GraphQL Api.
  • _options SchemaBindOptions

Returns

  • ISchemaConfig

Called when the GraphQL Api is initialized to allow this object to bind to the stack.


static fromAsset(filePath)

public static fromAsset(filePath: string): SchemaFile

Parameters

  • filePath string — the file path of the schema file.

Returns

  • SchemaFile

Generate a Schema from file.