package awsappsync import ( _init_ "github.com/aws/aws-cdk-go/awscdk/v2/jsii" _jsii_ "github.com/aws/jsii-runtime-go/runtime" "github.com/aws/aws-cdk-go/awscdk/v2/awsiam" "github.com/aws/constructs-go/constructs/v10" ) // An AppSync datasource backed by a DynamoDB table. // // Example: // api := appsync.NewGraphqlApi(this, jsii.String("Api"), &GraphqlApiProps{ // Name: jsii.String("demo"), // Schema: appsync.SchemaFile_FromAsset(path.join(__dirname, jsii.String("schema.graphql"))), // AuthorizationConfig: &AuthorizationConfig{ // DefaultAuthorization: &AuthorizationMode{ // AuthorizationType: appsync.AuthorizationType_IAM, // }, // }, // XrayEnabled: jsii.Boolean(true), // }) // // demoTable := dynamodb.NewTable(this, jsii.String("DemoTable"), &TableProps{ // PartitionKey: &Attribute{ // Name: jsii.String("id"), // Type: dynamodb.AttributeType_STRING, // }, // }) // // demoDS := api.AddDynamoDbDataSource(jsii.String("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(jsii.String("QueryGetDemosResolver"), &BaseResolverProps{ // TypeName: jsii.String("Query"), // FieldName: jsii.String("getDemos"), // RequestMappingTemplate: appsync.MappingTemplate_DynamoDbScanTable(), // ResponseMappingTemplate: appsync.MappingTemplate_DynamoDbResultList(), // }) // // // Resolver for the Mutation "addDemo" that puts the item into the DynamoDb table. // demoDS.CreateResolver(jsii.String("MutationAddDemoResolver"), &BaseResolverProps{ // TypeName: jsii.String("Mutation"), // FieldName: jsii.String("addDemo"), // RequestMappingTemplate: appsync.MappingTemplate_DynamoDbPutItem(appsync.PrimaryKey_Partition(jsii.String("id")).Auto(), appsync.Values_Projecting(jsii.String("input"))), // ResponseMappingTemplate: appsync.MappingTemplate_DynamoDbResultItem(), // }) // // //To enable DynamoDB read consistency with the `MappingTemplate`: // demoDS.CreateResolver(jsii.String("QueryGetDemosConsistentResolver"), &BaseResolverProps{ // TypeName: jsii.String("Query"), // FieldName: jsii.String("getDemosConsistent"), // RequestMappingTemplate: appsync.MappingTemplate_*DynamoDbScanTable(jsii.Boolean(true)), // ResponseMappingTemplate: appsync.MappingTemplate_*DynamoDbResultList(), // }) // type DynamoDbDataSource interface { BackedDataSource Api() IGraphqlApi SetApi(val IGraphqlApi) // the underlying CFN data source resource. Ds() CfnDataSource // the principal of the data source to be IGrantable. GrantPrincipal() awsiam.IPrincipal // the name of the data source. Name() *string // The tree node. Node() constructs.Node ServiceRole() awsiam.IRole SetServiceRole(val awsiam.IRole) // creates a new appsync function for this datasource and API using the given properties. CreateFunction(id *string, props *BaseAppsyncFunctionProps) AppsyncFunction // creates a new resolver for this datasource and API using the given properties. CreateResolver(id *string, props *BaseResolverProps) Resolver // Returns a string representation of this construct. ToString() *string } // The jsii proxy struct for DynamoDbDataSource type jsiiProxy_DynamoDbDataSource struct { jsiiProxy_BackedDataSource } func (j *jsiiProxy_DynamoDbDataSource) Api() IGraphqlApi { var returns IGraphqlApi _jsii_.Get( j, "api", &returns, ) return returns } func (j *jsiiProxy_DynamoDbDataSource) Ds() CfnDataSource { var returns CfnDataSource _jsii_.Get( j, "ds", &returns, ) return returns } func (j *jsiiProxy_DynamoDbDataSource) GrantPrincipal() awsiam.IPrincipal { var returns awsiam.IPrincipal _jsii_.Get( j, "grantPrincipal", &returns, ) return returns } func (j *jsiiProxy_DynamoDbDataSource) Name() *string { var returns *string _jsii_.Get( j, "name", &returns, ) return returns } func (j *jsiiProxy_DynamoDbDataSource) Node() constructs.Node { var returns constructs.Node _jsii_.Get( j, "node", &returns, ) return returns } func (j *jsiiProxy_DynamoDbDataSource) ServiceRole() awsiam.IRole { var returns awsiam.IRole _jsii_.Get( j, "serviceRole", &returns, ) return returns } func NewDynamoDbDataSource(scope constructs.Construct, id *string, props *DynamoDbDataSourceProps) DynamoDbDataSource { _init_.Initialize() if err := validateNewDynamoDbDataSourceParameters(scope, id, props); err != nil { panic(err) } j := jsiiProxy_DynamoDbDataSource{} _jsii_.Create( "aws-cdk-lib.aws_appsync.DynamoDbDataSource", []interface{}{scope, id, props}, &j, ) return &j } func NewDynamoDbDataSource_Override(d DynamoDbDataSource, scope constructs.Construct, id *string, props *DynamoDbDataSourceProps) { _init_.Initialize() _jsii_.Create( "aws-cdk-lib.aws_appsync.DynamoDbDataSource", []interface{}{scope, id, props}, d, ) } func (j *jsiiProxy_DynamoDbDataSource)SetApi(val IGraphqlApi) { if err := j.validateSetApiParameters(val); err != nil { panic(err) } _jsii_.Set( j, "api", val, ) } func (j *jsiiProxy_DynamoDbDataSource)SetServiceRole(val awsiam.IRole) { _jsii_.Set( j, "serviceRole", val, ) } // Checks if `x` is a construct. // // Use this method instead of `instanceof` to properly detect `Construct` // instances, even when the construct library is symlinked. // // Explanation: in JavaScript, multiple copies of the `constructs` library on // disk are seen as independent, completely different libraries. As a // consequence, the class `Construct` in each copy of the `constructs` library // is seen as a different class, and an instance of one class will not test as // `instanceof` the other class. `npm install` will not create installations // like this, but users may manually symlink construct libraries together or // use a monorepo tool: in those cases, multiple copies of the `constructs` // library can be accidentally installed, and `instanceof` will behave // unpredictably. It is safest to avoid using `instanceof`, and using // this type-testing method instead. // // Returns: true if `x` is an object created from a class which extends `Construct`. func DynamoDbDataSource_IsConstruct(x interface{}) *bool { _init_.Initialize() if err := validateDynamoDbDataSource_IsConstructParameters(x); err != nil { panic(err) } var returns *bool _jsii_.StaticInvoke( "aws-cdk-lib.aws_appsync.DynamoDbDataSource", "isConstruct", []interface{}{x}, &returns, ) return returns } func (d *jsiiProxy_DynamoDbDataSource) CreateFunction(id *string, props *BaseAppsyncFunctionProps) AppsyncFunction { if err := d.validateCreateFunctionParameters(id, props); err != nil { panic(err) } var returns AppsyncFunction _jsii_.Invoke( d, "createFunction", []interface{}{id, props}, &returns, ) return returns } func (d *jsiiProxy_DynamoDbDataSource) CreateResolver(id *string, props *BaseResolverProps) Resolver { if err := d.validateCreateResolverParameters(id, props); err != nil { panic(err) } var returns Resolver _jsii_.Invoke( d, "createResolver", []interface{}{id, props}, &returns, ) return returns } func (d *jsiiProxy_DynamoDbDataSource) ToString() *string { var returns *string _jsii_.Invoke( d, "toString", nil, // no parameters &returns, ) return returns }