diff --git a/CHANGELOG.md b/CHANGELOG.md index c24dbb3ceb1..c728ed21560 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ The version headers in this history reflect the versions of Apollo Server itself > The changes noted within this `vNEXT` section have not been released yet. New PRs and commits which introduce changes should include an entry in this `vNEXT` section as part of their development. With few exceptions, the format of the entry should follow convention (i.e., prefix with package name, use markdown `backtick formatting` for package names and code, suffix with a link to the change-set à la `[PR #YYY](https://link/pull/YYY)`, etc.). When a release is being prepared, a new header will be (manually) created below and the appropriate changes within that release will be moved into the new section. -- _Nothing yet! Stay tuned!_ +- Reinstate typings for `make-fetch-happen` at the `apollo-gateway` project level (and now, additionally, `apollo-server-plugin-operation-registry`) [PR #4333](https://github.com/apollographql/apollo-server/pull/4333) ## v2.15.1 diff --git a/packages/apollo-federation/CHANGELOG.md b/packages/apollo-federation/CHANGELOG.md index 08c0730c48a..c2cce721e58 100644 --- a/packages/apollo-federation/CHANGELOG.md +++ b/packages/apollo-federation/CHANGELOG.md @@ -4,7 +4,7 @@ > The changes noted within this `vNEXT` section have not been released yet. New PRs and commits which introduce changes should include an entry in this `vNEXT` section as part of their development. When a release is being prepared, a new header will be (manually) created below and the appropriate changes within that release will be moved into the new section. -- _Nothing yet! Stay tuned!_ +- Reinstate typings for `make-fetch-happen` at the `apollo-gateway` project level (and now, additionally, `apollo-server-plugin-operation-registry`) [PR #4333](https://github.com/apollographql/apollo-server/pull/4333) ## 0.16.10 diff --git a/types/make-fetch-happen/index.d.ts b/packages/apollo-gateway/src/make-fetch-happen.d.ts similarity index 100% rename from types/make-fetch-happen/index.d.ts rename to packages/apollo-gateway/src/make-fetch-happen.d.ts diff --git a/packages/apollo-server-plugin-operation-registry/src/make-fetch-happen.d.ts b/packages/apollo-server-plugin-operation-registry/src/make-fetch-happen.d.ts new file mode 100644 index 00000000000..6b7f1737a10 --- /dev/null +++ b/packages/apollo-server-plugin-operation-registry/src/make-fetch-happen.d.ts @@ -0,0 +1,59 @@ +/** + * We are attempting to get types included natively in this package, but it + * has not happened, yet! + * + * See https://github.com/npm/make-fetch-happen/issues/20 + */ +declare module 'make-fetch-happen' { + import { + Response, + Request, + RequestInfo, + RequestInit, + } from 'apollo-server-env'; + + // If adding to these options, they should mirror those from `make-fetch-happen` + // @see: https://github.com/npm/make-fetch-happen/#extra-options + export interface FetcherOptions { + cacheManager?: string | CacheManager; + // @see: https://www.npmjs.com/package/retry#retrytimeoutsoptions + retry?: + | boolean + | number + | { + // The maximum amount of times to retry the operation. Default is 10. Seting this to 1 means do it once, then retry it once + retries?: number; + // The exponential factor to use. Default is 2. + factor?: number; + // The number of milliseconds before starting the first retry. Default is 1000. + minTimeout?: number; + // The maximum number of milliseconds between two retries. Default is Infinity. + maxTimeout?: number; + // Randomizes the timeouts by multiplying with a factor between 1 to 2. Default is false. + randomize?: boolean; + }; + onRetry?(): void; + } + + export interface CacheManager { + delete(req: Request): Promise; + put(req: Request, res: Response): Promise; + match(req: Request): Promise; + } + + /** + * This is an augmentation of the fetch function types provided by `apollo-server-env` + * @see: https://git.io/JvBwX + */ + export interface Fetcher { + (input?: RequestInfo, init?: RequestInit & FetcherOptions): Promise< + Response + >; + } + + let fetch: Fetcher & { + defaults(opts?: RequestInit & FetcherOptions): Fetcher; + }; + + export default fetch; +}