@Generated(value="jsii-pacmak/1.63.2 (build a8a8833)", date="2022-08-09T19:16:45.577Z") public class DynamoDbDataSource extends BackedDataSource
Example:
GraphqlApi api = GraphqlApi.Builder.create(this, "Api") .name("demo") .schema(Schema.fromAsset(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. demoDS.createResolver(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(BaseResolverProps.builder() .typeName("Mutation") .fieldName("addDemo") .requestMappingTemplate(MappingTemplate.dynamoDbPutItem(PrimaryKey.partition("id").auto(), Values.projecting("input"))) .responseMappingTemplate(MappingTemplate.dynamoDbResultItem()) .build());
Modifier and Type | Class and Description |
---|---|
static class |
DynamoDbDataSource.Builder
(experimental) A fluent builder for
DynamoDbDataSource . |
IGrantable.Jsii$Default
IConstruct.Jsii$Default
Modifier | Constructor and Description |
---|---|
protected |
DynamoDbDataSource(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
DynamoDbDataSource(software.amazon.jsii.JsiiObjectRef objRef) |
|
DynamoDbDataSource(software.constructs.Construct scope,
java.lang.String id,
DynamoDbDataSourceProps props) |
getGrantPrincipal
createFunction, createResolver, getApi, getDs, getName, getServiceRole, setApi, setServiceRole
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate
protected DynamoDbDataSource(software.amazon.jsii.JsiiObjectRef objRef)
protected DynamoDbDataSource(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
public DynamoDbDataSource(software.constructs.Construct scope, java.lang.String id, DynamoDbDataSourceProps props)
scope
- This parameter is required.id
- This parameter is required.props
- This parameter is required.