aws_appsync: Support importing of DataSource constructs
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the feature
Right now, you cannot import an existing AppSync DataSource within a CDK app. You must create a new one every time. The feature request is to be able to import datasource resources.
### Use Case
A growingly popular pattern with AppSync is to use microservices with resolver based federation. AppSync itself has no support for federation the way Apollo GraphQL does, but a close approximation can be achieved by having the core GraphQL API and schema deployed in one cdk app (i.e., the "GraphQL service") and having various subgraphs of the schema resolve within their respective microservices.
The problem you quickly run into, however, is that DataSource names must be unique across a given GraphQL API in AppSync. The CDK constructs for DataSource resources do not generate hash-suffixed resource names the way most other constructs do. The `id` of the construct ends up being the name by default. Even if it was hash-suffixed, it'd still be wasteful and polluting to have so many empty `NoneDataSource` instances when just one would do.
### Proposed Solution
Allow importing a datasource as a type `IDataSource` or get specific as `INoneDataSource`, etc. Dynamic lookup that saves to the CDK context instead would be fine too, if that was preferred for whatever reason.
Maybe something like:
```typescript
NoneDataSource.fromDataSourceName(this, 'PassthruDataSource')
```
### Other Information
_No response_
### Acknowledgements
- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
### CDK version used
2.77.0
### Environment details (OS name and version, etc.)
N/A
Contributor guide
Research direction
Start from the aws_appsync DataSource constructs and the proposed NoneDataSource.fromDataSourceName(this, 'PassthruDataSource') entry point. Define what importing as IDataSource or a specific datasource type should support, then verify that an existing AppSync datasource can be referenced without creating a duplicate resource.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, graphql, typescript
- Domain
- api, cloud
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100