Class DynamoDbDataSource
java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.services.appsync.BaseDataSource
software.amazon.awscdk.services.appsync.BackedDataSource
software.amazon.awscdk.services.appsync.DynamoDbDataSource
- All Implemented Interfaces:
IGrantable,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct,software.constructs.IDependable
@Generated(value="jsii-pacmak/1.119.0 (build 1634eac)",
date="2025-12-01T16:02:14.480Z")
@Stability(Stable)
public class DynamoDbDataSource
extends BackedDataSource
An AppSync datasource backed by a DynamoDB table.
Example:
GraphqlApi api = GraphqlApi.Builder.create(this, "Api")
.name("demo")
.definition(Definition.fromFile(join(__dirname, "schema.graphql")))
.authorizationConfig(AuthorizationConfig.builder()
.defaultAuthorization(AuthorizationMode.builder()
.authorizationType(AuthorizationType.IAM)
.build())
.build())
.xrayEnabled(true)
.build();
Table demoTable = Table.Builder.create(this, "DemoTable")
.partitionKey(Attribute.builder()
.name("id")
.type(AttributeType.STRING)
.build())
.build();
DynamoDbDataSource demoDS = api.addDynamoDbDataSource("demoDataSource", demoTable);
// Resolver for the Query "getDemos" that scans the DynamoDb table and returns the entire list.
// Resolver Mapping Template Reference:
// https://docs.aws.amazon.com/appsync/latest/devguide/resolver-mapping-template-reference-dynamodb.html
demoDS.createResolver("QueryGetDemosResolver", BaseResolverProps.builder()
.typeName("Query")
.fieldName("getDemos")
.requestMappingTemplate(MappingTemplate.dynamoDbScanTable())
.responseMappingTemplate(MappingTemplate.dynamoDbResultList())
.build());
// Resolver for the Mutation "addDemo" that puts the item into the DynamoDb table.
demoDS.createResolver("MutationAddDemoResolver", BaseResolverProps.builder()
.typeName("Mutation")
.fieldName("addDemo")
.requestMappingTemplate(MappingTemplate.dynamoDbPutItem(PrimaryKey.partition("id").auto(), Values.projecting("input")))
.responseMappingTemplate(MappingTemplate.dynamoDbResultItem())
.build());
//To enable DynamoDB read consistency with the `MappingTemplate`:
demoDS.createResolver("QueryGetDemosConsistentResolver", BaseResolverProps.builder()
.typeName("Query")
.fieldName("getDemosConsistent")
.requestMappingTemplate(MappingTemplate.dynamoDbScanTable(true))
.responseMappingTemplate(MappingTemplate.dynamoDbResultList())
.build());
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.services.iam.IGrantable
IGrantable.Jsii$Default -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDynamoDbDataSource(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedDynamoDbDataSource(software.amazon.jsii.JsiiObjectRef objRef) DynamoDbDataSource(software.constructs.Construct scope, String id, DynamoDbDataSourceProps props) -
Method Summary
Methods inherited from class software.amazon.awscdk.services.appsync.BackedDataSource
getGrantPrincipalMethods inherited from class software.amazon.awscdk.services.appsync.BaseDataSource
createFunction, createResolver, getApi, getDs, getName, getServiceRole, setApi, setServiceRoleMethods inherited from class software.constructs.Construct
getNode, isConstruct, toStringMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
PROPERTY_INJECTION_ID
Uniquely identifies this class.
-
-
Constructor Details
-
DynamoDbDataSource
protected DynamoDbDataSource(software.amazon.jsii.JsiiObjectRef objRef) -
DynamoDbDataSource
protected DynamoDbDataSource(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
DynamoDbDataSource
@Stability(Stable) public DynamoDbDataSource(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull DynamoDbDataSourceProps props) - Parameters:
scope- This parameter is required.id- This parameter is required.props- This parameter is required.
-