Amplify-appsync-simulator: Pass info as argument and batch name for pipelines
Description of changes
When configuring the AppSync Simulator using a Pipeline with 2 lambdas and using BatchInvoke in VTL, an exception was raised.
TypeError: Cannot read property 'info' of undefined
at LambdaDataLoader.<anonymous> (/var/task/node_modules/amplify-appsync-simulator/lib/data-loader/lambda/index.js:64:40)
at step (/var/task/node_modules/amplify-appsync-simulator/lib/data-loader/lambda/index.js:33:23)
at Object.next (/var/task/node_modules/amplify-appsync-simulator/lib/data-loader/lambda/index.js:14:53)
at /var/task/node_modules/amplify-appsync-simulator/lib/data-loader/lambda/index.js:8:71
at new Promise (<anonymous>)
at __awaiter (/var/task/node_modules/amplify-appsync-simulator/lib/data-loader/lambda/index.js:4:12)
at LambdaDataLoader.load (/var/task/node_modules/amplify-appsync-simulator/lib/data-loader/lambda/index.js:56:16)
at AmplifySimulatorFunction.<anonymous> (/var/task/node_modules/amplify-appsync-simulator/lib/resolvers/function.js:102:57)
at step (/var/task/node_modules/amplify-appsync-simulator/lib/resolvers/function.js:48:23)
at Object.next (/var/task/node_modules/amplify-appsync-simulator/lib/resolvers/function.js:29:53)
at fulfilled (/var/task/node_modules/amplify-appsync-simulator/lib/resolvers/function.js:20:58)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
First of all, required parameters were not passed to the lambda data loader and then the batching name generated was not taking into account the current datasource name.
Issue #, if available
This change comes from following issue: https://github.com/aws-amplify/amplify-category-api/issues/525
Description of how you validated changes
Before making this change, it was not possible to use the AppSync Simulator with batching configured in request mapping VTL (BatchInvoke). After the fix, I was able to perform GraphQL queries against the AppSync Simulator as expected.
Checklist
- [x] PR description included
- [x]
yarn testpasses - [ ] Tests are changed or added
- [ ] Relevant documentation is changed or added (and PR referenced)
- [ ] New AWS SDK calls or CloudFormation actions have been added to relevant test and service IAM policies
- [ ] Pull request labels are added
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Codecov Report
Merging #11462 (1e0ac0c) into dev (97c6de4) will increase coverage by
0.00%. The diff coverage is0.00%.
@@ Coverage Diff @@
## dev #11462 +/- ##
=======================================
Coverage 50.20% 50.20%
=======================================
Files 702 702
Lines 33935 33935
Branches 6966 6966
=======================================
+ Hits 17036 17037 +1
+ Misses 15421 15420 -1
Partials 1478 1478
| Impacted Files | Coverage Δ | |
|---|---|---|
| ...-appsync-simulator/src/data-loader/lambda/index.ts | 28.57% <0.00%> (ø) |
|
| ...mplify-appsync-simulator/src/resolvers/function.ts | 15.38% <0.00%> (ø) |
|
| packages/amplify-cli/src/index.ts | 66.10% <0.00%> (+0.84%) |
:arrow_up: |
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more
Hi @Cox65 - Thanks for your contribution. Could you add an unit test for this change?
@Cox65 are you still working on this?
Hi @danielleadams ! Sorry I have to find time to add unit tests as requested by @sundersc. Let me have a look to what is already in place. BR,
Hi @Cox65 - thanks for the contribution! Thought to check in if you had time to write the test for this, let us know if you need anything
Hi @offlineprogrammer , It seems that there is no unit test for this file at all. I cannot manage the full coverage of this as I don't have the full knowledge to do it. We are using this fix for a while now (in a forked version of this repo) and without it, it's not working fine.
Any news?