Skip to content

Commit 389b1a6

Browse files
author
Dane Pilcher
committed
fix: change vars to amplifyApiEnvironmentName
1 parent ec2c184 commit 389b1a6

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

packages/backend-data/src/convert_js_resolvers.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ void describe('defaultJsResolverCode', () => {
3737
void it('returns the default JS resolver code with api id and env name in valid JS', async () => {
3838
const code = defaultJsResolverCode('testApiId', 'testEnvName');
3939
assert(code.includes("ctx.stash.awsAppsyncApiId = 'testApiId';"));
40-
assert(code.includes("ctx.stash.amplifyBranchName = 'testEnvName';"));
40+
assert(
41+
code.includes("ctx.stash.amplifyApiEnvironmentName = 'testEnvName';")
42+
);
4143

4244
const tempDir = tmpdir();
4345
const filename = join(tempDir, 'js_resolver_handler.js');
@@ -52,7 +54,7 @@ void describe('defaultJsResolverCode', () => {
5254
// assert api id and env name are added to the context stash
5355
assert.deepEqual(context.stash, {
5456
awsAppsyncApiId: 'testApiId',
55-
amplifyBranchName: 'testEnvName',
57+
amplifyApiEnvironmentName: 'testEnvName',
5658
});
5759
assert.equal(resolver.response(context), 'result');
5860
});
@@ -230,7 +232,7 @@ void describe('convertJsResolverDefinition', () => {
230232
'ApiId',
231233
],
232234
},
233-
"';\n ctx.stash.amplifyBranchName = 'NONE';\n return {};\n};\n/**\n * Pipeline resolver response handler\n */\nexport const response = (ctx) => {\n return ctx.prev.result;\n};\n",
235+
"';\n ctx.stash.amplifyApiEnvironmentName = 'NONE';\n return {};\n};\n/**\n * Pipeline resolver response handler\n */\nexport const response = (ctx) => {\n return ctx.prev.result;\n};\n",
234236
],
235237
],
236238
},

packages/backend-data/src/convert_js_resolvers.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const JS_PIPELINE_RESOLVER_HANDLER = './assets/js_resolver_handler.js';
2424
*/
2525
export const defaultJsResolverCode = (
2626
amplifyApiId: string,
27-
amplifyEnvironmentName: string
27+
amplifyApiEnvironmentName: string
2828
): string => {
2929
const resolvedTemplatePath = resolve(
3030
fileURLToPath(import.meta.url),
@@ -35,8 +35,8 @@ export const defaultJsResolverCode = (
3535
return readFileSync(resolvedTemplatePath, 'utf-8')
3636
.replace(new RegExp(/\$\{amplifyApiId\}/, 'g'), amplifyApiId)
3737
.replace(
38-
new RegExp(/\$\{amplifyEnvironmentName\}/, 'g'),
39-
amplifyEnvironmentName
38+
new RegExp(/\$\{amplifyApiEnvironmentName\}/, 'g'),
39+
amplifyApiEnvironmentName
4040
);
4141
};
4242

@@ -78,15 +78,15 @@ export const convertJsResolverDefinition = (
7878

7979
const resolverName = `Resolver_${resolver.typeName}_${resolver.fieldName}`;
8080

81-
const amplifyEnvironmentName =
81+
const amplifyApiEnvironmentName =
8282
scope.node.tryGetContext('amplifyEnvironmentName') ?? 'NONE';
8383
new CfnResolver(scope, resolverName, {
8484
apiId: amplifyApi.apiId,
8585
fieldName: resolver.fieldName,
8686
typeName: resolver.typeName,
8787
kind: APPSYNC_PIPELINE_RESOLVER,
8888
// Uses synth-time inline code to avoid circular dependency when adding the API ID as an environment variable.
89-
code: defaultJsResolverCode(amplifyApi.apiId, amplifyEnvironmentName),
89+
code: defaultJsResolverCode(amplifyApi.apiId, amplifyApiEnvironmentName),
9090
runtime: {
9191
name: APPSYNC_JS_RUNTIME_NAME,
9292
runtimeVersion: APPSYNC_JS_RUNTIME_VERSION,

0 commit comments

Comments
 (0)