Commit 92a160b
authored
fix(appsync): source api association does not depend on schema (#29455)
### Issue # (if applicable)
Closes #29044.
### Reason for this change
When associating between the source GraphQL API and the merged API using `fromSourceApis`, generated association resource doesn't depend on the source GraphQL schema.
```ts
// This API has `CfnGraphQLSchema` by `definition` prop
const firstApi = new appsync.GraphqlApi(stack, 'FirstSourceAPI', {
name: 'FirstSourceAPI',
definition: appsync.Definition.fromFile(path.join(__dirname, 'appsync.merged-api-1.graphql')),
});
// This merged API generates `CfnSourceApiAssociation`
new appsync.GraphqlApi(stack, 'MergedAPI', {
name: 'MergedAPI',
definition: appsync.Definition.fromSourceApis({
sourceApis: [
{
sourceApi: firstApi,
mergeType: appsync.MergeType.MANUAL_MERGE,
},
],
}),
});
```
The same is true if the `SourceApiAssociation` construct is used explicitly.
```ts
// This API has `CfnGraphQLSchema` by `definition` prop
const firstApi = new appsync.GraphqlApi(stack, 'FirstSourceAPI', {
name: 'FirstSourceAPI',
definition: appsync.Definition.fromFile(path.join(__dirname, 'appsync.merged-api-1.graphql')),
});
// This merged API does not generate `CfnSourceApiAssociation`
const mergedApi = new appsync.GraphqlApi(stack, 'MergedAPI', {
name: 'MergedAPI',
definition: appsync.Definition.fromSourceApis({
sourceApis: [],
mergedApiExecutionRole: mergedApiExecutionRole,
}),
});
// This construct has `CfnSourceApiAssociation`
new appsync.SourceApiAssociation(stack, 'SourceApiAssociation1', {
sourceApi: firstApi,
mergedApi: mergedApi,
mergeType: appsync.MergeType.MANUAL_MERGE,
mergedApiExecutionRole: mergedApiExecutionRole,
});
```
### Description of changes
The `sourceApi` passed by the `fromSourceApis` method or the `SourceApiAssociation` construct has `addSchemaDependency` method. Using this method, we can make the association to depend on the schema in the `sourceApi`.
But, if the api is an IMPORTED resource to begin with, it has no schema in the CDK layer, so there is nothing we can do about it. (The method does nothing.)
### Description of how you validated changes
Both unit and existing integ tests.
### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)
----
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*1 parent 49b4aa1 commit 92a160b
25 files changed
Lines changed: 357 additions & 249 deletions
File tree
- packages
- @aws-cdk-testing/framework-integ/test/aws-appsync/test
- integ.appsync-merged-api-arn-flag-enabled.js.snapshot
- integ.appsync-merged-api.js.snapshot
- integ.appsync-source-api-association.js.snapshot
- aws-cdk-lib/aws-appsync
- lib
- test
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
216 | | - | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
217 | 220 | | |
218 | 221 | | |
219 | 222 | | |
| |||
233 | 236 | | |
234 | 237 | | |
235 | 238 | | |
236 | | - | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
237 | 243 | | |
238 | 244 | | |
239 | 245 | | |
| |||
0 commit comments