@pothos/plugin-dataloader
Version:
A Pothos plugin for attaching dataloader to object types
41 lines (40 loc) • 1.45 kB
JavaScript
function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
}
else {
obj[key] = value;
}
return obj;
}
import { ImplementableInterfaceRef, InterfaceRef } from '@pothos/core';
import { dataloaderGetter } from '../util.js';
export class LoadableInterfaceRef extends InterfaceRef {
constructor(name, getDataloader) {
super(name), _define_property(this, "getDataloader", void 0);
this.getDataloader = getDataloader;
}
}
export class ImplementableLoadableInterfaceRef extends ImplementableInterfaceRef {
implement(options) {
return super.implement({
...options,
extensions: {
...options.extensions,
getDataloader: this.getDataloader,
cacheResolved: this.cacheResolved
}
});
}
constructor(builder, name, { loaderOptions, load, toKey, sort, cacheResolved }) {
super(builder, name), _define_property(this, "cacheResolved", void 0), _define_property(this, "getDataloader", void 0);
this.getDataloader = dataloaderGetter(loaderOptions, load, toKey, sort);
this.cacheResolved = typeof cacheResolved === "function" ? cacheResolved : cacheResolved && toKey;
}
}
//# sourceMappingURL=interface.js.map