Skip to content

Commit d35f032

Browse files
authored
fix(appsync): revert to allow resolver creation from data source (#12973)
* Revert to old behavior of allowing a data source to create a resolver as UNIT resolvers stem from data sources. * Maintaining new behavior of having `GraphqlApi` create resolvers as PIPELINE resolvers stem from the `GraphqlApi` itself Fixes #12635 Fixes #11522 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 6aac3b6 commit d35f032

File tree

6 files changed

+240
-237
lines changed

6 files changed

+240
-237
lines changed

packages/@aws-cdk/aws-appsync/lib/data-source.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,11 @@ export abstract class BaseDataSource extends CoreConstruct {
126126
* creates a new resolver for this datasource and API using the given properties
127127
*/
128128
public createResolver(props: BaseResolverProps): Resolver {
129-
return this.api.createResolver({ dataSource: this, ...props });
129+
return new Resolver(this, `${props.typeName}${props.fieldName}Resolver`, {
130+
api: this.api,
131+
dataSource: this,
132+
...props,
133+
});
130134
}
131135

132136
/**

packages/@aws-cdk/aws-appsync/test/appsync.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ test('appsync should error when creating pipeline resolver with data source', ()
5555

5656
// THEN
5757
expect(() => {
58-
api.createResolver({
59-
dataSource: ds,
58+
ds.createResolver({
6059
typeName: 'test',
6160
fieldName: 'test2',
6261
pipelineConfig: [test1, test2],

packages/@aws-cdk/aws-appsync/test/integ.api-import.expected.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
}
136136
}
137137
},
138-
"ApiQuerygetTestsResolver025B8E0A": {
138+
"ApidsQuerygetTestsResolver952F49EE": {
139139
"Type": "AWS::AppSync::Resolver",
140140
"Properties": {
141141
"ApiId": {
@@ -152,7 +152,7 @@
152152
"Apids0DB53FEA"
153153
]
154154
},
155-
"ApiMutationaddTestResolver7A08AE91": {
155+
"ApidsMutationaddTestResolverBCF0400B": {
156156
"Type": "AWS::AppSync::Resolver",
157157
"Properties": {
158158
"ApiId": {

packages/@aws-cdk/aws-appsync/test/integ.auth-apikey.expected.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
}
122122
}
123123
},
124-
"ApiQuerygetTestsResolver025B8E0A": {
124+
"ApitestDataSourceQuerygetTestsResolverA3BBB672": {
125125
"Type": "AWS::AppSync::Resolver",
126126
"Properties": {
127127
"ApiId": {
@@ -142,7 +142,7 @@
142142
"ApitestDataSource96AE54D5"
143143
]
144144
},
145-
"ApiMutationaddTestResolver7A08AE91": {
145+
"ApitestDataSourceMutationaddTestResolver36203D6B": {
146146
"Type": "AWS::AppSync::Resolver",
147147
"Properties": {
148148
"ApiId": {

packages/@aws-cdk/aws-appsync/test/integ.graphql-iam.expected.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
}
151151
}
152152
},
153-
"ApiQuerygetTestResolver4C1F8B0C": {
153+
"ApidsQuerygetTestResolverCCED7EC2": {
154154
"Type": "AWS::AppSync::Resolver",
155155
"Properties": {
156156
"ApiId": {
@@ -171,7 +171,7 @@
171171
"ApiSchema510EECD7"
172172
]
173173
},
174-
"ApiQuerygetTestsResolver025B8E0A": {
174+
"ApidsQuerygetTestsResolver952F49EE": {
175175
"Type": "AWS::AppSync::Resolver",
176176
"Properties": {
177177
"ApiId": {
@@ -192,7 +192,7 @@
192192
"ApiSchema510EECD7"
193193
]
194194
},
195-
"ApiMutationaddTestResolver7A08AE91": {
195+
"ApidsMutationaddTestResolverBCF0400B": {
196196
"Type": "AWS::AppSync::Resolver",
197197
"Properties": {
198198
"ApiId": {
@@ -400,14 +400,12 @@
400400
]
401401
}
402402
},
403-
"Handler": "iam-query.handler",
404403
"Role": {
405404
"Fn::GetAtt": [
406405
"LambdaIAM687B49AF",
407406
"Arn"
408407
]
409408
},
410-
"Runtime": "nodejs12.x",
411409
"Environment": {
412410
"Variables": {
413411
"APPSYNC_ENDPOINT": {
@@ -417,7 +415,9 @@
417415
]
418416
}
419417
}
420-
}
418+
},
419+
"Handler": "iam-query.handler",
420+
"Runtime": "nodejs12.x"
421421
},
422422
"DependsOn": [
423423
"LambdaIAMDefaultPolicy96DEA124",
@@ -496,14 +496,12 @@
496496
]
497497
}
498498
},
499-
"Handler": "iam-query.handler",
500499
"Role": {
501500
"Fn::GetAtt": [
502501
"testFailServiceRole9FF22F85",
503502
"Arn"
504503
]
505504
},
506-
"Runtime": "nodejs12.x",
507505
"Environment": {
508506
"Variables": {
509507
"APPSYNC_ENDPOINT": {
@@ -513,7 +511,9 @@
513511
]
514512
}
515513
}
516-
}
514+
},
515+
"Handler": "iam-query.handler",
516+
"Runtime": "nodejs12.x"
517517
},
518518
"DependsOn": [
519519
"testFailServiceRole9FF22F85"

0 commit comments

Comments
 (0)