UNPKG

graphql-composer

Version:
41 lines (40 loc) 1.43 kB
import { GQLField, InputField, Field, Removable, ClassType, InstanceOf, ConversionType } from "../../.."; import { GQLBasicType } from "./GQLBasicType"; export declare abstract class GQLType<BuiltType = any, T extends ClassType<any> = any, ExtensionsType = any> extends GQLBasicType<BuiltType, any, ExtensionsType> { protected _fields: GQLField[]; protected _classType?: T; get fields(): GQLField<any, string, any>[]; /** * Convert your type into a new one * @param to The target type */ abstract convert<Target extends ConversionType>(to: Target): InstanceOf<Target>; /** * Apply a transformation to your fields * @param cb The callback with the field instance as the first parameter */ abstract transformFields(cb: (field: InputField | Field) => void): this; /** * Set the field list * @param fields The fields list */ setFields(...fields: GQLField[]): GQLType; /** * Add some fields to the fields list * @param fields The fields list */ addFields(...fields: GQLField[]): GQLType<any, any, any>; /** * Remove some fields from the fields list * @param fields The fields IDs */ removeFields(...fields: Removable<GQLField>): GQLType<any, any, any>; /** * Make all the fields nullable */ partial(): this; /** * Make all the fields not nullable */ required(): this; }