Skip to content

Commit

Permalink
chore(release): 1.56.0 (aws#9379)
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Jul 31, 2020
2 parents 48ccf09 + 2b00bf5 commit c1c174d
Show file tree
Hide file tree
Showing 68 changed files with 2,207 additions and 832 deletions.
2 changes: 1 addition & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
image: jsii/superchain
tasks:
- init: yarn build --skip-test --no-bail --skip-prereqs
- init: yarn build --skip-test --no-bail --skip-prereqs --skip-compat

vscode:
extensions:
Expand Down
2 changes: 1 addition & 1 deletion .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pull_request_rules:
label:
add: [ contribution/core ]
conditions:
- author~=^(eladb|RomainMuller|garnaat|nija-at|shivlaks|skinny85|rix0rrr|NGL321|Jerry-AWS|SomayaB|MrArnoldPalmer|NetaNir|iliapolo|njlynch)$
- author~=^(eladb|RomainMuller|garnaat|nija-at|shivlaks|skinny85|rix0rrr|NGL321|Jerry-AWS|SomayaB|MrArnoldPalmer|NetaNir|iliapolo|njlynch|ericzbeard|ccfife|fulghum|pkandasamy91|SoManyHs|uttarasridhar|BryanPan342|comcalvi|kaizen3031593|)$
- -label~="contribution/core"
- name: automatic merge
actions:
Expand Down
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,36 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [1.56.0](https://github.com/aws/aws-cdk/compare/v1.55.0...v1.56.0) (2020-07-31)


### ⚠ BREAKING CHANGES

* **appsync:** **appsync** prop `schemaDefinition` no longer takes string, instead it is required to configure schema definition mode.
- **appsync**: schemaDefinition takes param `SchemaDefinition.XXX` to declare how schema will be configured
- **SchemaDefinition.CODE** allows schema definition through CDK
- **SchemaDefinition.FILE** allows schema definition through schema.graphql file
* **cloudfront:** Removed origin classes from the aws-cloudfront module.
* **aws-cloudfront:** Removed S3Origin and HttpOrigin from the aws-cloudfront module. Use the S3Origin and HttpOrigin classes in the aws-cloudfront-origins module instead.
* **aws-cloudfront:** Renamed Origin to OriginBase.
* **cloudfront:** the property Origin.domainName has been removed

### Features

* **cfn-include:** add support for the Fn::Sub function ([#9275](https://github.com/aws/aws-cdk/issues/9275)) ([2a48495](https://github.com/aws/aws-cdk/commit/2a48495093dc33d88554aaa0a033338e798f9d5f))
* **core:** make the CfnParameter class mutable ([#9365](https://github.com/aws/aws-cdk/issues/9365)) ([860966a](https://github.com/aws/aws-cdk/commit/860966a3945e1b667f92b19b49b92f7a1b1b8b33)), closes [#9364](https://github.com/aws/aws-cdk/issues/9364)


### Bug Fixes

* **certificatemanager:** DNS validation for wildcard certificates ([#9291](https://github.com/aws/aws-cdk/issues/9291)) ([419278b](https://github.com/aws/aws-cdk/commit/419278bf88c16d5519ba63c822e4af52157e8c67)), closes [#9248](https://github.com/aws/aws-cdk/issues/9248)
* **pipelines:** reduce assets IAM policy size ([#9333](https://github.com/aws/aws-cdk/issues/9333)) ([88d563f](https://github.com/aws/aws-cdk/commit/88d563fab6971c20754d76c5d2eb9f4463aeae6c)), closes [#9316](https://github.com/aws/aws-cdk/issues/9316)


* **appsync:** strongly type schema definition mode ([#9283](https://github.com/aws/aws-cdk/issues/9283)) ([b46aa99](https://github.com/aws/aws-cdk/commit/b46aa998ce3aedd3c5cfc5b4eef08859a6dc0d2a)), closes [#9301](https://github.com/aws/aws-cdk/issues/9301)
* **cloudfront:** README updates and notes of breaking changes ([#9356](https://github.com/aws/aws-cdk/issues/9356)) ([fbb0418](https://github.com/aws/aws-cdk/commit/fbb04183ea77bcf630c39fa22893039865782a12)), closes [#9326](https://github.com/aws/aws-cdk/issues/9326)
* **cloudfront:** small refactoring of the Origin API ([#9281](https://github.com/aws/aws-cdk/issues/9281)) ([cbfdc15](https://github.com/aws/aws-cdk/commit/cbfdc15959c5d5209d4fed6ac281f9897f44d4c5)), closes [#9109](https://github.com/aws/aws-cdk/issues/9109)

## [1.55.0](https://github.com/aws/aws-cdk/compare/v1.54.0...v1.55.0) (2020-07-28)


Expand Down
8 changes: 7 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -euo pipefail
bail="--bail"
runtarget="build+test"
check_prereqs="true"
check_compat="true"
while [[ "${1:-}" != "" ]]; do
case $1 in
-h|--help)
Expand All @@ -22,6 +23,9 @@ while [[ "${1:-}" != "" ]]; do
--skip-prereqs)
check_prereqs="false"
;;
--skip-compat)
check_compat="false"
;;
*)
echo "Unrecognized parameter: $1"
exit 1
Expand Down Expand Up @@ -70,6 +74,8 @@ echo "==========================================================================
echo "building..."
time lerna run $bail --stream $runtarget || fail

/bin/bash scripts/check-api-compatibility.sh
if [ "$check_compat" == "true" ]; then
/bin/bash scripts/check-api-compatibility.sh
fi

touch $BUILD_INDICATOR
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"tools/*"
],
"rejectCycles": "true",
"version": "1.55.0"
"version": "1.56.0"
}
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-appsync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import * as db from '@aws-cdk/aws-dynamodb';

const api = new appsync.GraphQLApi(stack, 'Api', {
name: 'demo',
schemaDefinition: appsync.SchemaDefinition.FILE,
schemaDefinitionFile: join(__dirname, 'schema.graphql'),
authorizationConfig: {
defaultAuthorization: {
Expand Down
75 changes: 60 additions & 15 deletions packages/@aws-cdk/aws-appsync/lib/graphqlapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,21 @@ export interface LogConfig {
readonly fieldLogLevel?: FieldLogLevel;
}

/**
* Enum containing the different modes of schema definition
*/
export enum SchemaDefinition {
/**
* Define schema through functions like addType, addQuery, etc.
*/
CODE = 'CODE',

/**
* Define schema in a file, i.e. schema.graphql
*/
FILE = 'FILE',
}

/**
* Properties for an AppSync GraphQL API
*/
Expand All @@ -227,11 +242,14 @@ export interface GraphQLApiProps {
readonly logConfig?: LogConfig;

/**
* GraphQL schema definition. You have to specify a definition or a file containing one.
* GraphQL schema definition. Specify how you want to define your schema.
*
* SchemaDefinition.CODE allows schema definition through CDK
* SchemaDefinition.FILE allows schema definition through schema.graphql file
*
* @default - Use schemaDefinitionFile
* @experimental
*/
readonly schemaDefinition?: string;
readonly schemaDefinition: SchemaDefinition;
/**
* File containing the GraphQL schema definition. You have to specify a definition or a file containing one.
*
Expand Down Expand Up @@ -332,6 +350,7 @@ export class GraphQLApi extends Construct {
return this._apiKey;
}

private schemaMode: SchemaDefinition;
private api: CfnGraphQLApi;
private _apiKey?: string;

Expand Down Expand Up @@ -389,6 +408,7 @@ export class GraphQLApi extends Construct {
this.arn = this.api.attrArn;
this.graphQlUrl = this.api.attrGraphQlUrl;
this.name = this.api.name;
this.schemaMode = props.schemaDefinition;

if (
defaultAuthorizationType === AuthorizationType.API_KEY ||
Expand All @@ -404,18 +424,7 @@ export class GraphQLApi extends Construct {
this._apiKey = this.createAPIKey(apiKeyConfig);
}

let definition;
if (props.schemaDefinition) {
definition = props.schemaDefinition;
} else if (props.schemaDefinitionFile) {
definition = readFileSync(props.schemaDefinitionFile).toString('UTF-8');
} else {
throw new Error('Missing Schema definition. Provide schemaDefinition or schemaDefinitionFile');
}
this.schema = new CfnGraphQLSchema(this, 'Schema', {
apiId: this.apiId,
definition,
});
this.schema = this.defineSchema(props.schemaDefinitionFile);
}

/**
Expand Down Expand Up @@ -666,4 +675,40 @@ export class GraphQLApi extends Construct {
const authModes = props.authorizationConfig?.additionalAuthorizationModes;
return authModes ? this.formatAdditionalAuthorizationModes(authModes) : undefined;
}

/**
* Sets schema defintiion to input if schema mode is configured with SchemaDefinition.CODE
*
* @param definition string that is the graphql representation of schema
* @experimental temporary
*/
public updateDefinition (definition: string): void{
if ( this.schemaMode != SchemaDefinition.CODE ) {
throw new Error('API cannot add type because schema definition mode is not configured as CODE.');
}
this.schema.definition = definition;
}

/**
* Define schema based on props configuration
* @param file the file name/s3 location of Schema
*/
private defineSchema(file?: string): CfnGraphQLSchema {
let definition;

if ( this.schemaMode == SchemaDefinition.FILE && !file) {
throw new Error('schemaDefinitionFile must be configured if using FILE definition mode.');
} else if ( this.schemaMode == SchemaDefinition.FILE && file ) {
definition = readFileSync(file).toString('UTF-8');
} else if ( this.schemaMode == SchemaDefinition.CODE && !file ) {
definition = '';
} else if ( this.schemaMode == SchemaDefinition.CODE && file) {
throw new Error('definition mode CODE is incompatible with file definition. Change mode to FILE/S3 or unconfigure schemaDefinitionFile');
}

return new CfnGraphQLSchema(this, 'Schema', {
apiId: this.apiId,
definition,
});
}
}
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-appsync/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"@aws-cdk/aws-dynamodb": "0.0.0",
"@aws-cdk/aws-iam": "0.0.0",
"@aws-cdk/aws-lambda": "0.0.0",
"@aws-cdk/aws-s3-assets": "0.0.0",
"@aws-cdk/core": "0.0.0",
"constructs": "^3.0.2"
},
Expand All @@ -84,6 +85,7 @@
"@aws-cdk/aws-dynamodb": "0.0.0",
"@aws-cdk/aws-iam": "0.0.0",
"@aws-cdk/aws-lambda": "0.0.0",
"@aws-cdk/aws-s3-assets": "0.0.0",
"@aws-cdk/core": "0.0.0",
"constructs": "^3.0.2"
},
Expand Down
4 changes: 4 additions & 0 deletions packages/@aws-cdk/aws-appsync/test/appsync-apikey.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe('AppSync Authorization Config', () => {
// WHEN
new appsync.GraphQLApi(stack, 'api', {
name: 'api',
schemaDefinition: appsync.SchemaDefinition.FILE,
schemaDefinitionFile: path.join(__dirname, 'appsync.test.graphql'),
});

Expand All @@ -25,6 +26,7 @@ describe('AppSync Authorization Config', () => {
// WHEN
new appsync.GraphQLApi(stack, 'api', {
name: 'api',
schemaDefinition: appsync.SchemaDefinition.FILE,
schemaDefinitionFile: path.join(__dirname, 'appsync.test.graphql'),
authorizationConfig: {
defaultAuthorization: {
Expand All @@ -47,6 +49,7 @@ describe('AppSync Authorization Config', () => {
// WHEN
new appsync.GraphQLApi(stack, 'api', {
name: 'api',
schemaDefinition: appsync.SchemaDefinition.FILE,
schemaDefinitionFile: path.join(__dirname, 'appsync.test.graphql'),
authorizationConfig: {
defaultAuthorization: {
Expand All @@ -66,6 +69,7 @@ describe('AppSync Authorization Config', () => {
// WHEN
new appsync.GraphQLApi(stack, 'api', {
name: 'api',
schemaDefinition: appsync.SchemaDefinition.FILE,
schemaDefinitionFile: path.join(__dirname, 'appsync.test.graphql'),
authorizationConfig: {
defaultAuthorization: {
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-appsync/test/appsync-grant.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ beforeEach(() => {
});
api = new appsync.GraphQLApi(stack, 'API', {
name: 'demo',
schemaDefinition: appsync.SchemaDefinition.FILE,
schemaDefinitionFile: join(__dirname, 'appsync.test.graphql'),
authorizationConfig: {
defaultAuthorization: {
Expand Down
104 changes: 104 additions & 0 deletions packages/@aws-cdk/aws-appsync/test/appsync-schema.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import { join } from 'path';
import '@aws-cdk/assert/jest';
import * as cdk from '@aws-cdk/core';
import * as appsync from '../lib';

// Schema Definitions
const type = 'type test {\n version: String!\n}\n\n';
const query = 'type Query {\n getTests: [ test! ]!\n}\n\n';
const mutation = 'type Mutation {\n addTest(version: String!): test\n}\n';

let stack: cdk.Stack;
beforeEach(() => {
// GIVEN
stack = new cdk.Stack();
});

describe('testing schema definition mode `code`', () => {

test('definition mode `code` produces empty schema definition', () => {
// WHEN
new appsync.GraphQLApi(stack, 'API', {
name: 'demo',
schemaDefinition: appsync.SchemaDefinition.CODE,
});

//THEN
expect(stack).toHaveResourceLike('AWS::AppSync::GraphQLSchema', {
Definition: '',
});
});

test('definition mode `code` generates correct schema with updateDefinition', () => {
// WHEN
const api = new appsync.GraphQLApi(stack, 'API', {
name: 'demo',
schemaDefinition: appsync.SchemaDefinition.CODE,
});
api.updateDefinition(`${type}${query}${mutation}`);

//THEN
expect(stack).toHaveResourceLike('AWS::AppSync::GraphQLSchema', {
Definition: `${type}${query}${mutation}`,
});
});

test('definition mode `code` errors when schemaDefinitionFile is configured', () => {
// WHEN
const when = () => {
new appsync.GraphQLApi(stack, 'API', {
name: 'demo',
schemaDefinition: appsync.SchemaDefinition.CODE,
schemaDefinitionFile: join(__dirname, 'appsync.test.graphql'),
});
};

//THEN
expect(when).toThrowError('definition mode CODE is incompatible with file definition. Change mode to FILE/S3 or unconfigure schemaDefinitionFile');
});

});

describe('testing schema definition mode `file`', () => {

test('definition mode `file` produces correct output', () => {
// WHEN
new appsync.GraphQLApi(stack, 'API', {
name: 'demo',
schemaDefinition: appsync.SchemaDefinition.FILE,
schemaDefinitionFile: join(__dirname, 'appsync.test.graphql'),
});

//THEN
expect(stack).toHaveResourceLike('AWS::AppSync::GraphQLSchema', {
Definition: `${type}${query}${mutation}`,
});
});

test('definition mode `file` errors when calling updateDefiniton function', () => {
// WHEN
const api = new appsync.GraphQLApi(stack, 'API', {
name: 'demo',
schemaDefinition: appsync.SchemaDefinition.FILE,
schemaDefinitionFile: join(__dirname, 'appsync.test.graphql'),
});
const when = () => { api.updateDefinition('error'); };

//THEN
expect(when).toThrowError('API cannot add type because schema definition mode is not configured as CODE.');
});

test('definition mode `file` errors when schemaDefinitionFile is not configured', () => {
// WHEN
const when = () => {
new appsync.GraphQLApi(stack, 'API', {
name: 'demo',
schemaDefinition: appsync.SchemaDefinition.FILE,
});
};

//THEN
expect(when).toThrowError('schemaDefinitionFile must be configured if using FILE definition mode.');
});

});
Loading

0 comments on commit c1c174d

Please sign in to comment.