import { type InterfaceParam, type ObjectTypeOptions, type OutputRef, outputShapeKey, type PothosMutationTypeConfig, type PothosObjectTypeConfig, type PothosQueryTypeConfig, type PothosSubscriptionTypeConfig, parentShapeKey, type SchemaTypes, } from '../types'; import { TypeRefWithFields } from './base-with-fields'; export type ObjectLikeConfig = | PothosMutationTypeConfig | PothosObjectTypeConfig | PothosQueryTypeConfig | PothosSubscriptionTypeConfig; export class ObjectRef extends TypeRefWithFields implements OutputRef, PothosSchemaTypes.ObjectRef { override kind = 'Object' as const; $inferType!: T; [outputShapeKey]!: T; [parentShapeKey]!: P; constructor(name: string, config?: ObjectLikeConfig) { super('Object', name, config); } } export class ImplementableObjectRef< Types extends SchemaTypes, Shape, Parent = Shape, > extends ObjectRef { builder: PothosSchemaTypes.SchemaBuilder; constructor(builder: PothosSchemaTypes.SchemaBuilder, name: string) { super(name); this.builder = builder; } implement[]>( options: Omit< ObjectTypeOptions, Parent, Interfaces>, 'name' >, ): PothosSchemaTypes.ObjectRef { return this.builder.objectType( this, options as ObjectTypeOptions< Types, ImplementableObjectRef, Parent, Interfaces >, ); } }