import type { FieldKind, FieldMap, FieldNullability, FieldRef, InputFieldMap, InterfaceParam, NormalizeArgs, OutputType, PluginName, SchemaTypes, ShapeFromTypeParam, TypeParam, } from '@pothos/core'; import type { GraphQLResolveInfo } from 'graphql'; import type { PothosPrismaPlugin } from '.'; import type { PrismaInterfaceRef, PrismaRef } from './interface-ref'; import type { PrismaNodeRef } from './node-ref'; import type { PrismaObjectRef, prismaModelKey } from './object-ref'; import type { PrismaObjectFieldBuilder as InternalPrismaObjectFieldBuilder } from './prisma-field-builder'; import { type PrismaClient, type PrismaConnectionFieldOptions, type PrismaConnectionShape, type PrismaFieldOptions, type PrismaFieldWithInputOptions, type PrismaInterfaceTypeOptions, type PrismaModelTypes, type PrismaNodeOptions, type PrismaObjectFieldOptions, type PrismaObjectTypeOptions, prismaModelName, type ShapeFromConnection, type ShapeFromSelection, } from './types'; declare global { export namespace PothosSchemaTypes { export interface Plugins { prisma: PothosPrismaPlugin; } export interface SchemaBuilderOptions { prisma: | { filterConnectionTotalCount?: boolean; client: (ctx: Types['Context']) => PrismaClient; dmmf: { datamodel: unknown }; exposeDescriptions?: | boolean | { models?: boolean; fields?: boolean; }; onUnusedQuery?: 'error' | 'warn' | ((info: GraphQLResolveInfo) => void) | null; maxConnectionSize?: number; defaultConnectionSize?: number; skipDeferredFragments?: boolean; } | { filterConnectionTotalCount?: boolean; client: PrismaClient; dmmf: { datamodel: unknown }; exposeDescriptions?: | boolean | { models?: boolean; fields?: boolean; }; onUnusedQuery?: 'error' | 'warn' | ((info: GraphQLResolveInfo) => void) | null; maxConnectionSize?: number; defaultConnectionSize?: number; skipDeferredFragments?: boolean; }; } export interface UserSchemaTypes { PrismaTypes: {}; } export interface ExtendDefaultTypes> { PrismaTypes: PartialTypes['PrismaTypes'] & {}; } export interface PothosKindToGraphQLType { PrismaObject: 'Object'; } export interface FieldOptionsByKind< Types extends SchemaTypes, ParentShape, Type extends TypeParam, Nullable extends FieldNullability, Args extends InputFieldMap, ResolveShape, ResolveReturnShape, > { PrismaObject: PrismaObjectFieldOptions< Types, ParentShape, Type, Nullable, Args, ResolveShape, ResolveReturnShape >; } export interface SchemaBuilder { prismaObject: < Name extends keyof Types['PrismaTypes'], const Interfaces extends InterfaceParam[], Model extends PrismaModelTypes & Types['PrismaTypes'][Name], Include = unknown, Select = unknown, >( name: Name, options: PrismaObjectTypeOptions< Types, Model, Interfaces, Include, Select, ShapeFromSelection >, ) => PrismaObjectRef< Types, Model, ShapeFromSelection >; prismaInterface: < Name extends keyof Types['PrismaTypes'], const Interfaces extends InterfaceParam[], Model extends PrismaModelTypes & Types['PrismaTypes'][Name], Include = unknown, Select = unknown, >( name: Name, options: PrismaInterfaceTypeOptions< Types, Model, Interfaces, Include, Select, ShapeFromSelection >, ) => PrismaInterfaceRef< Types, Model, ShapeFromSelection >; prismaObjectField: < Type extends PrismaObjectRef | keyof Types['PrismaTypes'], Model extends PrismaModelTypes = Type extends PrismaObjectRef ? M : PrismaModelTypes & Types['PrismaTypes'][Type & keyof Types['PrismaTypes']], Shape extends {} = Type extends PrismaObjectRef ? S & { [prismaModelName]?: Model['Name'] } : Model['Shape'] & { [prismaModelName]?: Type; }, >( type: Type, fieldName: string, field: (t: PrismaObjectFieldBuilder) => FieldRef, ) => void; prismaInterfaceField: < Type extends PrismaInterfaceRef | keyof Types['PrismaTypes'], Model extends PrismaModelTypes = Type extends PrismaInterfaceRef ? M : PrismaModelTypes & Types['PrismaTypes'][Type & keyof Types['PrismaTypes']], Shape extends {} = Type extends PrismaInterfaceRef ? S & { [prismaModelName]?: Model['Name'] } : Model['Shape'] & { [prismaModelName]?: Type; }, >( type: Type, fieldName: string, field: (t: PrismaObjectFieldBuilder) => FieldRef, ) => void; prismaObjectFields: < Type extends PrismaObjectRef | keyof Types['PrismaTypes'], Model extends PrismaModelTypes = Type extends PrismaObjectRef ? M : PrismaModelTypes & Types['PrismaTypes'][Type & keyof Types['PrismaTypes']], Shape extends {} = Type extends PrismaObjectRef ? S & { [prismaModelName]?: Model['Name'] } : Model['Shape'] & { [prismaModelName]?: Type; }, >( type: Type, fields: (t: PrismaObjectFieldBuilder) => FieldMap, ) => void; prismaInterfaceFields: < Type extends PrismaInterfaceRef | keyof Types['PrismaTypes'], Model extends PrismaModelTypes = Type extends PrismaInterfaceRef ? M : PrismaModelTypes & Types['PrismaTypes'][Type & keyof Types['PrismaTypes']], Shape extends {} = Type extends PrismaInterfaceRef ? S & { [prismaModelName]?: Model['Name'] } : Model['Shape'] & { [prismaModelName]?: Type; }, >( type: Type, fields: (t: PrismaObjectFieldBuilder) => FieldMap, ) => void; prismaNode: 'relay' extends PluginName ? < Name extends keyof Types['PrismaTypes'], Interfaces extends InterfaceParam[] = [], Include = unknown, Select = unknown, UniqueField = unknown, >( name: Name, options: PrismaNodeOptions< Types, PrismaModelTypes & Types['PrismaTypes'][Name], Interfaces, Include, Select, ShapeFromSelection< Types, PrismaModelTypes & Types['PrismaTypes'][Name], { select: Select; include: Include } >, UniqueField >, ) => PrismaNodeRef< Types, PrismaModelTypes & Types['PrismaTypes'][Name], ShapeFromSelection< Types, PrismaModelTypes & Types['PrismaTypes'][Name], { select: Select; include: Include } > > : '@pothos/plugin-relay is required to use this method'; } export interface RootFieldBuilder< Types extends SchemaTypes, ParentShape, Kind extends FieldKind = FieldKind, > { prismaField: < Args extends InputFieldMap, TypeParam extends // biome-ignore lint/suspicious/noExplicitAny: this is fine | PrismaRef | keyof Types['PrismaTypes'] | [keyof Types['PrismaTypes']] // biome-ignore lint/suspicious/noExplicitAny: this is fine | [PrismaRef], Nullable extends FieldNullability, ResolveShape, ResolveReturnShape, Type extends TypeParam extends [unknown] ? [ObjectRef] : ObjectRef, Model extends PrismaModelTypes = PrismaModelTypes & (TypeParam extends [keyof Types['PrismaTypes']] ? Types['PrismaTypes'][TypeParam[0]] : // biome-ignore lint/suspicious/noExplicitAny: this is fine TypeParam extends [PrismaRef] ? TypeParam[0][typeof prismaModelKey] : // biome-ignore lint/suspicious/noExplicitAny: this is fine TypeParam extends PrismaRef ? TypeParam[typeof prismaModelKey] : TypeParam extends keyof Types['PrismaTypes'] ? Types['PrismaTypes'][TypeParam] : never), >( options: PrismaFieldOptions< Types, ParentShape, TypeParam, Model, Type, Args, Nullable, ResolveShape, ResolveReturnShape, Kind >, ) => FieldRef>; prismaConnection: 'relay' extends PluginName ? < // biome-ignore lint/suspicious/noExplicitAny: this is fine Type extends PrismaRef | keyof Types['PrismaTypes'], Nullable extends boolean, ResolveReturnShape, Args extends InputFieldMap = {}, // biome-ignore lint/suspicious/noExplicitAny: this is fine Model extends PrismaModelTypes = Type extends PrismaRef ? T : PrismaModelTypes & Types['PrismaTypes'][Type & keyof Types['PrismaTypes']], // biome-ignore lint/suspicious/noExplicitAny: this is fine Shape = Type extends PrismaRef ? S : Model['Shape'], const ConnectionInterfaces extends InterfaceParam[] = [], const EdgeInterfaces extends InterfaceParam[] = [], >( options: PrismaConnectionFieldOptions< Types, ParentShape, Type, Model, ObjectRef, Nullable, Args, ResolveReturnShape, Kind >, ...args: NormalizeArgs< [ connectionOptions: | ConnectionObjectOptions< Types, ObjectRef, false, false, PrismaConnectionShape, ConnectionInterfaces > | ObjectRef< Types, ShapeFromConnection> >, edgeOptions: | ConnectionEdgeObjectOptions< Types, ObjectRef, false, PrismaConnectionShape, EdgeInterfaces > | ObjectRef< Types, { cursor: string; node?: Shape | null | undefined; } >, ], 0 > ) => FieldRef< Types, ShapeFromConnection> > : '@pothos/plugin-relay is required to use this method'; prismaFieldWithInput: 'withInput' extends PluginName ? < Fields extends InputFieldMap, TypeParam extends // biome-ignore lint/suspicious/noExplicitAny: this is fine | PrismaRef | keyof Types['PrismaTypes'] | [keyof Types['PrismaTypes']] // biome-ignore lint/suspicious/noExplicitAny: this is fine | [PrismaRef], Type extends TypeParam extends [unknown] ? [ObjectRef] : ObjectRef, ResolveShape, ResolveReturnShape, ArgRequired extends boolean, Args extends InputFieldMap = {}, Nullable extends FieldNullability = Types['DefaultFieldNullability'], InputName extends string = 'input', Model extends PrismaModelTypes = PrismaModelTypes & (TypeParam extends [keyof Types['PrismaTypes']] ? Types['PrismaTypes'][TypeParam[0]] : // biome-ignore lint/suspicious/noExplicitAny: this is fine TypeParam extends [PrismaRef] ? TypeParam[0][typeof prismaModelKey] : // biome-ignore lint/suspicious/noExplicitAny: this is fine TypeParam extends PrismaRef ? TypeParam[typeof prismaModelKey] : TypeParam extends keyof Types['PrismaTypes'] ? Types['PrismaTypes'][TypeParam] : never), >( options: PrismaFieldWithInputOptions< Types, ParentShape, Kind, Args, Fields, TypeParam, Model, Type, Nullable, InputName, ResolveShape, ResolveReturnShape, boolean extends ArgRequired ? (Types & { WithInputArgRequired: boolean })['WithInputArgRequired'] : ArgRequired >, ) => FieldRef> : '@pothos/plugin-with-input is required to use this method'; } export interface ConnectionFieldOptions< Types extends SchemaTypes, ParentShape, Type extends OutputType, Nullable extends boolean, EdgeNullability extends FieldNullability<[unknown]>, NodeNullability extends boolean, Args extends InputFieldMap, ResolveReturnShape, > {} export interface ConnectionObjectOptions< Types extends SchemaTypes, Type extends OutputType, EdgeNullability extends FieldNullability<[unknown]>, NodeNullability extends boolean, Resolved, Interfaces extends InterfaceParam[] = [], > {} export interface ConnectionEdgeObjectOptions< Types extends SchemaTypes, Type extends OutputType, NodeNullability extends boolean, Resolved, Interfaces extends InterfaceParam[] = [], > {} export interface DefaultConnectionArguments { first?: number | null | undefined; last?: number | null | undefined; before?: string | null | undefined; after?: string | null | undefined; } export interface ConnectionShapeHelper {} export interface ScopeAuthFieldAuthScopes< Types extends SchemaTypes, Parent, Args extends {} = {}, > {} export interface ScopeAuthContextForAuth {} export interface PrismaObjectFieldBuilder< Types extends SchemaTypes, Model extends PrismaModelTypes, Shape extends object = Model['Shape'], > extends InternalPrismaObjectFieldBuilder, RootFieldBuilder {} export interface FieldWithInputBaseOptions< Types extends SchemaTypes, Args extends InputFieldMap, Fields extends InputFieldMap, InputName extends string, ArgRequired extends boolean, > {} } }