Repository: ViacomInc/data-point (js)

Issue:
staleWhileRevalidate is not saving new value
<!--
Thanks for your interest in the project. We appreciate bugs filed and PRs submitted!
Please make sure that you are familiar with and follow the Code of Conduct for
this project (found in the CODE_OF_CONDUCT.md file).

Please fill/un-comment out this template with all the relevant information so we can
understand what's going on and fix the issue.
-->

**Problem description**:

When revalidation is done the new value is not getting saved, this is because of recent changes done in data point to return value instead of accumulator were not reflected on the data-point-service logic where:

1. we call `resolveFromAccumulator`:

https://github.com/ViacomInc/data-point/blob/2df6ae81fcee353ffbfdf207766ff56745a375b9/packages/data-point-service/lib/cache-middleware.js#L114-L119

2. then we pass the result to:

https://github.com/ViacomInc/data-point/blob/2df6ae81fcee353ffbfdf207766ff56745a375b9/packages/data-point-service/lib/cache-middleware.js#L44-L52

Line 48 should had been the value itself, not an accumulator. 

**Suggested solution**:

replace `acc` by a `value` which we pass to `addEntry` as is.

update tests.

<!-- 
REPORTING BUG:

If you are reporting a bug, please provide the full error message/screenshots/anything.
-->

**What happened**:

When revalidating via `staleWhileRevalidate` revalidation value gets saved as undefined.

**Reproduction**: 

happens on any instance of `staleWhileRevalidate`


Pull request description:
fix(data-point-service): pass value to addEntry when revalidating
<!--
Thanks for your interest in the project. We appreciate bugs filed and PRs submitted!

Please make sure that you are familiar with and follow the Code of Conduct for
this project (found in the CODE_OF_CONDUCT.md file).

Also, please make sure you're familiar with and follow the instructions in the
contributing guidelines (found in the CONTRIBUTING.md file).

Please fill out the information below to expedite the review and (hopefully)
merge of your pull request!

BREAKING CHANGES:

If your PR includes a breaking change, please submit it with a codemod under
data-point-codemods that will help users upgrade their codebase.

Breaking changes without a codemod will not be accepted unless a codemod is not
viable or does not apply to the specific situation.
-->

<!-- What changes are being made? (What feature/bug is being fixed here?) -->
**What**:

closes #437

<!-- Have you done all of these things?  -->
**Checklist**:
<!-- add "N/A" to the end of each line that's irrelevant to your changes -->
<!-- to check an item, place an "x" in the box like so: "- [x] Documentation" -->
- [ ] Has Breaking changes
- [ ] Documentation
- [X] Tests
- [X] Ready to be merged <!-- In your opinion, is this ready to be merged as soon as it's reviewed? -->
- [ ] Added username to **all-contributors** list

<!-- feel free to add additional comments -->


Patch:
diff --git a/packages/data-point-service/lib/cache-middleware.js b/packages/data-point-service/lib/cache-middleware.js
index 5c999a8..f403e1c 100644
--- a/packages/data-point-service/lib/cache-middleware.js
+++ b/packages/data-point-service/lib/cache-middleware.js
@@ -45,9 +45,9 @@ function updateSWREntry(service, entryKey, cache) {
   /**
    * @param {Accumulator} acc
    */
-  return acc => {
+  return value => {
     debug("Updating cache key: %s with new stale value", entryKey);
-    return service.staleWhileRevalidate.addEntry(entryKey, acc.value, cache);
+    return service.staleWhileRevalidate.addEntry(entryKey, value, cache);
   };
 }
 


Test patch:
diff --git a/packages/data-point-service/lib/cache-middleware.test.js b/packages/data-point-service/lib/cache-middleware.test.js
index 59bec83..acf59a0 100644
--- a/packages/data-point-service/lib/cache-middleware.test.js
+++ b/packages/data-point-service/lib/cache-middleware.test.js
@@ -89,8 +89,8 @@ describe("updateSWREntry", () => {
   it("should add stale entry", () => {
     const mockAddEntry = jest.fn();
     const service = _.set({}, "staleWhileRevalidate.addEntry", mockAddEntry);
-    const acc = _.set({}, "value", "value");
-    CacheMiddleware.updateSWREntry(service, "entryKey", "cache")(acc);
+    const value = "value";
+    CacheMiddleware.updateSWREntry(service, "entryKey", "cache")(value);
     expect(mockAddEntry).toBeCalledWith("entryKey", "value", "cache");
     expect(mockDebug.mock.calls).toMatchSnapshot();
   });