Skip to content

Commit 8d01b3c

Browse files
author
Eugene Cheung
authored
fix(appsync): allow imported IGraphqlApi resources (#277)
To stay consistent with other parts of the library. --- _By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license_
1 parent 72cb2ba commit 8d01b3c

File tree

4 files changed

+133
-9
lines changed

4 files changed

+133
-9
lines changed

API.md

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/monitoring/aws-appsync/AppSyncMetricFactory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { GraphqlApi } from "@aws-cdk/aws-appsync-alpha";
1+
import { IGraphqlApi } from "@aws-cdk/aws-appsync-alpha";
22
import { DimensionsMap } from "aws-cdk-lib/aws-cloudwatch";
33

44
import {
@@ -13,7 +13,7 @@ export interface AppSyncMetricFactoryProps {
1313
/**
1414
* the GraphQL API to monitor
1515
*/
16-
readonly api: GraphqlApi;
16+
readonly api: IGraphqlApi;
1717
/**
1818
* whether the TPS should be filled with zeroes
1919
* @default - true

test/monitoring/aws-appsync/AppSyncMonitoring.test.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { GraphqlApi } from "@aws-cdk/aws-appsync-alpha";
1+
import { GraphqlApi, IGraphqlApi } from "@aws-cdk/aws-appsync-alpha";
22
import { Duration, Stack } from "aws-cdk-lib";
33
import { Template } from "aws-cdk-lib/assertions";
44

@@ -25,6 +25,29 @@ test("snapshot test: no alarms", () => {
2525
expect(Template.fromStack(stack)).toMatchSnapshot();
2626
});
2727

28+
test("snapshot test: no alarms with imported IGraphqlApi", () => {
29+
const stack = new Stack();
30+
31+
const scope = new TestMonitoringScope(stack, "Scope");
32+
33+
const dummyApi: IGraphqlApi = GraphqlApi.fromGraphqlApiAttributes(
34+
scope,
35+
"ImportedGraphQlApi",
36+
{
37+
graphqlApiId: "DummyApiFromElsewhere",
38+
}
39+
);
40+
41+
const monitoring = new AppSyncMonitoring(scope, {
42+
api: dummyApi,
43+
humanReadableName: "Dummy API for testing",
44+
alarmFriendlyName: "DummyApi",
45+
});
46+
47+
addMonitoringDashboardsToStack(stack, monitoring);
48+
expect(Template.fromStack(stack)).toMatchSnapshot();
49+
});
50+
2851
test("snapshot test: all alarms", () => {
2952
const stack = new Stack();
3053

test/monitoring/aws-appsync/__snapshots__/AppSyncMonitoring.test.ts.snap

Lines changed: 101 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)