deno.land / x / pothos@release-1713397530 / packages / plugin-dataloader / refs / object.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// @ts-nocheck/* eslint-disable max-classes-per-file */import DataLoader from 'https://cdn.skypack.dev/dataloader?dts';import { ImplementableObjectRef, ObjectRef, SchemaTypes } from '../../core/index.ts';import { DataLoaderOptions } from '../types.ts';import { dataloaderGetter } from '../util.ts';export class LoadableObjectRef<Types extends SchemaTypes, RefShape, Shape, Key, CacheKey> extends ObjectRef<RefShape, Shape> { getDataloader; constructor(name: string, getDataloader: (context: Types["Context"]) => DataLoader<Key, Shape, CacheKey>) { super(name); this.getDataloader = getDataloader; }}export class ImplementableLoadableObjectRef<Types extends SchemaTypes, RefShape, Shape, Key extends bigint | number | string, CacheKey> extends ImplementableObjectRef<Types, RefShape, Shape> { getDataloader; protected cacheResolved; constructor(builder: PothosSchemaTypes.SchemaBuilder<Types>, name: string, { loaderOptions, load, toKey, sort, cacheResolved, }: DataLoaderOptions<Types, Shape, Key, CacheKey>) { super(builder, name); this.getDataloader = dataloaderGetter<Key, Shape, CacheKey>(loaderOptions, load, toKey, sort); this.cacheResolved = typeof cacheResolved === "function" ? cacheResolved : cacheResolved && toKey; this.builder.configStore.onTypeConfig(this, (config) => { // eslint-disable-next-line no-param-reassign config.extensions = { ...config.extensions, getDataloader: this.getDataloader, cacheResolved: this.cacheResolved, }; }); }}
pothos

Version Info

Tagged at
a year ago