Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colocate make-fetch-happen types within packages #4333

Merged
merged 4 commits into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-federation/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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<Boolean>;
put(req: Request, res: Response): Promise<Response>;
match(req: Request): Promise<Response | undefined>;
}

/**
* 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;
}