import './global-types'; import SchemaBuilder, { BasePlugin, type FieldMap, type InterfaceFieldsShape, type InterfaceParam, InterfaceRef, type Normalize, type ObjectFieldsShape, ObjectRef, type ParentShape, type SchemaTypes, type UnionToIntersection, } from '@pothos/core'; import type { OutputShapeFromFields } from './types'; const pluginName = 'simpleObjects'; export default pluginName; export class PothosSimpleObjectsPlugin extends BasePlugin {} SchemaBuilder.registerPlugin(pluginName, PothosSimpleObjectsPlugin); const proto: PothosSchemaTypes.SchemaBuilder = SchemaBuilder.prototype as PothosSchemaTypes.SchemaBuilder; proto.simpleObject = function simpleObject< const Interfaces extends InterfaceParam[], Fields extends FieldMap, Shape extends Normalize< OutputShapeFromFields & UnionToIntersection> >, >( name: string, options: PothosSchemaTypes.SimpleObjectTypeOptions, extraFields?: ObjectFieldsShape, ) { const ref = new ObjectRef(name); this.objectType(ref, options as PothosSchemaTypes.ObjectTypeOptions); if (extraFields) { this.objectFields(ref, extraFields); } return ref; }; proto.simpleInterface = function simpleInterface< const Interfaces extends InterfaceParam[], Fields extends FieldMap, Shape extends Normalize< OutputShapeFromFields & UnionToIntersection> >, >( name: string, options: PothosSchemaTypes.SimpleInterfaceTypeOptions, extraFields?: InterfaceFieldsShape, ) { const ref = new InterfaceRef(name); this.interfaceType(ref, options as object); if (extraFields) { this.interfaceFields(ref, extraFields); } return ref; };