UNPKG

inversify-graphql

Version:

Builds dependency-inverted GraphQL schemas with InversifyJS

53 lines (52 loc) 3.2 kB
/** * ======= PURPOSE ========= * This file contains shortcuts to have a more readable GraphQL typing */ import { GraphQLNonNull, GraphQLType, GraphQLList, GraphQLInputObjectTypeConfig, GraphQLInputObjectType, GraphQLObjectTypeConfig, GraphQLObjectType, GraphQLUnionTypeConfig, GraphQLUnionType, Thunk, GraphQLEnumTypeConfig, GraphQLEnumType, GraphQLInterfaceTypeConfig, GraphQLInterfaceType, GraphQLScalarType } from 'graphql'; import { InversifyObjectConfig, InversifyObjectTypeBuilder, InversifyUnionConfig, InversifyUnionTypeBuilder, InversifyFieldConfigMap, InversifyPartialMap, InversifyInterfaceConfig, InversifyBuilder } from '.'; import { interfaces } from 'inversify'; import { InversifyInterfaceTypeBuilder } from './interface-builder'; declare type Ctor<T> = interfaces.Newable<T>; declare type InvBuilder = Ctor<InversifyBuilder>; export declare function NN(t: InvBuilder): InvBuilder; export declare function NN<T extends GraphQLType>(t: T): GraphQLNonNull<T>; /** GraphQL list */ export declare function GList(t: InvBuilder): InvBuilder; export declare function GList<T extends GraphQLType>(t: T): GraphQLList<T>; /** GraphQL input type */ export declare function GInput(cfg: GraphQLInputObjectTypeConfig): GraphQLInputObjectType; /** GraphQL object */ export declare function GObject<T = any, TContext = any>(cfg: GraphQLObjectTypeConfig<T, TContext>): GraphQLObjectType<T, TContext, { [key: string]: any; }>; /** Inversify object shortcut */ export declare function GObjectInv<T = any, TContext = any>(cfg: InversifyObjectConfig<T, TContext>): interfaces.Newable<InversifyObjectTypeBuilder<T, TContext>>; export declare function GInterface<T = any, TContext = any>(cfg: GraphQLInterfaceTypeConfig<T, TContext>): GraphQLInterfaceType; /** Inversify interface */ export declare function GInterfaceInv<T = any, TContext = any>(cfg: InversifyInterfaceConfig<T, TContext>): interfaces.Newable<InversifyInterfaceTypeBuilder<T, TContext>>; /** * Create both an input & output types, with the same shape. * * Usage: * * const [MyOutput, MyInput] = GObjectIO({ ...config... }) * */ export declare function GObjectIO<T = any, TContext = any>(cfg: GraphQLObjectTypeConfig<T, TContext> & GraphQLInputObjectTypeConfig): [GraphQLObjectType<T, TContext>, GraphQLInputObjectType]; /** GraphQL union */ export declare function GUnion<T = any, TContext = any>(cfg: GraphQLUnionTypeConfig<T, TContext>): GraphQLUnionType; /** Inversify union */ export declare function GUnionInv<T = any, TContext = any>(cfg: InversifyUnionConfig<T, TContext>): interfaces.Newable<InversifyUnionTypeBuilder<T, TContext>>; /** Inversify partial map shortcut */ export declare function GPartialMap<T = any, TContext = any>(cfg: Thunk<InversifyFieldConfigMap<T, TContext>>): interfaces.Newable<InversifyPartialMap<T, TContext>>; /** GraphQL enum */ export declare function GEnum(cfg: GraphQLEnumTypeConfig): GraphQLEnumType; /** GraphQL string */ export declare const GString: GraphQLScalarType; /** GraphQL int */ export declare const GInt: GraphQLScalarType; /** GraphQL float */ export declare const GFloat: GraphQLScalarType; /** GraphQL bool */ export declare const GBool: GraphQLScalarType; export {};