Resolver function: (root, ctx, data) => result.
root is the parent object (e.g. the User row from the database).ctx is Context (or AuthorizedContext when authorized: true).data is the optional typed input argument.Configuration (same as query() but without mutation).
A FieldResolverDefinition with .call and .authCall for server-side invocation.
import { field } from "naystack/graphql";
// Resolve the "seller" field on a Property type
const seller = field(
async (property: PropertyDB) => {
if (!property.sellerId) return null;
const [seller] = await db.select().from(ContactTable).where(eq(ContactTable.id, property.sellerId));
return seller || null;
},
{ output: ContactGQL, outputOptions: { nullable: true } },
);
Defines a type-graphql field resolver with typed root, context, and input. Use with FieldLibrary to attach computed fields to a parent GraphQL type.
Like
query(), each field definition gets.call(root, data)and.authCall(root, data)for server-side invocation.