AppSyncGraphQLApiProps
Struct Stable
Customize the AppSync GraphQL API target.
| Source | aws-events-targets/lib/appsync.ts |
|---|---|
| Type last changed |
Example
ts
import * as appsync from 'aws-cdk-lib/aws-appsync';
const api = new appsync.GraphqlApi(this, 'api', {
name: 'api',
definition: appsync.Definition.fromFile('schema.graphql'),
authorizationConfig: {
defaultAuthorization: { authorizationType: appsync.AuthorizationType.IAM }
},
});
const rule = new events.Rule(this, 'Rule', {
schedule: events.Schedule.rate(cdk.Duration.hours(1)),
});
rule.addTarget(new targets.AppSync(api, {
graphQLOperation: 'mutation Publish($message: String!){ publish(message: $message) { message } }',
variables: events.RuleTargetInput.fromObject({
message: 'hello world',
}),
}));
python
import aws_cdk.aws_appsync as appsync
api = appsync.GraphqlApi(self, "api",
name="api",
definition=appsync.Definition.from_file("schema.graphql"),
authorization_config=appsync.AuthorizationConfig(
default_authorization=appsync.AuthorizationMode(authorization_type=appsync.AuthorizationType.IAM)
)
)
rule = events.Rule(self, "Rule",
schedule=events.Schedule.rate(cdk.Duration.hours(1))
)
rule.add_target(targets.AppSync(api,
graph_ql_operation="mutation Publish($message: String!){ publish(message: $message) { message } }",
variables=events.RuleTargetInput.from_object({
"message": "hello world"
})
))
java
import software.amazon.awscdk.services.appsync.*;
GraphqlApi api = GraphqlApi.Builder.create(this, "api")
.name("api")
.definition(Definition.fromFile("schema.graphql"))
.authorizationConfig(AuthorizationConfig.builder()
.defaultAuthorization(AuthorizationMode.builder().authorizationType(AuthorizationType.IAM).build())
.build())
.build();
Rule rule = Rule.Builder.create(this, "Rule")
.schedule(Schedule.rate(Duration.hours(1)))
.build();
rule.addTarget(AppSync.Builder.create(api)
.graphQLOperation("mutation Publish($message: String!){ publish(message: $message) { message } }")
.variables(RuleTargetInput.fromObject(Map.of(
"message", "hello world")))
.build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.AppSync;
var api = new GraphqlApi(this, "api", new GraphqlApiProps {
Name = "api",
Definition = Definition.FromFile("schema.graphql"),
AuthorizationConfig = new AuthorizationConfig {
DefaultAuthorization = new AuthorizationMode { AuthorizationType = AuthorizationType.IAM }
}
});
var rule = new Rule(this, "Rule", new RuleProps {
Schedule = Schedule.Rate(Duration.Hours(1))
});
rule.AddTarget(new AppSync(api, new AppSyncGraphQLApiProps {
GraphQLOperation = "mutation Publish($message: String!){ publish(message: $message) { message } }",
Variables = RuleTargetInput.FromObject(new Dictionary<string, string> {
{ "message", "hello world" }
})
}));
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import "github.com/aws/aws-cdk-go/awscdk"
api := appsync.NewGraphqlApi(this, jsii.String("api"), &GraphqlApiProps{
Name: jsii.String("api"),
Definition: appsync.Definition_FromFile(jsii.String("schema.graphql")),
AuthorizationConfig: &AuthorizationConfig{
DefaultAuthorization: &AuthorizationMode{
AuthorizationType: appsync.AuthorizationType_IAM,
},
},
})
rule := events.NewRule(this, jsii.String("Rule"), &RuleProps{
Schedule: events.Schedule_Rate(cdk.Duration_Hours(jsii.Number(1))),
})
rule.AddTarget(targets.NewAppSync(api, &AppSyncGraphQLApiProps{
GraphQLOperation: jsii.String("mutation Publish($message: String!){ publish(message: $message) { message } }"),
Variables: events.RuleTargetInput_FromObject(map[string]*string{
"message": jsii.String("hello world"),
}),
}))
Properties
deadLetterQueueoptionalIQueuedead_letter_queueoptionalIQueuedeadLetterQueueoptionalIQueueDeadLetterQueueoptionalIQueueDeadLetterQueueoptionalIQueue #The SQS queue to be used as deadLetterQueue. Check out the considerations for using a dead-letter queue.
Default: no dead-letter queue
notes
The events not successfully delivered are automatically retried for a specified period of time, depending on the retry policy of the target. If an event is not delivered before all retry attempts are exhausted, it will be sent to the dead letter queue.
eventRoleoptionalIRoleevent_roleoptionalIRoleeventRoleoptionalIRoleEventRoleoptionalIRoleEventRoleoptionalIRole #The role to assume before invoking the target (i.e., the pipeline) when the given rule is triggered.
Default: a new role with permissions to access mutations will be created
graphQLOperationstringgraph_ql_operationstrgraphQLOperationStringGraphQLOperationstringGraphQLOperation*string required #The GraphQL operation;
that is, the query, mutation, or subscription to be parsed and executed by the GraphQL service.
maxEventAgeoptionalDurationmax_event_ageoptionalDurationmaxEventAgeoptionalDurationMaxEventAgeoptionalDurationMaxEventAgeoptionalDuration = Duration.hours(24) #The maximum age of a request that Lambda sends to a function for processing.
Minimum value of 60. Maximum value of 86400.
retryAttemptsoptionalnumberretry_attemptsoptionalint | floatretryAttemptsoptionalNumberRetryAttemptsoptionaldoubleRetryAttemptsoptional*float64 = 185 #The maximum number of times to retry when the function returns an error.
Minimum value of 0. Maximum value of 185.
variablesoptionalRuleTargetInputvariablesoptionalRuleTargetInputvariablesoptionalRuleTargetInputVariablesoptionalRuleTargetInputVariablesoptionalRuleTargetInput #The variables that are include in the GraphQL operation.
Default: The entire event is used