-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add api id and amplify environment name to stash #2273
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 9aff173 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
* Pipeline resolver request handler | ||
*/ | ||
export const request = (ctx) => { | ||
ctx.stash.apiId = '${amplifyApi.apiId}'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd normally recommend we namespace all amplify variables, as in:
amplifyAppsyncApiId
amplifyEnvironmentName
amplifyFooBar...
However! Since we already have an output name for API ID, I wonder if we should use that:
awsAppsyncApiId
For parallelism, that makes the other variable something like:
awsAmplifyEnvironmentName
Co-authored-by: Tim Schmelter <[email protected]>
import { Asset } from 'aws-cdk-lib/aws-s3-assets'; | ||
import { resolveEntryPath } from './resolve_entry_path.js'; | ||
|
||
const APPSYNC_PIPELINE_RESOLVER = 'PIPELINE'; | ||
const APPSYNC_JS_RUNTIME_NAME = 'APPSYNC_JS'; | ||
const APPSYNC_JS_RUNTIME_VERSION = '1.0.0'; | ||
const JS_PIPELINE_RESOLVER_HANDLER = './assets/js_resolver_handler.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we're dropping this. Shall we remove unused assets?
(before you do please read other comments).
.replace('${amplifyApiId}', amplifyApiId) | ||
.replace('${amplifyEnvironmentName}', amplifyEnvironmentName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For future proofing: If templates reference the match patterns more than once, this will fail. Consider a global regexp:
.replace('${amplifyApiId}', amplifyApiId) | |
.replace('${amplifyEnvironmentName}', amplifyEnvironmentName); | |
.replace(new RegExp('\$\{amplifyApiId\}', 'g'), amplifyApiId) | |
.replace(new RegExp('\$\{amplifyEnvironmentName\}', 'g'), amplifyEnvironmentName); |
If you do adopt this change, please add tests to verify.
Problem
Customers are not able to use DDB batch operations in custom JS resolvers. The customer needs the DDB table name to perform batch operations. The customer can construct the table name from the GraphQL API ID and the Amplify environment name (
<model-name>-<graphql-api-id>-<environment-name>
).Issue number, if available: aws-amplify/amplify-category-api#408 (comment)
Changes
Add GraphQL API ID and the Amplify environment name to resolver context stash.
Corresponding docs PR, if applicable: aws-amplify/docs#8145
Validation
Checklist
run-e2e
label set.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.