Skip to content

Commit

Permalink
Add warning when using external caching with transformers
Browse files Browse the repository at this point in the history
  • Loading branch information
Didas-git committed Apr 5, 2024
1 parent 1ac5872 commit bb60376
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/core/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,13 @@ export class Client<T extends Transformers = Transformers, C extends CacheManage
//#endregion
//#region Cache handlers
if (typeof caching !== "undefined" && caching.delegate !== CachingDelegationType.TRANSFORMERS) {
if (caching.delegate === CachingDelegationType.EXTERNAL) throw new Error("External caching is not yet supported");
if (caching.delegate === CachingDelegationType.EXTERNAL && caching.applyTransformers === true && !caching.safeToTransform) {
process.emitWarning("Transformers will be applied to external solution!", {
code: "EXTERNAL_TRANSFORMERS",
detail: "Some external caching managers might not support transformers, please read their documentation before proceeding."
});
}

if (Object.keys(caching.enabled).length === 0) throw new Error("");

const defaults: SelectiveCache = {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/typings/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ interface BaseCachingStructure {
export interface ExternalCache extends BaseCachingStructure {
delegate: CachingDelegationType.EXTERNAL;
manager: CacheManagerStructure;
safeToTransform?: boolean;
}

export interface TransformersCache extends BaseCachingStructure {
Expand Down

0 comments on commit bb60376

Please sign in to comment.