Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/pothos/packages/core/fieldUtils/builder.ts>FieldBuilder

Pothos GraphQL is library for creating GraphQL schemas in typescript using a strongly typed code first approach
Latest
class FieldBuilder
import { FieldBuilder } from "https://deno.land/x/pothos@release-1730496474/packages/core/fieldUtils/builder.ts";

Type Parameters

Types extends SchemaTypes
ParentShape
optional
Kind extends FieldKind = FieldKind

Methods

expose<Type extends TypeParam<Types>, Nullable extends FieldNullability<Type>, ResolveReturnShape, Name extends CompatibleTypes<Types, ParentShape, Type, Type extends [unknown] ? { list: true; items: true; } : true>>(name: Name extends keyof ParentShape ? Name : keyof ParentShape, ...args: NormalizeArgs<[ExposeNullability<Types, Type, ParentShape, Name, Nullable> & Omit<FieldOptionsFromKind<Types, ParentShape, Type, Nullable, { }, Kind, ParentShape, ResolveReturnShape>, "nullable" | InferredFieldOptionKeys>]>)

Create a field that resolves to a property of the corresponding type on the parent object

exposeBoolean<Name extends CompatibleTypes<Types, ParentShape, "Boolean", true>, ResolveReturnShape, Nullable extends FieldNullability<"Boolean"> = Types["DefaultFieldNullability"]>(name: Name, ...args: NormalizeArgs<[ExposeNullability<Types, "Boolean", ParentShape, Name, Nullable> & Omit<FieldOptionsFromKind<Types, ParentShape, "Boolean", Nullable, { }, Kind, ParentShape, ResolveReturnShape>, "nullable" | "type" | InferredFieldOptionKeys>]>)

Create a Boolean field from a boolean property on the parent object

exposeBooleanList<Name extends CompatibleTypes<Types, ParentShape, ["Boolean"], { list: true; items: true; }>, ResolveReturnShape, Nullable extends FieldNullability<["Boolean"]> = Types["DefaultFieldNullability"]>(name: Name, ...args: NormalizeArgs<[ExposeNullability<Types, ["Boolean"], ParentShape, Name, Nullable> & Omit<FieldOptionsFromKind<Types, ParentShape, ["Boolean"], Nullable, { }, Kind, ParentShape, ResolveReturnShape>, "nullable" | "type" | InferredFieldOptionKeys>]>)

Create a Boolean list field from a boolean[] property on the parent object

exposeFloat<Name extends CompatibleTypes<Types, ParentShape, "Float", true>, ResolveReturnShape, Nullable extends FieldNullability<"Float"> = Types["DefaultFieldNullability"]>(name: Name, ...args: NormalizeArgs<[ExposeNullability<Types, "Float", ParentShape, Name, Nullable> & Omit<FieldOptionsFromKind<Types, ParentShape, "Float", Nullable, { }, Kind, ParentShape, ResolveReturnShape>, "nullable" | "type" | InferredFieldOptionKeys>]>)

Create a Float field from a numeric property on the parent object

exposeFloatList<Name extends CompatibleTypes<Types, ParentShape, ["Float"], { list: true; items: true; }>, ResolveReturnShape, Nullable extends FieldNullability<["Float"]> = Types["DefaultFieldNullability"]>(name: Name, ...args: NormalizeArgs<[ExposeNullability<Types, ["Float"], ParentShape, Name, Nullable> & Omit<FieldOptionsFromKind<Types, ParentShape, ["Float"], Nullable, { }, Kind, ParentShape, ResolveReturnShape>, "nullable" | "type" | InferredFieldOptionKeys>]>)

Create a Float list field from a number[] property on the parent object

exposeID<Name extends CompatibleTypes<Types, ParentShape, "ID", true>, ResolveReturnShape, Nullable extends FieldNullability<"ID"> = Types["DefaultFieldNullability"]>(name: Name, ...args: NormalizeArgs<[ExposeNullability<Types, "ID", ParentShape, Name, Nullable> & Omit<FieldOptionsFromKind<Types, ParentShape, "ID", Nullable, { }, Kind, ParentShape, ResolveReturnShape>, "nullable" | "type" | InferredFieldOptionKeys>]>)

Create an ID field from a property on the parent object

exposeIDList<Name extends CompatibleTypes<Types, ParentShape, ["ID"], { list: true; items: true; }>, ResolveReturnShape, Nullable extends FieldNullability<["ID"]> = Types["DefaultFieldNullability"]>(name: Name, ...args: NormalizeArgs<[ExposeNullability<Types, ["ID"], ParentShape, Name, Nullable> & Omit<FieldOptionsFromKind<Types, ParentShape, ["ID"], Nullable, { }, Kind, ParentShape, ResolveReturnShape>, "nullable" | "type" | InferredFieldOptionKeys>]>)

Create an ID list field from an id[] property on the parent object

exposeInt<Name extends CompatibleTypes<Types, ParentShape, "Int", true>, ResolveReturnShape, Nullable extends FieldNullability<"Int"> = Types["DefaultFieldNullability"]>(name: Name, ...args: NormalizeArgs<[ExposeNullability<Types, "Int", ParentShape, Name, Nullable> & Omit<FieldOptionsFromKind<Types, ParentShape, "Int", Nullable, { }, Kind, ParentShape, ResolveReturnShape>, "nullable" | "type" | InferredFieldOptionKeys>]>)

Create an Int field from a numeric property on the parent object

exposeIntList<Name extends CompatibleTypes<Types, ParentShape, ["Int"], { list: true; items: true; }>, ResolveReturnShape, Nullable extends FieldNullability<["Int"]> = Types["DefaultFieldNullability"]>(name: Name, ...args: NormalizeArgs<[ExposeNullability<Types, ["Int"], ParentShape, Name, Nullable> & Omit<FieldOptionsFromKind<Types, ParentShape, ["Int"], Nullable, { }, Kind, ParentShape, ResolveReturnShape>, "nullable" | "type" | InferredFieldOptionKeys>]>)

Create a Int list field from a number[] property on the parent object

exposeString<Name extends CompatibleTypes<Types, ParentShape, "String", true>, ResolveReturnShape, Nullable extends FieldNullability<"String"> = Types["DefaultFieldNullability"]>(name: Name, ...args: NormalizeArgs<[ExposeNullability<Types, "String", ParentShape, Name, Nullable> & Omit<FieldOptionsFromKind<Types, ParentShape, "String", Nullable, { }, Kind, ParentShape, ResolveReturnShape>, "nullable" | "type" | InferredFieldOptionKeys>]>)

Create a String field from a string property on the parent object

exposeStringList<Name extends CompatibleTypes<Types, ParentShape, ["String"], { list: true; items: true; }>, ResolveReturnShape, Nullable extends FieldNullability<["String"]> = Types["DefaultFieldNullability"]>(name: Name, ...args: NormalizeArgs<[ExposeNullability<Types, ["String"], ParentShape, Name, Nullable> & Omit<FieldOptionsFromKind<Types, ParentShape, ["String"], Nullable, { }, Kind, ParentShape, ResolveReturnShape>, "nullable" | "type" | InferredFieldOptionKeys>]>)

Create a String list field from a string[] property on the parent object