Skip to content

Commit

Permalink
change addValidation with a private method
Browse files Browse the repository at this point in the history
  • Loading branch information
go-to-k committed Feb 15, 2024
1 parent ccc1b72 commit 1a100b5
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions packages/aws-cdk-lib/aws-appsync/lib/graphqlapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ export class GraphqlApi extends GraphqlApiBase {
this.addEnvironmentVariable(key, value);
});
}
this.validateEnvironmentVariables();
this.node.addValidation({ validate: () => this.validateEnvironmentVariables() });

this.api = new CfnGraphQLApi(this, 'Resource', {
name: props.name,
Expand Down Expand Up @@ -888,16 +888,12 @@ export class GraphqlApi extends GraphqlApiBase {
}

private validateEnvironmentVariables() {
this.node.addValidation( {
validate: () => {
const errors: string[] = [];
const entries = Object.entries(this.environmentVariables);
if (entries.length > 50) {
errors.push(`Only 50 environment variables can be set, got ${entries.length}`);
}
return errors;
},
});
const errors: string[] = [];
const entries = Object.entries(this.environmentVariables);
if (entries.length > 50) {
errors.push(`Only 50 environment variables can be set, got ${entries.length}`);
}
return errors;
}

private renderEnvironmentVariables() {
Expand Down

0 comments on commit 1a100b5

Please sign in to comment.