import type { FieldKind, FieldNullability, FieldRef, InputFieldMap, InterfaceParam, ObjectParam, OutputType, PluginName, SchemaTypes, ShapeFromTypeParam, TypeParam, } from '@pothos/core'; import type { LoadableGroupFieldOptions, LoadableInterfaceOptions, LoadableListFieldOptions, LoadableUnionOptions, PothosDataloaderPlugin, ShapeFromLoadResult, } from './index.js'; import type { ImplementableLoadableNodeRef, LoadableNodeRef } from './refs/index.js'; import type { ImplementableLoadableInterfaceRef, LoadableInterfaceRef } from './refs/interface.js'; import type { ImplementableLoadableObjectRef, LoadableObjectRef } from './refs/object.js'; import type { LoadableUnionRef } from './refs/union.js'; import type { DataLoaderOptions, DataloaderObjectTypeOptions, LoadableFieldOptions, LoadableNodeId, LoadableNodeOptions, } from './types.js'; declare global { export namespace PothosSchemaTypes { export interface Plugins { dataloader: PothosDataloaderPlugin; } export interface SchemaBuilder { loadableObject: < LoadResult extends NameOrRef extends ObjectParam ? ShapeFromTypeParam | Error : unknown, Key extends bigint | number | string, Interfaces extends InterfaceParam[], NameOrRef extends ObjectParam | string, CacheKey = Key, Shape = ShapeFromLoadResult, >( nameOrRef: NameOrRef, options: DataloaderObjectTypeOptions< Types, LoadResult, Key, Interfaces, NameOrRef, CacheKey, Shape >, ) => LoadableObjectRef; loadableInterface: < LoadResult extends NameOrRef extends InterfaceParam ? ShapeFromTypeParam | Error : unknown, Key extends bigint | number | string, Interfaces extends InterfaceParam[], NameOrRef extends InterfaceParam | string, CacheKey = Key, Shape = ShapeFromLoadResult, >( nameOrRef: NameOrRef, options: LoadableInterfaceOptions< Types, LoadResult, Key, Interfaces, NameOrRef, CacheKey, Shape >, ) => LoadableInterfaceRef; loadableObjectRef: < LoadResult, Key extends bigint | number | string, CacheKey = Key, Shape = ShapeFromLoadResult, >( name: string, options: DataLoaderOptions, ) => ImplementableLoadableObjectRef; loadableInterfaceRef: < LoadResult, Key extends bigint | number | string, CacheKey = Key, Shape = ShapeFromLoadResult, >( name: string, options: DataLoaderOptions, ) => ImplementableLoadableInterfaceRef; loadableNodeRef: < LoadResult, IDShape extends bigint | number | string = string, Key extends bigint | number | string = IDShape, CacheKey = Key, Shape = ShapeFromLoadResult, >( name: string, options: DataLoaderOptions & LoadableNodeId, ) => ImplementableLoadableNodeRef; loadableUnion: < Key extends bigint | number | string, Member extends ObjectParam, CacheKey = Key, Shape = ShapeFromTypeParam, >( name: string, options: LoadableUnionOptions, ) => LoadableUnionRef; loadableNode: 'relay' extends PluginName ? < LoadResult extends NameOrRef extends ObjectParam ? ShapeFromTypeParam | Error : unknown, Interfaces extends InterfaceParam[], NameOrRef extends ObjectParam | string, IDShape extends bigint | number | string = string, Key extends bigint | number | string = IDShape, CacheKey = Key, Shape = ShapeFromLoadResult, >( nameOrRef: NameOrRef, options: LoadableNodeOptions< Types, LoadResult, Interfaces, NameOrRef, IDShape, Key, CacheKey, Shape >, ) => LoadableNodeRef : '@pothos/plugin-relay is required to use this method'; } export interface RootFieldBuilder< Types extends SchemaTypes, ParentShape, Kind extends FieldKind = FieldKind, > { loadable: < Args extends InputFieldMap, Type extends TypeParam, Key, CacheKey, ResolveReturnShape, Nullable extends FieldNullability = Types['DefaultFieldNullability'], ByPath extends boolean = boolean, >( options: LoadableFieldOptions< Types, ParentShape, Type, Nullable, Args, ResolveReturnShape, Key, CacheKey, Kind, ByPath >, ) => FieldRef; loadableList: < Args extends InputFieldMap, Type extends OutputType, Key, CacheKey, ResolveReturnShape, Nullable extends FieldNullability<[Type]> = Types['DefaultFieldNullability'], ByPath extends boolean = boolean, >( options: LoadableListFieldOptions< Types, ParentShape, Type, Nullable, Args, ResolveReturnShape, Key, CacheKey, Kind, ByPath >, ) => FieldRef; loadableGroup: < Args extends InputFieldMap, Type extends OutputType, Key, CacheKey, ResolveReturnShape, Nullable extends FieldNullability<[Type]> = Types['DefaultFieldNullability'], ByPath extends boolean = boolean, >( options: LoadableGroupFieldOptions< Types, ParentShape, Type, Nullable, Args, ResolveReturnShape, Key, CacheKey, Kind, ByPath >, ) => FieldRef; } } }