Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@apollo/datasource-rest

Package Overview
Dependencies
Maintainers
4
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@apollo/datasource-rest - npm Package Compare versions

Comparing version 5.0.2 to 5.1.0

2

dist/HTTPCache.d.ts
/// <reference types="node" />
import type { Options as HttpCacheSemanticsOptions } from 'http-cache-semantics';
import type { Fetcher, FetcherResponse, FetcherRequestInit } from '@apollo/utils.fetcher';
import { KeyValueCache } from '@apollo/utils.keyvaluecache';
import { type KeyValueCache } from '@apollo/utils.keyvaluecache';
import type { CacheOptions, RequestOptions, ValueOrPromise } from './RESTDataSource';

@@ -6,0 +6,0 @@ interface ResponseWithCacheWritePromise {

@@ -7,2 +7,3 @@ /// <reference types="node" />

import { HTTPCache } from './HTTPCache';
import type { Logger } from '@apollo/utils.logger';
import type { Options as HttpCacheSemanticsOptions } from 'http-cache-semantics';

@@ -51,2 +52,3 @@ export type ValueOrPromise<T> = T | Promise<T>;

fetch?: Fetcher;
logger?: Logger;
}

@@ -80,2 +82,3 @@ export interface RequestDeduplicationResult {

baseURL?: string;
logger: Logger;
constructor(config?: DataSourceConfig);

@@ -82,0 +85,0 @@ protected cacheKeyFor(url: URL, request: RequestOptions): string;

@@ -13,4 +13,6 @@ "use strict";

constructor(config) {
var _a;
this.deduplicationPromises = new Map();
this.httpCache = new HTTPCache_1.HTTPCache(config === null || config === void 0 ? void 0 : config.cache, config === null || config === void 0 ? void 0 : config.fetch);
this.logger = (_a = config === null || config === void 0 ? void 0 : config.logger) !== null && _a !== void 0 ? _a : console;
}

@@ -259,3 +261,3 @@ cacheKeyFor(url, request) {

cacheWritePromise.catch((e) => {
console.error(`Error writing from RESTDataSource to cache: ${e}`);
this.logger.error(`Error writing from RESTDataSource to cache: ${e}`);
});

@@ -272,3 +274,3 @@ }

const label = `${request.method || 'GET'} ${url}`;
console.log(`${label} (${duration}ms)`);
this.logger.info(`${label} (${duration}ms)`);
}

@@ -275,0 +277,0 @@ }

{
"name": "@apollo/datasource-rest",
"description": "REST DataSource for Apollo Server v4",
"version": "5.0.2",
"version": "5.1.0",
"author": "Apollo <packages@apollographql.com>",

@@ -27,24 +27,28 @@ "license": "MIT",

"publish-changeset": "changeset publish",
"spell-check": "cspell lint '**' --no-progress || (echo 'Add any real words to cspell-dict.txt.'; exit 1)",
"spell-check": "cspell lint '**' '.changeset/**' --no-progress || (echo 'Add any real words to cspell-dict.txt.'; exit 1)",
"test": "jest",
"test:ci": "jest --coverage --ci --maxWorkers=2 --reporters=default --reporters=jest-junit",
"watch": "tsc --build --watch"
"watch": "tsc --build --watch",
"lint": "eslint src/**/*.ts"
},
"devDependencies": {
"@apollo/server": "4.3.2",
"@apollo/server": "4.7.0",
"@changesets/changelog-github": "0.4.8",
"@changesets/cli": "2.26.0",
"@types/jest": "29.4.0",
"@changesets/cli": "2.26.1",
"@types/jest": "29.5.1",
"@types/lodash.isplainobject": "4.0.7",
"@types/node": "14.18.36",
"cspell": "6.22.0",
"@types/node": "14.18.42",
"@typescript-eslint/eslint-plugin": "5.59.0",
"@typescript-eslint/parser": "5.59.0",
"cspell": "6.31.1",
"eslint": "8.39.0",
"form-data": "4.0.0",
"graphql": "16.6.0",
"jest": "29.4.1",
"jest-junit": "15.0.0",
"jest": "29.5.0",
"jest-junit": "16.0.0",
"nock": "13.3.0",
"prettier": "2.8.3",
"ts-jest": "29.0.5",
"prettier": "2.8.8",
"ts-jest": "29.1.0",
"ts-node": "10.9.1",
"typescript": "4.9.5"
"typescript": "5.0.4"
},

@@ -54,2 +58,3 @@ "dependencies": {

"@apollo/utils.keyvaluecache": "^2.0.0",
"@apollo/utils.logger": "^2.0.1",
"@apollo/utils.withrequired": "^2.0.0",

@@ -65,5 +70,5 @@ "@types/http-cache-semantics": "^4.0.1",

"volta": {
"node": "18.14.0",
"npm": "9.4.1"
"node": "18.16.0",
"npm": "9.6.5"
}
}

@@ -56,2 +56,21 @@ # Apollo REST Data Source

#### Constructor
The `RESTDataSource` takes in a `DataSourceConfig` which allows for overriding some default behavior.
Configuration Overrides
- `cache` - Custom [`KeyValueCache`](https://www.npmjs.com/package/@apollo/utils.keyvaluecache) implementation
- `fetch` - Custom [`Fetcher`](https://www.npmjs.com/package/@apollo/utils.fetcher) implementation
- `logger` - Custom [`Logger`](https://www.npmjs.com/package/@apollo/utils.logger) implementation that will replace all logging activity within `RESTDataSource`
To override the RESTDataSource, see the following example code:
```typescript
const dataSource = new (class extends RESTDataSource {})({
cache: customCache,
fetch: customFetcher,
logger: customLogger,
});
```
#### Properties

@@ -58,0 +77,0 @@

@@ -14,4 +14,4 @@ import nodeFetch, {

import {
type KeyValueCache,
InMemoryLRUCache,
KeyValueCache,
PrefixingKeyValueCache,

@@ -18,0 +18,0 @@ } from '@apollo/utils.keyvaluecache';

@@ -11,2 +11,3 @@ import type {

import { HTTPCache } from './HTTPCache';
import type { Logger } from '@apollo/utils.logger';
import type { Options as HttpCacheSemanticsOptions } from 'http-cache-semantics';

@@ -128,2 +129,3 @@

fetch?: Fetcher;
logger?: Logger;
}

@@ -180,5 +182,7 @@

baseURL?: string;
logger: Logger;
constructor(config?: DataSourceConfig) {
this.httpCache = new HTTPCache(config?.cache, config?.fetch);
this.logger = config?.logger ?? console;
}

@@ -611,3 +615,3 @@

cacheWritePromise.catch((e) => {
console.error(`Error writing from RESTDataSource to cache: ${e}`);
this.logger.error(`Error writing from RESTDataSource to cache: ${e}`);
});

@@ -629,3 +633,3 @@ }

const label = `${request.method || 'GET'} ${url}`;
console.log(`${label} (${duration}ms)`);
this.logger.info(`${label} (${duration}ms)`);
}

@@ -632,0 +636,0 @@ } else {

@@ -21,3 +21,4 @@ {

"forceConsistentCasingInFileNames": true,
"importsNotUsedAsValues": "error",
// TODO(esm): enable if this package is ever ESM-only
// "verbatimModuleSyntax": true,
"lib": ["es2019", "esnext.asynciterable"],

@@ -24,0 +25,0 @@ "types": ["node"],

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