Skip to content

Commit

Permalink
Replace union type with type hierarchy
Browse files Browse the repository at this point in the history
Signed-off-by: Duarte Nunes <duarte@uma.ni>
  • Loading branch information
duarten committed Feb 19, 2020
1 parent ab0b3da commit 988a115
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
14 changes: 7 additions & 7 deletions packages/@aws-cdk/aws-appsync/lib/graphqlapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import { Construct, Duration, IResolvable } from "@aws-cdk/core";
import { readFileSync } from "fs";
import { CfnApiKey, CfnDataSource, CfnGraphQLApi, CfnGraphQLSchema, CfnResolver } from "./appsync.generated";

/**
* Marker interface for the different authorization modes.
*/
export interface AuthMode { }

/**
* enum with all possible values for Cognito user-pool default actions
*/
Expand All @@ -23,7 +28,7 @@ export enum UserPoolDefaultAction {
/**
* Configuration for Cognito user-pools in AppSync
*/
export interface UserPoolConfig {
export interface UserPoolConfig extends AuthMode {

/**
* The Cognito user pool to use as identity source
Expand All @@ -50,7 +55,7 @@ function isUserPoolConfig(obj: unknown): obj is UserPoolConfig {
/**
* Configuration for API Key authorization in AppSync
*/
export interface ApiKeyConfig {
export interface ApiKeyConfig extends AuthMode {
/**
* Unique description of the API key
*/
Expand All @@ -69,11 +74,6 @@ function isApiKeyConfig(obj: unknown): obj is ApiKeyConfig {
return (obj as ApiKeyConfig).apiKeyDesc !== undefined;
}

/**
* Marker interface for the different authorization modes.
*/
type AuthMode = UserPoolConfig | ApiKeyConfig;

/**
* Configuration of the API authorization modes.
*/
Expand Down
9 changes: 8 additions & 1 deletion packages/@aws-cdk/aws-appsync/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,12 @@
"engines": {
"node": ">= 10.3.0"
},
"awslint": {
"exclude": [
"no-unused-type:@aws-cdk/aws-appsync.ApiKeyConfig",
"no-unused-type:@aws-cdk/aws-appsync.UserPoolConfig",
"no-unused-type:@aws-cdk/aws-appsync.UserPoolDefaultAction"
]
},
"stability": "experimental"
}
}

0 comments on commit 988a115

Please sign in to comment.