Skip to content

v6.2.0

Compare
Choose a tag to compare
@github-actions github-actions released this 18 Sep 16:54
· 106 commits to main since this release
965e64e

Minor Changes

  • #185 147f820 Thanks @HishamAli81! - Added support to the RESTDatasource to be able to specify a custom cache set options type. The cache set options may need to be customized to include additional set options supported by the underlying key value cache implementation.

    For example, if the InMemoryLRUCache is being used to cache HTTP responses, then noDisposeOnSet, noUpdateTTL, etc cache options can be provided to the LRU cache:

    import { InMemoryLRUCache } from '@apollo/utils.keyvaluecache';
    
    interface CustomCacheOptions {
      ttl?: number;
      noDisposeOnSet?: boolean;
    }
    
    class ExampleDataSource extends RESTDataSource<CustomCacheOptions> {
      override baseURL = 'https://api.example.com';
    
      constructor() {
        super({ cache: new InMemoryLRUCache() });
      }
    
      getData(id: number) {
        return this.get(`data/${id}`, {
          cacheOptions: { ttl: 3600, noDisposeOnSet: true },
        });
      }
    }