Skip to content

Commit

Permalink
fix(appsync): Not to throw an Error even if 'additionalAuthorizationM…
Browse files Browse the repository at this point in the history
…odes' is undefined

fixes #8666 #8668
  • Loading branch information
civilizeddev committed Jun 22, 2020
1 parent 5053eb7 commit 82ba1f3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
12 changes: 6 additions & 6 deletions packages/@aws-cdk/aws-appsync/lib/graphqlapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,7 @@ export class GraphQLApi extends Construct {
props.authorizationConfig.defaultAuthorization.userPoolConfig!,
)
: undefined,
additionalAuthenticationProviders: props.authorizationConfig
?.additionalAuthorizationModes!.length
? this.formatAdditionalAuthorizationModes(
props.authorizationConfig!.additionalAuthorizationModes!,
)
: undefined,
additionalAuthenticationProviders: this.formatAdditionalAuthenticationProviders(props),
});

this.apiId = this.api.attrApiId;
Expand Down Expand Up @@ -569,6 +564,11 @@ export class GraphQLApi extends Construct {
[],
);
}

private formatAdditionalAuthenticationProviders(props: GraphQLApiProps): CfnGraphQLApi.AdditionalAuthenticationProviderProperty[] | undefined {
const authModes = props.authorizationConfig?.additionalAuthorizationModes;
return authModes ? this.formatAdditionalAuthorizationModes(authModes) : undefined;
}
}

/**
Expand Down
21 changes: 18 additions & 3 deletions packages/@aws-cdk/aws-appsync/test/appsync.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
import '@aws-cdk/assert/jest';
import {} from '../lib';
import * as cdk from '@aws-cdk/core';
import * as path from 'path';
import * as appsync from '../lib';

test('No tests are specified for this package', () => {
expect(true).toBe(true);
test('should not throw an Error', () => {
// Given
const stack = new cdk.Stack();

// When
const when = () => {
new appsync.GraphQLApi(stack, 'api', {
authorizationConfig: {},
name: 'api',
schemaDefinitionFile: path.join(__dirname, 'schema.graphql'),
});
};

// Then
expect(when).not.toThrow();
});

0 comments on commit 82ba1f3

Please sign in to comment.