UNPKG

@pothos/core

Version:

Pothos (formerly GiraphQL) is a plugin based schema builder for creating code-first GraphQL schemas in typescript

72 lines 7.02 kB
import { type GraphQLScalarSerializer, type GraphQLScalarType, GraphQLSchema } from 'graphql'; import { ConfigStore } from './config-store'; import { ImplementableInputObjectRef, InputObjectRef } from './refs/input-object'; import { ImplementableInterfaceRef } from './refs/interface'; import { MutationRef } from './refs/mutation'; import { ImplementableObjectRef } from './refs/object'; import { QueryRef } from './refs/query'; import { SubscriptionRef } from './refs/subscription'; import type { AbstractReturnShape, AddVersionedDefaultsToBuilderOptions, BaseEnum, EnumParam, EnumTypeOptions, EnumValues, InputFieldMap, InputFieldsFromShape, InputShape, InputShapeFromFields, InterfaceFieldsShape, InterfaceFieldThunk, InterfaceParam, InterfaceTypeOptions, MutationFieldsShape, MutationFieldThunk, NormalizeArgs, NormalizeSchemeBuilderOptions, ObjectFieldsShape, ObjectFieldThunk, ObjectParam, ObjectTypeOptions, OneOfInputShapeFromFields, OutputShape, ParentShape, PluginConstructorMap, QueryFieldsShape, QueryFieldThunk, RecursivelyNormalizeNullableFields, ScalarName, SchemaTypes, ShapeFromEnumValues, SubscriptionFieldsShape, SubscriptionFieldThunk, ValuesFromEnum } from './types'; export declare class SchemaBuilder<Types extends SchemaTypes> { $inferSchemaTypes: Types; private queryRef; private mutationRef; private subscriptionRef; static plugins: Partial<PluginConstructorMap<SchemaTypes>>; static optionNormalizers: Map<string, { v3?: (options: AddVersionedDefaultsToBuilderOptions<SchemaTypes, 'v3'>) => Partial<NormalizeSchemeBuilderOptions<SchemaTypes>>; v4?: undefined; }>; static allowPluginReRegistration: boolean; configStore: ConfigStore<Types>; options: PothosSchemaTypes.SchemaBuilderOptions<Types>; defaultFieldNullability: boolean; defaultInputFieldRequiredness: boolean; constructor(options: PothosSchemaTypes.SchemaBuilderOptions<Types>); static registerPlugin<T extends keyof PluginConstructorMap<SchemaTypes>>(name: T, plugin: PluginConstructorMap<SchemaTypes>[T], normalizeOptions?: { v3?: (options: AddVersionedDefaultsToBuilderOptions<SchemaTypes, 'v3'>) => Partial<NormalizeSchemeBuilderOptions<SchemaTypes>>; }): void; objectType<const Interfaces extends InterfaceParam<Types>[], Param extends ObjectParam<Types>>(param: Param, options: ObjectTypeOptions<Types, Param, ParentShape<Types, Param>, Interfaces>, fields?: ObjectFieldsShape<Types, ParentShape<Types, Param>>): PothosSchemaTypes.ObjectRef<Types, OutputShape<Types, Param>, ParentShape<Types, Param>>; objectFields<Type extends ObjectParam<Types>>(param: Type, fields: ObjectFieldsShape<Types, ParentShape<Types, Type>>): void; objectField<Type extends ObjectParam<Types>>(param: Type, fieldName: string, field: ObjectFieldThunk<Types, ParentShape<Types, Type>>): void; queryType(...args: NormalizeArgs<[ options: PothosSchemaTypes.QueryTypeOptions<Types>, fields?: QueryFieldsShape<Types> ], 0>): QueryRef<Types>; queryFields(fields: QueryFieldsShape<Types>): void; queryField(name: string, field: QueryFieldThunk<Types>): void; mutationType(...args: NormalizeArgs<[ options: PothosSchemaTypes.MutationTypeOptions<Types>, fields?: MutationFieldsShape<Types> ], 0>): MutationRef<Types>; mutationFields(fields: MutationFieldsShape<Types>): void; mutationField(name: string, field: MutationFieldThunk<Types>): void; subscriptionType(...args: NormalizeArgs<[ options: PothosSchemaTypes.SubscriptionTypeOptions<Types>, fields?: SubscriptionFieldsShape<Types> ], 0>): SubscriptionRef<Types>; subscriptionFields(fields: SubscriptionFieldsShape<Types>): void; subscriptionField(name: string, field: SubscriptionFieldThunk<Types>): void; args<Shape extends InputFieldMap>(fields: (t: PothosSchemaTypes.InputFieldBuilder<Types, 'Arg'>) => Shape): Shape; interfaceType<Param extends InterfaceParam<Types>, const Interfaces extends InterfaceParam<Types>[], ResolveType>(param: Param, options: InterfaceTypeOptions<Types, Param, ParentShape<Types, Param>, Interfaces, ResolveType>, fields?: InterfaceFieldsShape<Types, ParentShape<Types, Param>>): PothosSchemaTypes.InterfaceRef<Types, AbstractReturnShape<Types, Param, ResolveType>, ParentShape<Types, Param>>; interfaceFields<Type extends InterfaceParam<Types>>(ref: Type, fields: InterfaceFieldsShape<Types, ParentShape<Types, Type>>): void; interfaceField<Type extends InterfaceParam<Types>>(ref: Type, fieldName: string, field: InterfaceFieldThunk<Types, ParentShape<Types, Type>>): void; unionType<Member extends ObjectParam<Types>, ResolveType>(name: string, options: PothosSchemaTypes.UnionTypeOptions<Types, Member, ResolveType>): PothosSchemaTypes.UnionRef<Types, AbstractReturnShape<Types, Member, ResolveType>, ParentShape<Types, Member>>; enumType<Param extends EnumParam, const Values extends EnumValues<Types>>(param: Param, options: EnumTypeOptions<Types, Param, Values>): PothosSchemaTypes.EnumRef<Types, Param extends BaseEnum ? ValuesFromEnum<Param> : ShapeFromEnumValues<Types, Values>>; scalarType<Name extends ScalarName<Types>>(name: Name, options: PothosSchemaTypes.ScalarTypeOptions<Types, InputShape<Types, Name>, ParentShape<Types, Name>>): PothosSchemaTypes.ScalarRef<Types, InputShape<Types, Name>, ParentShape<Types, Name>>; addScalarType<Name extends ScalarName<Types>>(name: Name, scalar: GraphQLScalarType, ...args: NormalizeArgs<[ options: Omit<PothosSchemaTypes.ScalarTypeOptions<Types, InputShape<Types, Name>, OutputShape<Types, Name>>, 'serialize'> & { serialize?: GraphQLScalarSerializer<OutputShape<Types, Name>>; } ]>): PothosSchemaTypes.ScalarRef<Types, InputShape<Types, Name>, ParentShape<Types, Name>, InputShape<Types, Name>>; inputType<Param extends InputObjectRef<Types, unknown> | string, Fields extends Param extends PothosSchemaTypes.InputObjectRef<Types, unknown> ? InputFieldsFromShape<Types, InputShape<Types, Param> & object, 'InputObject'> : Param extends keyof Types['Inputs'] ? InputFieldsFromShape<Types, InputShape<Types, Param> & object, 'InputObject'> : InputFieldMap, IsOneOf extends boolean = boolean>(param: Param, options: PothosSchemaTypes.InputObjectTypeOptions<Types, Fields> & { isOneOf?: IsOneOf; }): PothosSchemaTypes.InputObjectRef<Types, [ IsOneOf ] extends [true] ? OneOfInputShapeFromFields<Fields> : InputShapeFromFields<Fields>>; inputRef<T extends object, Normalize = true>(name: string): ImplementableInputObjectRef<Types, RecursivelyNormalizeNullableFields<T>, Normalize extends false ? T : RecursivelyNormalizeNullableFields<T>>; objectRef<T>(name: string): ImplementableObjectRef<Types, T>; interfaceRef<T>(name: string): ImplementableInterfaceRef<Types, T>; toSchema(...args: NormalizeArgs<[options?: PothosSchemaTypes.BuildSchemaOptions<Types>]>): GraphQLSchema; } //# sourceMappingURL=builder.d.ts.map