Socket
Socket
Sign inDemoInstall

apollo-datasource-http

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-datasource-http - npm Package Compare versions

Comparing version 0.7.0 to 0.8.0

25

dist/src/http-data-source.d.ts

@@ -10,4 +10,4 @@ import { DataSource, DataSourceConfig } from 'apollo-datasource';

};
export declare type RequestOptions = Omit<DispatchOptions, 'origin' | 'path' | 'method'> & CacheTTLOptions;
declare type InternalRequestOptions = DispatchOptions & CacheTTLOptions;
export declare type ClientRequestOptions = Omit<DispatchOptions, 'origin' | 'path' | 'method'> & CacheTTLOptions;
export declare type RequestOptions = DispatchOptions & CacheTTLOptions;
export declare type Response<TResult> = {

@@ -22,3 +22,3 @@ body: TResult;

pool?: Pool;
requestOptions?: RequestOptions;
requestOptions?: ClientRequestOptions;
clientOptions?: Client.Options;

@@ -40,15 +40,14 @@ lru?: Partial<LRUOptions>;

protected isResponseOk(statusCode: number): boolean;
protected isResponseCacheable<TResult = unknown>(requestOptions: InternalRequestOptions, response: Response<TResult>): boolean;
protected onCacheKeyCalculation(requestOptions: InternalRequestOptions): string;
protected onRequest?(requestOptions: RequestOptions): void;
protected onResponse<TResult = unknown>(response: Response<TResult>): Response<TResult>;
protected onError?(_error: Error): 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>>;
protected isResponseCacheable<TResult = unknown>(requestOptions: RequestOptions, response: Response<TResult>): boolean;
protected onCacheKeyCalculation(requestOptions: RequestOptions): string;
protected onRequest?(requestOptions: ClientRequestOptions): void;
protected onResponse<TResult = unknown>(_requestOptions: RequestOptions, response: Response<TResult>): Response<TResult>;
protected onError?(_error: Error, requestOptions: RequestOptions): void;
protected get<TResult = unknown>(path: string, requestOptions?: ClientRequestOptions): Promise<Response<TResult>>;
protected post<TResult = unknown>(path: string, requestOptions?: ClientRequestOptions): Promise<Response<TResult>>;
protected delete<TResult = unknown>(path: string, requestOptions?: ClientRequestOptions): Promise<Response<TResult>>;
protected put<TResult = unknown>(path: string, requestOptions?: ClientRequestOptions): Promise<Response<TResult>>;
private performRequest;
private request;
}
export {};
//# sourceMappingURL=http-data-source.d.ts.map

@@ -68,3 +68,3 @@ "use strict";

}
onResponse(response) {
onResponse(_requestOptions, response) {
if (this.isResponseOk(response.statusCode)) {

@@ -124,3 +124,3 @@ return response;

};
this.onResponse(response);
this.onResponse(options, response);
if (options.requestCache && this.isResponseCacheable(options, response)) {

@@ -133,3 +133,3 @@ this.storageAdapter.set(cacheKey, response, options.requestCache?.maxTtl);

catch (error) {
this.onError?.(error);
this.onError?.(error, options);
if (options.requestCache) {

@@ -136,0 +136,0 @@ const hasFallback = await this.storageAdapter.get(`staleIfError:${cacheKey}`);

@@ -1,2 +0,2 @@

export { HTTPDataSource, HTTPDataSourceOptions, LRUOptions, RequestOptions, Response } from './http-data-source';
export { HTTPDataSource, HTTPDataSourceOptions, LRUOptions, ClientRequestOptions, Response, RequestOptions, CacheTTLOptions, } from './http-data-source';
//# sourceMappingURL=index.d.ts.map
{
"name": "apollo-datasource-http",
"version": "0.7.0",
"version": "0.8.0",
"author": "Dustin Deus <deusdustin@gmail.com>",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -73,3 +73,3 @@ # Apollo HTTP Data Source

onResponse<TResult = unknown>(request: Request, response: Response<TResult>): void {
onResponse<TResult = unknown>(request: RequestOptions, response: Response<TResult>): void {
// manipulate response or handle unsuccessful response in a different way

@@ -79,3 +79,3 @@ return super.onResponse(request, response)

onError(error: RequestError): void {
onError(error: RequestError, request: RequestOptions): void {
// log errors

@@ -88,3 +88,3 @@ }

'X-Foo': 'bar',
}
},
})

@@ -118,2 +118,2 @@ }

This will limit the cache to 10MB and removes the least recently used keys from the cache when the cache hits the limits.
This will limit the cache to 10MB and removes the least recently used keys from the cache when the cache hits the limits.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc