-
Notifications
You must be signed in to change notification settings - Fork 819
(gen2-migration) generate command should handle api overrides #14642
Copy link
Copy link
Open
Labels
Description
Is this feature request related to a new or existing Amplify category?
No response
Is this related to another service?
No response
Describe the feature you'd like to request
In Gen1, customers can override the built-in api resources by running amplify override api. This creates an overrides.ts file where customers can override resource properties using the CDK. For example
import { AmplifyApiGraphQlResourceStackTemplate, AmplifyProjectInfo } from '@aws-amplify/cli-extensibility-helper';
export function override(resources: AmplifyApiGraphQlResourceStackTemplate, amplifyProjectInfo: AmplifyProjectInfo) {
resources.api.GraphQLAPI.queryDepthLimit = 5;
}Our code-generation should take this override.ts file into account and produce the equivalent Gen2 code.
Describe the solution you'd like
Ideally, we would transform the override.ts to look like this:
export function override(backend: Backend<any>, amplifyProjectInfo: { envName: string, projectName: string }) {
(backend.data.resources.graphqlApi.node.defaultChild as CfnGraphQLApi).queryDepthLimit = 5;
}And then invoke this function from backend.ts:
import { override as overrideApi } from './api/override.ts`
const branchName = process.env.AWS_BRANCH ?? 'sandbox';
const backend = defineBackend({
...,
data,
});
overrideApi(backend, { envName: branchName, projectName: '<hard-code-project-name>' });Describe alternatives you've considered
None
Additional context
Lines 16 to 22 in 664dabc
| export interface AmplifyApiGraphQlResourceStackTemplate { | |
| // directives stack | |
| api?: Partial<AppsyncApiStack>; | |
| models?: Partial<Record<string, ModelDirectiveStack>>; | |
| opensearch?: Partial<OpenSearchDirectiveStack & AppsyncStackCommon>; | |
| predictions?: Partial<PredictionsDirectiveStack & AppsyncStackCommon>; | |
| } |
Note that its also possible to override REST APIs:
amplify-cli/packages/amplify-cli-extensibility-helper/src/types/api/types.ts
Lines 20 to 26 in 664dabc
| export type AmplifyApiRestResourceStackTemplate = { | |
| restApi: apigwCdk.CfnRestApi; | |
| deploymentResource: apigwCdk.CfnDeployment; | |
| policies?: { | |
| [pathName: string]: ApigwPathPolicy; | |
| }; | |
| } & AmplifyCDKL1; |
Is this something that you'd be interested in working on?
- 👋 I may be able to implement this feature request
Would this feature include a breaking change?
-
⚠️ This feature might incur a breaking change
Reactions are currently unavailable