apollo-datasource-http
Advanced tools
Comparing version 0.9.12 to 0.10.0
@@ -64,6 +64,6 @@ /// <reference types="node" /> | ||
protected onError?(_error: Error, requestOptions: Request): void; | ||
protected get<TResult = unknown>(path: string, requestOptions?: RequestOptions): Promise<Response<TResult>>; | ||
protected post<TResult = unknown>(path: string, requestOptions?: RequestOptions): Promise<Response<TResult>>; | ||
protected delete<TResult = unknown>(path: string, requestOptions?: RequestOptions): Promise<Response<TResult>>; | ||
protected put<TResult = unknown>(path: string, requestOptions?: RequestOptions): Promise<Response<TResult>>; | ||
get<TResult = unknown>(path: string, requestOptions?: RequestOptions): Promise<Response<TResult>>; | ||
post<TResult = unknown>(path: string, requestOptions?: RequestOptions): Promise<Response<TResult>>; | ||
delete<TResult = unknown>(path: string, requestOptions?: RequestOptions): Promise<Response<TResult>>; | ||
put<TResult = unknown>(path: string, requestOptions?: RequestOptions): Promise<Response<TResult>>; | ||
private performRequest; | ||
@@ -70,0 +70,0 @@ private request; |
{ | ||
"name": "apollo-datasource-http", | ||
"version": "0.9.12", | ||
"version": "0.10.0", | ||
"author": "Dustin Deus <deusdustin@gmail.com>", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -71,5 +71,12 @@ # Apollo HTTP Data Source | ||
// manipulate request before it is send | ||
// for example assign a AbortController signal to all requests and abort | ||
request.signal = this.context.abortController.signal | ||
setTimeout(() => { | ||
this.context.abortController.abort() | ||
}, 3000).unref() | ||
} | ||
onResponse<TResult = unknown>(request: Request, response: Response<TResult>): void { | ||
onResponse<TResult = unknown>(request: Request, response: Response<TResult>): Response<TResult> { | ||
// manipulate response or handle unsuccessful response in a different way | ||
@@ -88,2 +95,5 @@ return super.onResponse(request, response) | ||
}, | ||
context: { | ||
tracingName: 'getMovie', | ||
}, | ||
headers: { | ||
@@ -99,5 +109,2 @@ 'X-Foo': 'bar', | ||
})() | ||
// cancel all running requests e.g when the request is closed prematurely | ||
datasource.abort() | ||
``` | ||
@@ -110,3 +117,3 @@ | ||
- `onResponse` - Is executed when a response has been received. This can be used to alter the response before it is passed to caller or to log errors. | ||
- `onError` - Is executed for any error. | ||
- `onError` - Is executed for any request error. | ||
@@ -113,0 +120,0 @@ ## Error handling |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26597
130