graphql-composer
Version:
Create your GraphQL API using composition!
40 lines (39 loc) • 1.98 kB
TypeScript
import { GraphQLInterfaceType, GraphQLTypeResolver, InterfaceTypeDefinitionNode } from "graphql";
import { ObjectType, ClassType, TypeResolvable, InputType, KeyValue } from "../../../..";
import { GQLObjectType } from "./GQLObjectType";
export declare class InterfaceType<T extends ClassType = any, ExtensionsType = any> extends GQLObjectType<GraphQLInterfaceType, T, ExtensionsType> implements TypeResolvable {
protected _typeResolver: GraphQLTypeResolver<any, any>;
private _possibleTypes;
get definitionNode(): InterfaceTypeDefinitionNode;
protected constructor(name: string);
static create<T = any>(name: string): InterfaceType<ClassType<T>>;
static create<T extends ClassType = any>(classType: T): InterfaceType<T>;
static create<T = any>(inputType: InputType): InterfaceType<ClassType<T>>;
static create<T = any>(objectType: ObjectType): InterfaceType<ClassType<T>>;
static create<T = any>(interfaceType: InterfaceType): InterfaceType<ClassType<T>>;
build(): GraphQLInterfaceType;
/**
* Set the type of the field
* @param typeResolver the field resolver
*/
setTypeResolver<TSource = any, TContext = any>(typeResolver: GraphQLTypeResolver<TSource, TContext>): this;
/**
* Set the possible types of the interface to resolve the __typename
* @param possibleTypes The possible types
*/
setPossibleTypes(...possibleTypes: ObjectType[]): this;
/**
* Set the possible types of the interface to resolve the __typename
* @param possibleTypes The possible types
*/
addPossibleTypes(...possibleTypes: ObjectType[]): this;
/**
* Add a suffix to the name of your type ("Interface" by default)
* @param suffix The suffix to add to the name
*/
suffix(suffix?: string): this;
copy(): InterfaceType<T>;
convert(to: typeof InputType): InputType<T>;
convert(to: typeof ObjectType): ObjectType<T>;
defaultTypeResolver(obj: KeyValue): any;
}