Socket
Socket
Sign inDemoInstall

dataloader-factory

Package Overview
Dependencies
2
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.4.3 to 4.5.0

11

dist-esm/index.d.ts
import DataLoader from 'dataloader';
declare type MatchingKeyof<T, V> = keyof {
type MatchingKeyof<T, V> = keyof {
[P in keyof T as T[P] extends V ? P : never]: P;

@@ -10,3 +10,3 @@ };

abstract init(factory: DataLoaderFactory): any;
abstract getDataLoader(cached: any, filters?: FilterType): DataLoader<KeyType, ReturnType | undefined, string> | DataLoader<KeyType, ReturnType[], string>;
abstract getDataLoader(cached: any, factory: DataLoaderFactory, filters?: FilterType): DataLoader<KeyType, ReturnType | undefined, string> | DataLoader<KeyType, ReturnType[], string>;
addIdLoader(loader: PrimaryKeyLoader<any, ReturnType>): void;

@@ -41,8 +41,7 @@ }

constructor(config: BaseManyLoaderConfig<KeyType, ReturnType, FilterType>);
protected factory: DataLoaderFactory;
init(factory: DataLoaderFactory): Map<any, any>;
prime(loader: PrimaryKeyLoader<any, ReturnType>, items: any): void;
prime(loader: PrimaryKeyLoader<any, ReturnType>, factory: DataLoaderFactory, items: any): void;
abstract groupItems(items: ReturnType[] | ManyJoinedType<KeyType, ReturnType>[], dedupekeys: Map<string, KeyType>): Record<string, ReturnType[]>;
abstract filterItems(items: ReturnType[] | ManyJoinedType<KeyType, ReturnType>[], filters: FilterType | undefined): ReturnType[] | ManyJoinedType<KeyType, ReturnType>[];
getDataLoader(cached: Map<string, FilteredStorageObject<KeyType, ReturnType>>, filters?: FilterType): DataLoader<KeyType, ReturnType[], string>;
getDataLoader(cached: Map<string, FilteredStorageObject<KeyType, ReturnType>>, factory: DataLoaderFactory, filters?: FilterType): DataLoader<KeyType, ReturnType[], string>;
getCache(cached: Map<string, FilteredStorageObject<KeyType, ReturnType>>, filters?: FilterType): Map<string, Promise<ReturnType[]>> | undefined;

@@ -67,3 +66,3 @@ }

filterItems(items: ManyJoinedType<KeyType, ReturnType>[], filters: FilterType | undefined): ManyJoinedType<KeyType, ReturnType>[];
prime(loader: PrimaryKeyLoader<any, ReturnType>, items: ManyJoinedType<KeyType, ReturnType>[]): void;
prime(loader: PrimaryKeyLoader<any, ReturnType>, factory: DataLoaderFactory, items: ManyJoinedType<KeyType, ReturnType>[]): void;
}

@@ -70,0 +69,0 @@ export interface ManyToManyLoaderConfig<KeyType, ReturnType, FilterType> extends BaseManyLoaderConfig<KeyType, ReturnType, FilterType> {

@@ -74,11 +74,10 @@ "use strict";

init(factory) {
this.factory = factory;
return new Map();
}
prime(loader, items) {
prime(loader, factory, items) {
for (const item of items) {
this.factory.get(loader).prime(loader.extractId(item), item);
factory.get(loader).prime(loader.extractId(item), item);
}
}
getDataLoader(cached, filters) {
getDataLoader(cached, factory, filters) {
const filterstring = (0, txstate_utils_1.stringify)(filters);

@@ -96,5 +95,5 @@ let storageObject = cached.get(filterstring);

}
const items = this.filterItems(await this.config.fetch(Array.from(dedupekeys.values()), filters, this.factory.context), filters);
const items = this.filterItems(await this.config.fetch(Array.from(dedupekeys.values()), filters, factory.context), filters);
for (const loader of this.idLoaders) {
this.prime(loader, items);
this.prime(loader, factory, items);
}

@@ -187,5 +186,5 @@ const grouped = this.groupItems(items, dedupekeys);

}
prime(loader, items) {
prime(loader, factory, items) {
for (const item of items) {
this.factory.get(loader).prime(loader.extractId(item.value), item.value);
factory.get(loader).prime(loader.extractId(item.value), item.value);
}

@@ -302,3 +301,3 @@ }

}
return loader.getDataLoader(loaderCache, filters);
return loader.getDataLoader(loaderCache, this, filters);
}

@@ -305,0 +304,0 @@ async loadMany(loader, keys, filter) {

{
"name": "dataloader-factory",
"version": "4.4.3",
"version": "4.5.0",
"description": "DataLoader classes to make it easier to write complex graphql resolvers.",

@@ -14,3 +14,4 @@ "exports": {

"build": "rm -rf dist && tsc && mv dist/index.d.ts dist-esm/index.d.ts",
"test": "mocha -r ts-node/register test/**/*.ts"
"test": "mocha -r ts-node/register test/**/*.ts",
"lint": "eslint src/**/*.ts test/**/*.ts"
},

@@ -31,9 +32,9 @@ "repository": {

"@types/js-yaml": "^4.0.0",
"@types/mocha": "^9.0.0",
"@types/mocha": "^10.0.1",
"chai": "^4.3.0",
"eslint-config-standard-with-typescript": "^21.0.1",
"eslint-config-standard-with-typescript": "^37.0.0",
"js-yaml": "^4.0.0",
"mocha": "^9.1.1",
"mocha": "^10.2.0",
"ts-node": "^10.2.1",
"typescript": "^4.1.3"
"typescript": "^5.1.6"
},

@@ -40,0 +41,0 @@ "dependencies": {

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc