Skip to content

Commit aa2c162

Browse files
committed
[ADDED] introspection, query & resolver limits properties in appsync
1 parent c029c63 commit aa2c162

10 files changed

+279
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Transform: AWS::Serverless-2016-10-31
2+
Resources:
3+
SuperCoolAPI:
4+
Type: AWS::Serverless::GraphQLApi
5+
Properties:
6+
SchemaInline: |
7+
type Mutation {
8+
addTodo(id: ID!, name: String, description: String, priority: Int): Todo
9+
}
10+
Visibility: PRIVATE
11+
OwnerContact: blah-blah
12+
IntrospectionConfig: DISABLED
13+
QueryDepthLimit: 10
14+
ResolverCountLimit: 100
15+
Auth:
16+
Type: AWS_IAM

samtranslator/internal/model/appsync.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ class GraphQLApi(Resource):
115115
"AdditionalAuthenticationProviders": GeneratedProperty(),
116116
"Visibility": GeneratedProperty(),
117117
"OwnerContact": GeneratedProperty(),
118+
"IntrospectionConfig": GeneratedProperty(),
119+
"QueryDepthLimit": GeneratedProperty(),
120+
"ResolverCountLimit": GeneratedProperty(),
118121
}
119122

120123
Name: str
@@ -128,6 +131,9 @@ class GraphQLApi(Resource):
128131
LogConfig: Optional[LogConfigType]
129132
Visibility: Optional[str]
130133
OwnerContact: Optional[str]
134+
IntrospectionConfig: Optional[str]
135+
QueryDepthLimit: Optional[int]
136+
ResolverCountLimit: Optional[int]
131137

132138
runtime_attrs = {"api_id": lambda self: fnGetAtt(self.logical_id, "ApiId")}
133139

samtranslator/internal/schema_source/aws_serverless_graphqlapi.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ class Properties(BaseModel):
164164
Cache: Optional[Cache]
165165
Visibility: Optional[PassThroughProp]
166166
OwnerContact: Optional[PassThroughProp]
167+
IntrospectionConfig: Optional[PassThroughProp]
168+
QueryDepthLimit: Optional[PassThroughProp]
169+
ResolverCountLimit: Optional[PassThroughProp]
167170

168171

169172
class Resource(BaseModel):

samtranslator/model/sam_resources.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2226,6 +2226,9 @@ class SamGraphQLApi(SamResourceMacro):
22262226
"Cache": Property(False, IS_DICT),
22272227
"Visibility": PassThroughProperty(False),
22282228
"OwnerContact": PassThroughProperty(False),
2229+
"IntrospectionConfig": PassThroughProperty(False),
2230+
"QueryDepthLimit": PassThroughProperty(False),
2231+
"ResolverCountLimit": PassThroughProperty(False),
22292232
}
22302233

22312234
Auth: List[Dict[str, Any]]
@@ -2243,6 +2246,9 @@ class SamGraphQLApi(SamResourceMacro):
22432246
Cache: Optional[Dict[str, Any]]
22442247
Visibility: Optional[PassThrough]
22452248
OwnerContact: Optional[PassThrough]
2249+
IntrospectionConfig: Optional[PassThrough]
2250+
QueryDepthLimit: Optional[PassThrough]
2251+
ResolverCountLimit: Optional[PassThrough]
22462252

22472253
# stop validation so we can use class variables for tracking state
22482254
validate_setattr = False
@@ -2322,6 +2328,13 @@ def _construct_appsync_api_resources(
23222328
api.OwnerContact = passthrough_value(model.OwnerContact)
23232329
api.XrayEnabled = model.XrayEnabled
23242330

2331+
if model.IntrospectionConfig:
2332+
api.IntrospectionConfig = passthrough_value(model.IntrospectionConfig)
2333+
if model.QueryDepthLimit:
2334+
api.QueryDepthLimit = passthrough_value(model.QueryDepthLimit)
2335+
if model.ResolverCountLimit:
2336+
api.ResolverCountLimit = passthrough_value(model.ResolverCountLimit)
2337+
23252338
lambda_auth_arns = self._parse_and_set_auth_properties(api, model.Auth)
23262339
auth_connectors = [
23272340
self._construct_lambda_auth_connector(api, arn, i) for i, arn in enumerate(lambda_auth_arns, 1)

samtranslator/schema/schema.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279735,6 +279735,9 @@
279735279735
"title": "Functions",
279736279736
"type": "object"
279737279737
},
279738+
"IntrospectionConfig": {
279739+
"$ref": "#/definitions/PassThroughProp"
279740+
},
279738279741
"Logging": {
279739279742
"anyOf": [
279740279743
{
@@ -279752,6 +279755,12 @@
279752279755
"OwnerContact": {
279753279756
"$ref": "#/definitions/PassThroughProp"
279754279757
},
279758+
"QueryDepthLimit": {
279759+
"$ref": "#/definitions/PassThroughProp"
279760+
},
279761+
"ResolverCountLimit": {
279762+
"$ref": "#/definitions/PassThroughProp"
279763+
},
279755279764
"Resolvers": {
279756279765
"additionalProperties": {
279757279766
"additionalProperties": {

schema_source/sam.schema.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6659,6 +6659,9 @@
66596659
"title": "Functions",
66606660
"type": "object"
66616661
},
6662+
"IntrospectionConfig": {
6663+
"$ref": "#/definitions/PassThroughProp"
6664+
},
66626665
"Logging": {
66636666
"anyOf": [
66646667
{
@@ -6676,6 +6679,12 @@
66766679
"OwnerContact": {
66776680
"$ref": "#/definitions/PassThroughProp"
66786681
},
6682+
"QueryDepthLimit": {
6683+
"$ref": "#/definitions/PassThroughProp"
6684+
},
6685+
"ResolverCountLimit": {
6686+
"$ref": "#/definitions/PassThroughProp"
6687+
},
66796688
"Resolvers": {
66806689
"additionalProperties": {
66816690
"additionalProperties": {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Transform: AWS::Serverless-2016-10-31
2+
Resources:
3+
SuperCoolAPI:
4+
Type: AWS::Serverless::GraphQLApi
5+
Properties:
6+
SchemaInline: |
7+
type Mutation {
8+
addTodo(id: ID!, name: String, description: String, priority: Int): Todo
9+
}
10+
Visibility: PRIVATE
11+
OwnerContact: blah-blah
12+
IntrospectionConfig: DISABLED
13+
QueryDepthLimit: 10
14+
ResolverCountLimit: 100
15+
Auth:
16+
Type: AWS_IAM
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"Resources": {
3+
"SuperCoolAPI": {
4+
"Properties": {
5+
"AuthenticationType": "AWS_IAM",
6+
"IntrospectionConfig": "DISABLED",
7+
"LogConfig": {
8+
"CloudWatchLogsRoleArn": {
9+
"Fn::GetAtt": [
10+
"SuperCoolAPICloudWatchRole",
11+
"Arn"
12+
]
13+
},
14+
"FieldLogLevel": "ALL"
15+
},
16+
"Name": "SuperCoolAPI",
17+
"OwnerContact": "blah-blah",
18+
"QueryDepthLimit": 10,
19+
"ResolverCountLimit": 100,
20+
"Tags": [
21+
{
22+
"Key": "graphqlapi:createdBy",
23+
"Value": "SAM"
24+
}
25+
],
26+
"Visibility": "PRIVATE"
27+
},
28+
"Type": "AWS::AppSync::GraphQLApi"
29+
},
30+
"SuperCoolAPICloudWatchRole": {
31+
"Properties": {
32+
"AssumeRolePolicyDocument": {
33+
"Statement": [
34+
{
35+
"Action": [
36+
"sts:AssumeRole"
37+
],
38+
"Effect": "Allow",
39+
"Principal": {
40+
"Service": [
41+
"appsync.amazonaws.com"
42+
]
43+
}
44+
}
45+
],
46+
"Version": "2012-10-17"
47+
},
48+
"ManagedPolicyArns": [
49+
{
50+
"Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSAppSyncPushToCloudWatchLogs"
51+
}
52+
]
53+
},
54+
"Type": "AWS::IAM::Role"
55+
},
56+
"SuperCoolAPISchema": {
57+
"Properties": {
58+
"ApiId": {
59+
"Fn::GetAtt": [
60+
"SuperCoolAPI",
61+
"ApiId"
62+
]
63+
},
64+
"Definition": "type Mutation {\n addTodo(id: ID!, name: String, description: String, priority: Int): Todo\n}\n"
65+
},
66+
"Type": "AWS::AppSync::GraphQLSchema"
67+
}
68+
}
69+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"Resources": {
3+
"SuperCoolAPI": {
4+
"Properties": {
5+
"AuthenticationType": "AWS_IAM",
6+
"IntrospectionConfig": "DISABLED",
7+
"LogConfig": {
8+
"CloudWatchLogsRoleArn": {
9+
"Fn::GetAtt": [
10+
"SuperCoolAPICloudWatchRole",
11+
"Arn"
12+
]
13+
},
14+
"FieldLogLevel": "ALL"
15+
},
16+
"Name": "SuperCoolAPI",
17+
"OwnerContact": "blah-blah",
18+
"QueryDepthLimit": 10,
19+
"ResolverCountLimit": 100,
20+
"Tags": [
21+
{
22+
"Key": "graphqlapi:createdBy",
23+
"Value": "SAM"
24+
}
25+
],
26+
"Visibility": "PRIVATE"
27+
},
28+
"Type": "AWS::AppSync::GraphQLApi"
29+
},
30+
"SuperCoolAPICloudWatchRole": {
31+
"Properties": {
32+
"AssumeRolePolicyDocument": {
33+
"Statement": [
34+
{
35+
"Action": [
36+
"sts:AssumeRole"
37+
],
38+
"Effect": "Allow",
39+
"Principal": {
40+
"Service": [
41+
"appsync.amazonaws.com"
42+
]
43+
}
44+
}
45+
],
46+
"Version": "2012-10-17"
47+
},
48+
"ManagedPolicyArns": [
49+
{
50+
"Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSAppSyncPushToCloudWatchLogs"
51+
}
52+
]
53+
},
54+
"Type": "AWS::IAM::Role"
55+
},
56+
"SuperCoolAPISchema": {
57+
"Properties": {
58+
"ApiId": {
59+
"Fn::GetAtt": [
60+
"SuperCoolAPI",
61+
"ApiId"
62+
]
63+
},
64+
"Definition": "type Mutation {\n addTodo(id: ID!, name: String, description: String, priority: Int): Todo\n}\n"
65+
},
66+
"Type": "AWS::AppSync::GraphQLSchema"
67+
}
68+
}
69+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"Resources": {
3+
"SuperCoolAPI": {
4+
"Properties": {
5+
"AuthenticationType": "AWS_IAM",
6+
"IntrospectionConfig": "DISABLED",
7+
"LogConfig": {
8+
"CloudWatchLogsRoleArn": {
9+
"Fn::GetAtt": [
10+
"SuperCoolAPICloudWatchRole",
11+
"Arn"
12+
]
13+
},
14+
"FieldLogLevel": "ALL"
15+
},
16+
"Name": "SuperCoolAPI",
17+
"OwnerContact": "blah-blah",
18+
"QueryDepthLimit": 10,
19+
"ResolverCountLimit": 100,
20+
"Tags": [
21+
{
22+
"Key": "graphqlapi:createdBy",
23+
"Value": "SAM"
24+
}
25+
],
26+
"Visibility": "PRIVATE"
27+
},
28+
"Type": "AWS::AppSync::GraphQLApi"
29+
},
30+
"SuperCoolAPICloudWatchRole": {
31+
"Properties": {
32+
"AssumeRolePolicyDocument": {
33+
"Statement": [
34+
{
35+
"Action": [
36+
"sts:AssumeRole"
37+
],
38+
"Effect": "Allow",
39+
"Principal": {
40+
"Service": [
41+
"appsync.amazonaws.com"
42+
]
43+
}
44+
}
45+
],
46+
"Version": "2012-10-17"
47+
},
48+
"ManagedPolicyArns": [
49+
{
50+
"Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSAppSyncPushToCloudWatchLogs"
51+
}
52+
]
53+
},
54+
"Type": "AWS::IAM::Role"
55+
},
56+
"SuperCoolAPISchema": {
57+
"Properties": {
58+
"ApiId": {
59+
"Fn::GetAtt": [
60+
"SuperCoolAPI",
61+
"ApiId"
62+
]
63+
},
64+
"Definition": "type Mutation {\n addTodo(id: ID!, name: String, description: String, priority: Int): Todo\n}\n"
65+
},
66+
"Type": "AWS::AppSync::GraphQLSchema"
67+
}
68+
}
69+
}

0 commit comments

Comments
 (0)