apollographql / datasource-rest

A caching data source for REST APIs
MIT License
39 stars 20 forks source link

Fix CacheOptions Related Types #267

Closed HishamAli81 closed 1 year ago

HishamAli81 commented 1 year ago

Problem:

There are a couple issues with the CacheOptions related types.

First, the RequestOptions.cacheOptions function returns a Promise<CO | undefined>, whereas the RESTDataSource.cacheOptionsFor() and HttpCache.fetch() functions both accept a function that returns ValueOrPromise<CO | undefined>.

Second, there are a number of places where the CO cache option generics argument is being propagated through to RequestOptions and AugmentedRequest

HishamAli81 commented 1 year ago

I've created this PR to fix some of the type issues: https://github.com/apollographql/datasource-rest/pull/268. It's a follow up to this PR: https://github.com/apollographql/datasource-rest/pull/185 that I created & was already merged.