Skip to content

Commit

Permalink
fix: Add in new prop to support xray on appsync api (#74)
Browse files Browse the repository at this point in the history
* fix: Add in new prop to support xray on appsync api
* chore: bumping a few packages
  • Loading branch information
kcwinner authored Dec 17, 2020
1 parent 6c3624d commit af87250
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 29 deletions.
2 changes: 2 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ new AppSyncTransformer(scope: Construct, id: string, props: AppSyncTransformerPr
* **authorizationConfig** (<code>[AuthorizationConfig](#aws-cdk-aws-appsync-authorizationconfig)</code>) Optional. __*Default*__: API_KEY authorization config
* **fieldLogLevel** (<code>[FieldLogLevel](#aws-cdk-aws-appsync-fieldloglevel)</code>) Optional. __*Default*__: FieldLogLevel.NONE
* **syncEnabled** (<code>boolean</code>) Whether to enable Amplify DataStore and Sync Tables. __*Default*__: false
* **xrayEnabled** (<code>boolean</code>) Determines whether xray should be enabled on the AppSync API. __*Default*__: false



Expand Down Expand Up @@ -99,6 +100,7 @@ Name | Type | Description
**authorizationConfig**?🔹 | <code>[AuthorizationConfig](#aws-cdk-aws-appsync-authorizationconfig)</code> | Optional.<br/>__*Default*__: API_KEY authorization config
**fieldLogLevel**?🔹 | <code>[FieldLogLevel](#aws-cdk-aws-appsync-fieldloglevel)</code> | Optional.<br/>__*Default*__: FieldLogLevel.NONE
**syncEnabled**?🔹 | <code>boolean</code> | Whether to enable Amplify DataStore and Sync Tables.<br/>__*Default*__: false
**xrayEnabled**?🔹 | <code>boolean</code> | Determines whether xray should be enabled on the AppSync API.<br/>__*Default*__: false



Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"devDependencies": {
"@aws-cdk/assert": "^1.77.0",
"@types/jest": "^26.0.18",
"@types/jest": "^26.0.19",
"@types/node": "^10.17.48",
"@typescript-eslint/eslint-plugin": "^4.3.0",
"@typescript-eslint/parser": "^4.3.0",
Expand All @@ -41,9 +41,9 @@
"eslint-plugin-import": "^2.22.1",
"jest": "^26.6.3",
"jest-junit": "^12",
"jsii": "^1.15.0",
"jsii": "^1.16.0",
"jsii-diff": "^1.16.0",
"jsii-docgen": "^1.4.114",
"jsii-docgen": "^1.5.3",
"jsii-pacmak": "^1.16.0",
"jsii-release": "^0.2.7",
"json-schema": "^0.2.5",
Expand Down
7 changes: 7 additions & 0 deletions src/appsync-transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ export interface AppSyncTransformerProps {
* @default FieldLogLevel.NONE
*/
readonly fieldLogLevel?: FieldLogLevel;

/**
* Determines whether xray should be enabled on the AppSync API
* @default false
*/
readonly xrayEnabled?: boolean;
}

const defaultAuthorizationConfig: AuthorizationConfig = {
Expand Down Expand Up @@ -165,6 +171,7 @@ export class AppSyncTransformer extends Construct {
fieldLogLevel: props.fieldLogLevel ? props.fieldLogLevel : FieldLogLevel.NONE,
},
schema: Schema.fromAsset('./appsync/schema.graphql'),
xrayEnabled: props.xrayEnabled ?? false,
});

let tableData = this.outputs.cdkTables ?? {};
Expand Down
4 changes: 4 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ test('GraphQL API W/ Defaults Created', () => {
const appSyncTransformer = new AppSyncTransformer(stack, 'test-transformer', {
schemaPath: testSchemaPath,
authorizationConfig: apiKeyAuthorizationConfig,
xrayEnabled: false,
});

expect(stack).toHaveResource('AWS::CloudFormation::Stack');
expect(appSyncTransformer.nestedAppsyncStack).toHaveResource('AWS::AppSync::GraphQLApi', {
AuthenticationType: 'API_KEY',
XrayEnabled: false,
});
});

Expand All @@ -45,12 +47,14 @@ test('GraphQL API W/ Sync Created', () => {
apiName: 'sync-api',
authorizationConfig: apiKeyAuthorizationConfig,
syncEnabled: true,
xrayEnabled: true,
});

expect(stack).toHaveResource('AWS::CloudFormation::Stack');
expect(appSyncTransformer.nestedAppsyncStack).toHaveResource('AWS::AppSync::GraphQLApi', {
AuthenticationType: 'API_KEY',
Name: 'sync-api',
XrayEnabled: true,
});
});

Expand Down
53 changes: 27 additions & 26 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1023,10 +1023,10 @@
jest-diff "^26.0.0"
pretty-format "^26.0.0"

"@types/jest@^26.0.18":
version "26.0.18"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.18.tgz#3c5f9228e9ac15bd42f903f1acf2ad6ea5ed73d9"
integrity sha512-scDPs+mELZgsFetTgBSsIxKGrlitn9t/d2ecP+S1QSIGD+31fkMBEftLfOAX5k3tU06/0PjreJIQ+gWEbbHqpw==
"@types/jest@^26.0.19":
version "26.0.19"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.19.tgz#e6fa1e3def5842ec85045bd5210e9bb8289de790"
integrity sha512-jqHoirTG61fee6v6rwbnEuKhpSKih0tuhqeFbCmMmErhtu3BYlOZaXWjffgOstMM4S/3iQD31lI5bGLTrs97yQ==
dependencies:
jest-diff "^26.0.0"
pretty-format "^26.0.0"
Expand Down Expand Up @@ -2168,20 +2168,21 @@ deep-diff@^1.0.2:
resolved "https://registry.yarnpkg.com/deep-diff/-/deep-diff-1.0.2.tgz#afd3d1f749115be965e89c63edc7abb1506b9c26"
integrity sha512-aWS3UIVH+NPGCD1kki+DCU9Dua032iSsO43LqQpcs4R3+dVv7tX0qBGjiVHJHjplsoUM2XRO/KB92glqc68awg==

deep-equal@^2.0.4:
version "2.0.4"
resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-2.0.4.tgz#6b0b407a074666033169df3acaf128e1c6f3eab6"
integrity sha512-BUfaXrVoCfgkOQY/b09QdO9L3XNoF2XH0A3aY9IQwQL/ZjLOe8FQgCNVl1wiolhsFo8kFdO9zdPViCPbmaJA5w==
deep-equal@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-2.0.5.tgz#55cd2fe326d83f9cbf7261ef0e060b3f724c5cb9"
integrity sha512-nPiRgmbAtm1a3JsnLCf6/SLfXcjyN5v8L1TXzdCmHrXJ4hx+gW/w1YCcn7z8gJtSiDArZCgYtbao3QqLm/N1Sw==
dependencies:
es-abstract "^1.18.0-next.1"
es-get-iterator "^1.1.0"
call-bind "^1.0.0"
es-get-iterator "^1.1.1"
get-intrinsic "^1.0.1"
is-arguments "^1.0.4"
is-date-object "^1.0.2"
is-regex "^1.1.1"
isarray "^2.0.5"
object-is "^1.1.3"
object-is "^1.1.4"
object-keys "^1.1.1"
object.assign "^4.1.1"
object.assign "^4.1.2"
regexp.prototype.flags "^1.3.0"
side-channel "^1.0.3"
which-boxed-primitive "^1.0.1"
Expand Down Expand Up @@ -2395,7 +2396,7 @@ es-abstract@^1.18.0-next.0, es-abstract@^1.18.0-next.1:
string.prototype.trimend "^1.0.1"
string.prototype.trimstart "^1.0.1"

es-get-iterator@^1.1.0:
es-get-iterator@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/es-get-iterator/-/es-get-iterator-1.1.1.tgz#b93ddd867af16d5118e00881396533c1c6647ad9"
integrity sha512-qorBw8Y7B15DVLaJWy6WdEV/ZkieBcu6QCq/xzWzGOKJqgG1j754vXRfZ3NY7HSShneqU43mPB4OkQBTkvHhFw==
Expand Down Expand Up @@ -4253,10 +4254,10 @@ jsii-diff@^1.16.0:
typescript "~3.9.7"
yargs "^16.1.1"

jsii-docgen@^1.4.114:
version "1.4.114"
resolved "https://registry.yarnpkg.com/jsii-docgen/-/jsii-docgen-1.4.114.tgz#9f5fb432d858e3ec017951fa017d752b0fe72e26"
integrity sha512-a7MFmPo/Y48AYJzGOxSAqNRJ3MwYuIrqGegOPb5wwXhyttm2H7muH3BYYn932LWEsUjNemmZoqmUhYeuM9OeAA==
jsii-docgen@^1.5.3:
version "1.5.3"
resolved "https://registry.yarnpkg.com/jsii-docgen/-/jsii-docgen-1.5.3.tgz#654072e2835adc4520ac741c41f2b5e2bb6baadf"
integrity sha512-AnDxMQwBCjK23ISZqXf4JmRFNODTprcB6qfwUrCaPwBblfOCFEo6xpZROtuGdeZRmu+RmlcYlywSyWQQFdj0PA==
dependencies:
"@jsii/spec" "^1.9.0"
fs-extra "^9.0.0"
Expand Down Expand Up @@ -4320,18 +4321,18 @@ jsii-rosetta@^1.16.0:
xmldom "^0.4.0"
yargs "^16.1.1"

jsii@^1.15.0:
version "1.15.0"
resolved "https://registry.yarnpkg.com/jsii/-/jsii-1.15.0.tgz#3f3160ee2c5fe62473855c1ac8d2aa9e3bf72ad1"
integrity sha512-kYiO1WkeqN7or4rz5ccYooO576+wiqiRGzv+UCI6hShKd42ff3xYZ1oTUSnBQdh9lp9i/nlNtx7KGUEqjC16Aw==
jsii@^1.16.0:
version "1.16.0"
resolved "https://registry.yarnpkg.com/jsii/-/jsii-1.16.0.tgz#bc39ad771b5dc6a631ce4b85191447686fa96967"
integrity sha512-8cgroyD6LOlFUlXUMAmjtUhzgyF3oQpVVpIdDzqcn2dNgs7iDnZN/Wo27MfZj8usbIBLLK3DYv7DSf+0/H0yWA==
dependencies:
"@jsii/spec" "^1.15.0"
"@jsii/spec" "^1.16.0"
case "^1.6.3"
colors "^1.4.0"
deep-equal "^2.0.4"
deep-equal "^2.0.5"
fs-extra "^9.0.1"
log4js "^6.3.0"
semver "^7.3.2"
semver "^7.3.4"
semver-intersect "^1.4.0"
sort-json "^2.0.0"
spdx-license-list "^6.3.0"
Expand Down Expand Up @@ -4988,7 +4989,7 @@ object-inspect@^1.8.0:
resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.8.0.tgz#df807e5ecf53a609cc6bfe93eac3cc7be5b3a9d0"
integrity sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA==

object-is@^1.1.3:
object-is@^1.1.4:
version "1.1.4"
resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.4.tgz#63d6c83c00a43f4cbc9434eb9757c8a5b8565068"
integrity sha512-1ZvAZ4wlF7IyPVOcE1Omikt7UpaFlOQq0HlSti+ZvDH3UiD2brwGMwDbyV43jao2bKJ+4+WdPJHSd7kgzKYVqg==
Expand All @@ -5008,7 +5009,7 @@ object-visit@^1.0.0:
dependencies:
isobject "^3.0.0"

object.assign@^4.1.1:
object.assign@^4.1.1, object.assign@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.2.tgz#0ed54a342eceb37b38ff76eb831a0e788cb63940"
integrity sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==
Expand Down

0 comments on commit af87250

Please sign in to comment.