-
Notifications
You must be signed in to change notification settings - Fork 2k
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
RESTDataSource - fetch timeout #1594
Comments
I haven't checked it out yet, but it looks like it could be supported, since I believe From the node-fetch library (source): let inputBody =
init.body != null
? init.body
: isRequest(input) && input.body !== null
? clone(input)
: null
Body.call(this, inputBody, {
timeout: init.timeout || input.timeout || 0,
size: init.size || input.size || 0,
}) And the apollo-server-env (source) export declare class Request extends Body {
constructor(input: Request | string, init?: RequestInit);
readonly method: string;
readonly url: string;
readonly headers: Headers;
clone(): Request;
}
export interface RequestInit {
method?: string;
headers?: HeadersInit;
body?: BodyInit;
mode?: RequestMode;
credentials?: RequestCredentials;
cache?: RequestCache;
redirect?: RequestRedirect;
referrer?: string;
referrerPolicy?: ReferrerPolicy;
integrity?: string;
// Cloudflare Workers accept a `cf` property to control Cloudflare features
// See https://developers.cloudflare.com/workers/reference/cloudflare-features/
cf?: {
[key: string]: any;
};
} Here's a link to some tests (node-fetch) for the timeout extension. Haven't checked it out yet though. |
@sbrichardson I've confirmed it works. Thank you! |
@shinyaohira Awesome, would you mind sharing an example of the timeout setting you used, or the config object? Thanks |
@sbrichardson I'm using it like this: import { RequestInit } from "apollo-server-env";
...
const requestInit: RequestInit = {
timeout: 1000,
compress: true,
};
...
const result = await this.get<Item>("item", params, requestInit); |
I am using RESTDataSource to fetch data and want to set timeout for it. But RequestInit in apollo-server-env doesn't have timeout option.
The text was updated successfully, but these errors were encountered: