File tree Expand file tree Collapse file tree 4 files changed +21
-2
lines changed
Expand file tree Collapse file tree 4 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77
88## [ Unreleased]
99
10+ ## [ 6.45.24] - 2023-10-05
11+ ### Added
12+
13+ - Allow disabling memoization for all requests of a client
1014## [ 6.45.23] - 2023-10-04
1115
1216### Fixed
Original file line number Diff line number Diff line change 11{
22 "name" : " @vtex/api" ,
3- "version" : " 6.45.23 " ,
3+ "version" : " 6.45.24 " ,
44 "description" : " VTEX I/O API client" ,
55 "main" : " lib/index.js" ,
66 "typings" : " lib/index.d.ts" ,
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ export class HttpClient {
3939
4040 private logger : Logger
4141 private cacheableType : CacheType
42+ private memoizable : boolean
4243
4344 private runMiddlewares : compose . ComposedMiddleware < MiddlewareContext >
4445
@@ -49,6 +50,7 @@ export class HttpClient {
4950 authType,
5051 memoryCache,
5152 diskCache,
53+ memoizable = true ,
5254 locale,
5355 name,
5456 metrics,
@@ -79,6 +81,7 @@ export class HttpClient {
7981 this . name = name || baseURL || 'unknown'
8082 this . logger = logger
8183 this . cacheableType = cacheableType
84+ this . memoizable = memoizable
8285
8386 const limit = concurrency && concurrency > 0 && pLimit ( concurrency ) || undefined
8487 const headers : Record < string , string > = {
@@ -210,7 +213,7 @@ export class HttpClient {
210213
211214 private getConfig = ( url : string , config : RequestConfig = { } ) : CacheableRequestConfig => ( {
212215 cacheable : this . cacheableType ,
213- memoizable : true ,
216+ memoizable : this . memoizable ,
214217 ...config ,
215218 url,
216219 } )
Original file line number Diff line number Diff line change @@ -83,6 +83,18 @@ export interface InstanceOptions {
8383 timeout ?: number
8484 memoryCache ?: CacheLayer < string , Cached >
8585 diskCache ?: CacheLayer < string , Cached >
86+
87+ /**
88+ * Enables memoization, ephemeral within each request, for all requests of this client.
89+ * Useful for services that makes recursive requests, like graphql resolvers, which
90+ * might fetch the same endpoint more than once.
91+ * If that's not the case for your service, disabling it might improve the CPU and
92+ * memory usage.
93+ *
94+ * Default value: true
95+ */
96+ memoizable ?: boolean
97+
8698 baseURL ?: string
8799 retries ?: number
88100 exponentialTimeoutCoefficient ?: number
You can’t perform that action at this time.
0 commit comments