aws / aws/aws-cdk

(AppSync): Add `GraphqlApi.fromApiName()` method to lookup existing APIs from other CDK projects

Open
#13,440 2 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-appsync effort/small feature-request feature/enhancement good first issue p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

Adding the static method `fromApiName()` to the `GraphqlApi` object will allow the configuration of APIs in separate projects.

Currently alternative is to use `fromGraphqlApiAttributes` which required knowledge of the exact ID or ARN used in the current environment, which is a configuration overhead for all projects to maintain and update the values across environments.

### Use Case

We are setting up a number of graphQL end points that we would like to be reachable through a single CloudFront controlled URL.

The target end URL is `services.domain.com` with the following endPoints:

- `/endPoint1`
- `/endPoint2`
- `/endPoint3`

etc

Each endPoint is serviced with different lamba functions that we would like to configure in separate projects, rather than build a single project with the lambdas for all end points. This will allow us to more easily manage the roll-out of different functions.

At the moment to do this we need to collect the IDs for each `GraphqlApi` once they are generated in the main project and then configure them per environment in each lambda project.

This API would simplify things.

### Proposed Solution

`GraphqlApi.fromApiName(scope: Construct, id: string, apiName: string): IGraphqlApi`

Similar to the way a Bucket can be looked up:

`Bucket.fromBucketName(scope: Construct, id: string, bucketName: string): IBucket`

### Other

* [ ] :wave: I may be able to implement this feature request
* [ ] :warning: This feature might incur a breaking change

---

This is a :rocket: Feature Request

Contributor guide

Open the contributing guide

Research direction

Start with the GraphqlApi construct and compare the proposed method with Bucket.fromBucketName and the existing fromGraphqlApiAttributes entry point. Determine how an API name should resolve across environments, then add the corresponding lookup behavior and tests showing that fromApiName returns an IGraphqlApi.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, graphql, typescript
Domain
api, cloud
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.