Show / Hide Table of Contents

Class BaseResolverProps

Basic properties for an AppSync resolver.

Inheritance
object
BaseResolverProps
Implements
IBaseResolverProps
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: Amazon.CDK.AWS.AppSync
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class BaseResolverProps : IBaseResolverProps
Syntax (vb)
Public Class BaseResolverProps Implements IBaseResolverProps
Remarks

ExampleMetadata: infused

Examples
// Build a data source for AppSync to access the database.
            GraphqlApi api;
            // Create username and password secret for DB Cluster
            var secret = new DatabaseSecret(this, "AuroraSecret", new DatabaseSecretProps {
                Username = "clusteradmin"
            });

            // The VPC to place the cluster in
            var vpc = new Vpc(this, "AuroraVpc");

            // Create the serverless cluster, provide all values needed to customise the database.
            var cluster = new ServerlessCluster(this, "AuroraCluster", new ServerlessClusterProps {
                Engine = DatabaseClusterEngine.AURORA_MYSQL,
                Vpc = vpc,
                Credentials = new Dictionary<string, string> { { "username", "clusteradmin" } },
                ClusterIdentifier = "db-endpoint-test",
                DefaultDatabaseName = "demos"
            });
            var rdsDS = api.AddRdsDataSource("rds", cluster, secret, "demos");

            // Set up a resolver for an RDS query.
            rdsDS.CreateResolver("QueryGetDemosRdsResolver", new BaseResolverProps {
                TypeName = "Query",
                FieldName = "getDemosRds",
                RequestMappingTemplate = MappingTemplate.FromString(@"
                  {
                    ""version"": ""2018-05-29"",
                    ""statements"": [
                      ""SELECT * FROM demos""
                    ]
                  }
                  "),
                ResponseMappingTemplate = MappingTemplate.FromString(@"
                    $utils.toJson($utils.rds.toJsonObject($ctx.result)[0])
                  ")
            });

            // Set up a resolver for an RDS mutation.
            rdsDS.CreateResolver("MutationAddDemoRdsResolver", new BaseResolverProps {
                TypeName = "Mutation",
                FieldName = "addDemoRds",
                RequestMappingTemplate = MappingTemplate.FromString(@"
                  {
                    ""version"": ""2018-05-29"",
                    ""statements"": [
                      ""INSERT INTO demos VALUES (:id, :version)"",
                      ""SELECT * WHERE id = :id""
                    ],
                    ""variableMap"": {
                      "":id"": $util.toJson($util.autoId()),
                      "":version"": $util.toJson($ctx.args.version)
                    }
                  }
                  "),
                ResponseMappingTemplate = MappingTemplate.FromString(@"
                    $utils.toJson($utils.rds.toJsonObject($ctx.result)[1][0])
                  ")
            });

Synopsis

Constructors

BaseResolverProps()

Basic properties for an AppSync resolver.

Properties

CachingConfig

The caching configuration for this resolver.

Code

The function code.

FieldName

name of the GraphQL field in the given type this resolver is attached to.

MaxBatchSize

The maximum number of elements per batch, when using batch invoke.

PipelineConfig

configuration of the pipeline resolver.

RequestMappingTemplate

The request mapping template for this resolver.

ResponseMappingTemplate

The response mapping template for this resolver.

Runtime

The functions runtime.

TypeName

name of the GraphQL type this resolver is attached to.

Constructors

BaseResolverProps()

Basic properties for an AppSync resolver.

public BaseResolverProps()
Remarks

ExampleMetadata: infused

Examples
// Build a data source for AppSync to access the database.
            GraphqlApi api;
            // Create username and password secret for DB Cluster
            var secret = new DatabaseSecret(this, "AuroraSecret", new DatabaseSecretProps {
                Username = "clusteradmin"
            });

            // The VPC to place the cluster in
            var vpc = new Vpc(this, "AuroraVpc");

            // Create the serverless cluster, provide all values needed to customise the database.
            var cluster = new ServerlessCluster(this, "AuroraCluster", new ServerlessClusterProps {
                Engine = DatabaseClusterEngine.AURORA_MYSQL,
                Vpc = vpc,
                Credentials = new Dictionary<string, string> { { "username", "clusteradmin" } },
                ClusterIdentifier = "db-endpoint-test",
                DefaultDatabaseName = "demos"
            });
            var rdsDS = api.AddRdsDataSource("rds", cluster, secret, "demos");

            // Set up a resolver for an RDS query.
            rdsDS.CreateResolver("QueryGetDemosRdsResolver", new BaseResolverProps {
                TypeName = "Query",
                FieldName = "getDemosRds",
                RequestMappingTemplate = MappingTemplate.FromString(@"
                  {
                    ""version"": ""2018-05-29"",
                    ""statements"": [
                      ""SELECT * FROM demos""
                    ]
                  }
                  "),
                ResponseMappingTemplate = MappingTemplate.FromString(@"
                    $utils.toJson($utils.rds.toJsonObject($ctx.result)[0])
                  ")
            });

            // Set up a resolver for an RDS mutation.
            rdsDS.CreateResolver("MutationAddDemoRdsResolver", new BaseResolverProps {
                TypeName = "Mutation",
                FieldName = "addDemoRds",
                RequestMappingTemplate = MappingTemplate.FromString(@"
                  {
                    ""version"": ""2018-05-29"",
                    ""statements"": [
                      ""INSERT INTO demos VALUES (:id, :version)"",
                      ""SELECT * WHERE id = :id""
                    ],
                    ""variableMap"": {
                      "":id"": $util.toJson($util.autoId()),
                      "":version"": $util.toJson($ctx.args.version)
                    }
                  }
                  "),
                ResponseMappingTemplate = MappingTemplate.FromString(@"
                    $utils.toJson($utils.rds.toJsonObject($ctx.result)[1][0])
                  ")
            });

Properties

CachingConfig

The caching configuration for this resolver.

public ICachingConfig? CachingConfig { get; set; }
Property Value

ICachingConfig

Remarks

Default: - No caching configuration

Code

The function code.

public Code? Code { get; set; }
Property Value

Code

Remarks

Default: - no code is used

FieldName

name of the GraphQL field in the given type this resolver is attached to.

public string FieldName { get; set; }
Property Value

string

Remarks

ExampleMetadata: infused

MaxBatchSize

The maximum number of elements per batch, when using batch invoke.

public double? MaxBatchSize { get; set; }
Property Value

double?

Remarks

Default: - No max batch size

PipelineConfig

configuration of the pipeline resolver.

public IAppsyncFunction[]? PipelineConfig { get; set; }
Property Value

IAppsyncFunction[]

Remarks

Default: - no pipeline resolver configuration An empty array | undefined sets resolver to be of kind, unit

RequestMappingTemplate

The request mapping template for this resolver.

public MappingTemplate? RequestMappingTemplate { get; set; }
Property Value

MappingTemplate

Remarks

Default: - No mapping template

ResponseMappingTemplate

The response mapping template for this resolver.

public MappingTemplate? ResponseMappingTemplate { get; set; }
Property Value

MappingTemplate

Remarks

Default: - No mapping template

Runtime

The functions runtime.

public FunctionRuntime? Runtime { get; set; }
Property Value

FunctionRuntime

Remarks

Default: - no function runtime, VTL mapping templates used

TypeName

name of the GraphQL type this resolver is attached to.

public string TypeName { get; set; }
Property Value

string

Remarks

ExampleMetadata: infused

Implements

IBaseResolverProps
Back to top Generated by DocFX