Socket
Socket
Sign inDemoInstall

apollo-datasource-http

Package Overview
Dependencies
62
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.17.1 to 0.18.0

18

dist/src/http-data-source.js

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

constructor(baseURL, options) {
var _a, _b, _c;
var _a, _b, _c, _d, _e;
super();

@@ -34,4 +34,5 @@ this.baseURL = baseURL;

maxSize: ((_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.lru) === null || _b === void 0 ? void 0 : _b.maxSize) ? this.options.lru.maxSize : 100,
maxAge: (_d = (_c = this.options) === null || _c === void 0 ? void 0 : _c.lru) === null || _d === void 0 ? void 0 : _d.maxAge,
});
this.pool = (_c = options === null || options === void 0 ? void 0 : options.pool) !== null && _c !== void 0 ? _c : new undici_1.Pool(this.baseURL, options === null || options === void 0 ? void 0 : options.clientOptions);
this.pool = (_e = options === null || options === void 0 ? void 0 : options.pool) !== null && _e !== void 0 ? _e : new undici_1.Pool(this.baseURL, options === null || options === void 0 ? void 0 : options.clientOptions);
this.globalRequestOptions = options === null || options === void 0 ? void 0 : options.requestOptions;

@@ -58,3 +59,3 @@ this.logger = options === null || options === void 0 ? void 0 : options.logger;

isResponseOk(statusCode) {
return (statusCode >= 200 && statusCode <= 399) || statusCode === 304;
return statusCode >= 200 && statusCode <= 399;
}

@@ -191,7 +192,7 @@ isResponseCacheable(request, response) {

}
throw apollo_server_errors_1.toApolloError(error);
throw (0, apollo_server_errors_1.toApolloError)(error);
}
}
async request(request) {
var _a;
var _a, _b;
if (Object.keys(request.query).length > 0) {

@@ -209,5 +210,10 @@ request.path = request.path + '?' + this.buildQueryString(request.query);

}
const headers = {
...(((_a = this.globalRequestOptions) === null || _a === void 0 ? void 0 : _a.headers) || {}),
...request.headers,
};
const options = {
...request,
...this.globalRequestOptions,
headers,
};

@@ -229,3 +235,3 @@ if (options.method === 'GET') {

catch (error) {
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.error(`Cache item '${cacheKey}' could not be loaded: ${error.message}`);
(_b = this.logger) === null || _b === void 0 ? void 0 : _b.error(`Cache item '${cacheKey}' could not be loaded: ${error.message}`);
}

@@ -232,0 +238,0 @@ }

{
"name": "apollo-datasource-http",
"version": "0.17.1",
"version": "0.18.0",
"author": "Dustin Deus <deusdustin@gmail.com>",

@@ -53,24 +53,29 @@ "license": "MIT",

"@alloc/quick-lru": "^5.2.0",
"apollo-datasource": "^0.9.0",
"apollo-server-caching": "^0.7.0",
"apollo-server-errors": "^2.5.0",
"apollo-server-types": "^0.9.0",
"graphql": "^15.5.1",
"undici": "^4.4.2"
"apollo-datasource": "^3.3.0",
"apollo-server-caching": "^3.3.0",
"apollo-server-errors": "^3.3.0",
"apollo-server-types": "^3.4.0",
"undici": "^4.12.1"
},
"peerDependencies": {
"graphql": "^15.3.0 || ^16.0.0"
},
"devDependencies": {
"@sinonjs/fake-timers": "^8.1.0",
"@tsconfig/node12": "^1.0.9",
"@types/node": "^14.17.3",
"@types/node": "^17.0.5",
"@types/sinonjs__fake-timers": "^8.1.1",
"abort-controller": "^3.0.0",
"apollo-datasource-rest": "^0.14.0",
"apollo-datasource-rest": "^3.4.0",
"ava": "^3.15.0",
"graphql": "^16.2.0",
"h2url": "^0.2.0",
"nock": "^13.1.1",
"nock": "^13.2.1",
"nyc": "^15.1.0",
"prettier": "^2.3.2",
"release-it": "^14.11.3",
"ts-node": "^10.2.0",
"typescript": "^4.3.5",
"prettier": "^2.5.1",
"release-it": "^14.11.8",
"ts-node": "^10.4.0",
"typescript": "^4.5.4",
"uid": "^2.0.0"
}
}

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

- Uses [Undici](https://github.com/nodejs/undici) under the hood. It's around `54%` faster than `apollo-datasource-rest`
- Uses [Undici](https://github.com/nodejs/undici) under the hood. It's around `56%` faster than `apollo-datasource-rest`
- Request Deduplication (LRU), Request Cache (TTL) and `stale-if-error` Cache (TTL)

@@ -113,4 +113,4 @@ - Support [AbortController ](https://github.com/mysticatea/abort-controller) to manually cancel all running requests

requestCache: {
maxTtl: 1000 * 60 * 10, // 10min, will respond for 10min with the cached result (updated every 10min)
maxTtlIfError: 1000 * 60 * 30, // 30min, will respond with the cached response in case of an error (for further 20min)
maxTtl: 10 * 60, // 10min, will respond for 10min with the cached result (updated every 10min)
maxTtlIfError: 30 * 60, // 30min, will respond with the cached response in case of an error (for further 20min)
},

@@ -117,0 +117,0 @@ })

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc