Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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*
- Loading branch information