StarpTech / apollo-datasource-http

Optimized JSON HTTP Data Source for Apollo Server
MIT License
73 stars 32 forks source link

Disable memoization for specific requests #26

Closed rerinho closed 2 years ago

rerinho commented 2 years ago

Hello!

Changes:

  1. Added memoize option in the Request type (its true by default for GET requests)
  2. Added request memoizable validation before the response is set in memoisedResults.
  3. Added 3 tests a. When no memoize option is informed (only for non-GET requests) b. When memoize option is false (should not add the response in the memoizedResults) c. When memoize option is true (current version default approach)

Motivation:

This change was necessary for a specific use case presented bellow:

1. Request a resource from another API.
2. Update some property of this resource.
3. Request the same resource again.

In this case, the resource received in the step 3 will be the same as in step 1, as the memoized is returned.

The memoize option allows to disabling storage in memoizedResults for specific requests.
JustinTRoss commented 2 years ago

Is there anywhere we can find a list of maintainers who can approve the running of workflows? @StarpTech

StarpTech commented 2 years ago

Hi @JustinTRoss, I'll try to review it next week. Thanks for the work.

JustinTRoss commented 2 years ago

Thanks @StarpTech 🙏 . @rerinho is the hard-worker 🔨 . Just looking for the lever to advance this to the next step 🙃 .

StarpTech commented 2 years ago

https://github.com/StarpTech/apollo-datasource-http/releases/tag/0.19.0