@Generated(value="jsii-pacmak/1.70.0 (build 03c2f6f)", date="2022-11-01T13:16:42.877Z") @Stability(value=Experimental) public class PrimaryKey extends software.amazon.jsii.JsiiObject
It either contains the full primary key or only the partition key.
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 | Constructor and Description |
|---|---|
|
PrimaryKey(Assign pkey) |
|
PrimaryKey(Assign pkey,
Assign skey) |
protected |
PrimaryKey(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
PrimaryKey(software.amazon.jsii.JsiiObjectRef objRef) |
| Modifier and Type | Method and Description |
|---|---|
protected Assign |
getPkey() |
static PartitionKeyStep |
partition(String key)
(experimental) Allows assigning a value to the partition key.
|
String |
renderTemplate()
(experimental) Renders the key assignment to a VTL string.
|
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetprotected PrimaryKey(software.amazon.jsii.JsiiObjectRef objRef)
protected PrimaryKey(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Experimental)
public PrimaryKey(@NotNull
Assign pkey,
@Nullable
Assign skey)
pkey - This parameter is required.skey - @Stability(value=Experimental)
public PrimaryKey(@NotNull
Assign pkey)
pkey - This parameter is required.@Stability(value=Experimental) @NotNull public static PartitionKeyStep partition(@NotNull String key)
key - This parameter is required.@Stability(value=Experimental) @NotNull public String renderTemplate()
@Stability(value=Experimental) @NotNull protected Assign getPkey()
Copyright © 2022. All rights reserved.