Skip to content

v0.3.0

Compare
Choose a tag to compare
@github-actions github-actions released this 30 Apr 20:27
· 23 commits to main since this release

Minor Changes

  • 3fbea90: Move to keyv as cache implementation. This makes it compatible with various
    cache implementations. To update replace the client option with store and
    pass a Keyv instance.

import { dataloaderCache } from "@labdigital/dataloader-cache-wrapper"
import Keyv from 'keyv';

const redis = new Redis('redis://user:pass@localhost:6379');
const keyvRedis = new KeyvRedis(redis);

export const createProductBySlugLoader = () => {
return new DataLoader<ProductReference, any>(ProductDataLoader, {
maxBatchSize: 50,
});
};

export const ProductDataLoader = async
(keys: readonly any[]): Promise<(Product | null)[]> => {
return dataloaderCache(_uncachedProductDataLoader, keys, {
store: new Keyv({ store: keyvRedis }),
ttl: 3600,

  cacheKeysFn: (ref: ProductRef) => {
    const key = `${ref.store}-${ref.locale}-${ref.currency}`;
    return [`some-data:${key}:id:${ref.slug}`];
  },
})

}


## 0.2.0

### Minor Changes

- ffe9f26: Refactor to simplify the API by removing the lookupFn callback

## 0.1.1

### Patch Changes

- 0fd4457: Fix silly typo in latest change. bachLoadFn -> batchLoadFn

## 0.1.0

### Minor Changes

- 01243d5: Move all arguments to the options object for consistency
- dc082bf: Add support for adding a callback to prime the dataloader cache

## 0.0.5

### Patch Changes

- 822774e: Simplify the lookupFn function definition to improve the API

## 0.0.4

### Patch Changes

- 0edf554: Fix release artifact

## 0.0.3

### Patch Changes

- bedf41c: Fix ESM exports

## 0.0.2

### Patch Changes

- 95be409: Fix issue returning missing items from the dataloader