@graphql-tools/batch-delegate
Version:
A set of utils for faster development of GraphQL tools
21 lines (20 loc) • 718 B
JavaScript
import { getLoader } from './getLoader.js';
export function createBatchDelegateFn(optionsOrArgsFromKeys, lazyOptionsFn, dataLoaderOptions, valuesFromResults) {
return typeof optionsOrArgsFromKeys === 'function'
? createBatchDelegateFnImpl({
argsFromKeys: optionsOrArgsFromKeys,
lazyOptionsFn,
dataLoaderOptions,
valuesFromResults,
})
: createBatchDelegateFnImpl(optionsOrArgsFromKeys);
}
function createBatchDelegateFnImpl(options) {
return batchDelegateOptions => {
const loader = getLoader({
...options,
...batchDelegateOptions,
});
return loader.load(batchDelegateOptions.key);
};
}