class Schema
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.AppSync.Schema |
![]() | software.amazon.awscdk.services.appsync.Schema |
![]() | aws_cdk.aws_appsync.Schema |
![]() | @aws-cdk/aws-appsync » Schema |
The Schema for a GraphQL Api.
If no options are configured, schema will be generated code-first.
Example
const api = new appsync.GraphqlApi(this, 'api', {
name: 'api',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'schema.graphql')),
});
const httpDs = api.addHttpDataSource(
'ds',
'https://states.amazonaws.com',
{
name: 'httpDsWithStepF',
description: 'from appsync to StepFunctions Workflow',
authorizationConfig: {
signingRegion: 'us-east-1',
signingServiceName: 'states',
}
}
);
httpDs.createResolver({
typeName: 'Mutation',
fieldName: 'callStepFunction',
requestMappingTemplate: appsync.MappingTemplate.fromFile('request.vtl'),
responseMappingTemplate: appsync.MappingTemplate.fromFile('response.vtl'),
});
Initializer
new Schema(options?: SchemaOptions)
Parameters
- options
Schema
Options
Properties
Name | Type | Description |
---|---|---|
definition | string | The definition for this schema. |
definition
Type:
string
The definition for this schema.
Methods
Name | Description |
---|---|
add | Add a mutation field to the schema's Mutation. CDK will create an Object Type called 'Mutation'. For example,. |
add | Add a query field to the schema's Query. CDK will create an Object Type called 'Query'. For example,. |
add | Add a subscription field to the schema's Subscription. CDK will create an Object Type called 'Subscription'. For example,. |
add | Escape hatch to add to Schema as desired. |
add | Add type to the schema. |
bind(api) | Called when the GraphQL Api is initialized to allow this object to bind to the stack. |
static from | Generate a Schema from file. |
addMutation(fieldName, field)
public addMutation(fieldName: string, field: ResolvableField): ObjectType
Parameters
- fieldName
string
— the name of the Mutation. - field
Resolvable
— the resolvable field to for this Mutation.Field
Returns
Add a mutation field to the schema's Mutation. CDK will create an Object Type called 'Mutation'. For example,.
type Mutation { fieldName: Field.returnType }
addQuery(fieldName, field)
public addQuery(fieldName: string, field: ResolvableField): ObjectType
Parameters
- fieldName
string
— the name of the query. - field
Resolvable
— the resolvable field to for this query.Field
Returns
Add a query field to the schema's Query. CDK will create an Object Type called 'Query'. For example,.
type Query { fieldName: Field.returnType }
addSubscription(fieldName, field)
public addSubscription(fieldName: string, field: Field): ObjectType
Parameters
- fieldName
string
— the name of the Subscription. - field
Field
— the resolvable field to for this Subscription.
Returns
Add a subscription field to the schema's Subscription. CDK will create an Object Type called 'Subscription'. For example,.
type Subscription { fieldName: Field.returnType }
addToSchema(addition, delimiter?)
public addToSchema(addition: string, delimiter?: string): void
Parameters
- addition
string
— the addition to add to schema. - delimiter
string
— the delimiter between schema and addition.
Escape hatch to add to Schema as desired.
Will always result in a newline.
addType(type)
public addType(type: IIntermediateType): IIntermediateType
Parameters
- type
IIntermediate
— the intermediate type to add to the schema.Type
Returns
Add type to the schema.
bind(api)
public bind(api: GraphqlApi): CfnGraphQLSchema
Parameters
- api
Graphql
— The binding GraphQL Api.Api
Returns
Called when the GraphQL Api is initialized to allow this object to bind to the stack.
static fromAsset(filePath)
public static fromAsset(filePath: string): Schema
Parameters
- filePath
string
— the file path of the schema file.
Returns
Generate a Schema from file.