class AttributeValues
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.AppSync.AttributeValues |
![]() | software.amazon.awscdk.services.appsync.AttributeValues |
![]() | aws_cdk.aws_appsync.AttributeValues |
![]() | @aws-cdk/aws-appsync » AttributeValues |
Specifies the attribute value assignments.
Example
const api = new appsync.GraphqlApi(this, 'Api', {
name: 'demo',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'schema.graphql')),
authorizationConfig: {
defaultAuthorization: {
authorizationType: appsync.AuthorizationType.IAM,
},
},
xrayEnabled: true,
});
const demoTable = new dynamodb.Table(this, 'DemoTable', {
partitionKey: {
name: 'id',
type: dynamodb.AttributeType.STRING,
},
});
const demoDS = api.addDynamoDbDataSource('demoDataSource', demoTable);
// Resolver for the Query "getDemos" that scans the DynamoDb table and returns the entire list.
demoDS.createResolver({
typeName: 'Query',
fieldName: 'getDemos',
requestMappingTemplate: appsync.MappingTemplate.dynamoDbScanTable(),
responseMappingTemplate: appsync.MappingTemplate.dynamoDbResultList(),
});
// Resolver for the Mutation "addDemo" that puts the item into the DynamoDb table.
demoDS.createResolver({
typeName: 'Mutation',
fieldName: 'addDemo',
requestMappingTemplate: appsync.MappingTemplate.dynamoDbPutItem(
appsync.PrimaryKey.partition('id').auto(),
appsync.Values.projecting('input'),
),
responseMappingTemplate: appsync.MappingTemplate.dynamoDbResultItem(),
});
Initializer
new AttributeValues(container: string, assignments?: Assign[])
Parameters
- container
string
- assignments
Assign
[]
Methods
Name | Description |
---|---|
attribute(attr) | Allows assigning a value to the specified attribute. |
render | Renders the attribute value assingments to a VTL string. |
render | Renders the variables required for renderTemplate . |
attribute(attr)
public attribute(attr: string): AttributeValuesStep
Parameters
- attr
string
Returns
Allows assigning a value to the specified attribute.
Template()
renderpublic renderTemplate(): string
Returns
string
Renders the attribute value assingments to a VTL string.
Variables()
renderpublic renderVariables(): string
Returns
string
Renders the variables required for renderTemplate
.