Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/aws-cdk/lib/api/hotswap/appsync-mapping-templates.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type {
GetSchemaCreationStatusCommandOutput,
GetSchemaCreationStatusCommandInput,
FunctionConfiguration,
} from '@aws-sdk/client-appsync';
import {
type ChangeHotswapResult,
Expand All @@ -14,6 +15,8 @@ import type { SDK } from '../aws-auth';

import type { EvaluateCloudFormationTemplate } from '../evaluate-cloudformation-template';

type ApiId = string;

export async function isHotswappableAppSyncChange(
logicalId: string,
change: HotswappableChangeCandidate,
Expand Down Expand Up @@ -55,6 +58,7 @@ export async function isHotswappableAppSyncChange(
} else {
physicalName = arn;
}
const functions: Record<ApiId, FunctionConfiguration[]> = {};
ret.push({
hotswappable: true,
resourceType: change.newValue.Type,
Expand Down Expand Up @@ -116,8 +120,10 @@ export async function isHotswappableAppSyncChange(
delete sdkRequestObject.runtime;
}

const functions = await sdk.appsync().listFunctions({ apiId: sdkRequestObject.apiId });
const { functionId } = functions.find((fn) => fn.name === physicalName) ?? {};
if (!functions.hasOwnProperty(sdkRequestObject.apiId)) {
functions[sdkRequestObject.apiId] = await sdk.appsync().listFunctions({ apiId: sdkRequestObject.apiId });
}
const { functionId } = functions[sdkRequestObject.apiId].find((fn) => fn.name === physicalName) ?? {};
Comment on lines +123 to +126
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we include a unit test that validates that:

  1. listFunctions is called with proper params when sdkRequestObject.apiId is not present
  2. listFunctions is NOT called when sdkRequestObject.apiId is present
    ?

// Updating multiple functions at the same time or along with graphql schema results in `ConcurrentModificationException`
await exponentialBackOffRetry(
() =>
Expand Down
Loading