import * as graphql from 'graphql' ; import { Scalar , Enum , EnumValue , ObjectType , InputObject , Interface , Union , InputType , OutputType , ArgMap , TOfArgMap , Field , AbstractField , DefaultArgument , Argument , InputFieldMap , SubscriptionField , SubscriptionObject , PromiseOrValue , } from './types' ; type ExtensionsMap = { field ? : { [ key ] : any ; } ; objectType ? : { [ key ] : any ; } ; } ; type ResolvePartialMandatory < Src , Arg , Ctx , Out > = { resolve : ( src : Src , args : TOfArgMap < ArgMap < Arg > > , ctx : Ctx , info : graphql . GraphQLResolveInfo ) => PromiseOrValue < Out > ; } ; type ResolvePartialOptional < Src , Arg , Ctx , Out > = { resolve ? : ( src : Src , args : TOfArgMap < ArgMap < Arg > > , ctx : Ctx , info : graphql . GraphQLResolveInfo ) => PromiseOrValue < Out > ; } ; export type Factory < Ctx , TExtensionsMap extends ExtensionsMap > = { String : Scalar < string | null > ; Int : Scalar < number | null > ; Float : Scalar < number | null > ; Boolean : Scalar < boolean | null > ; ID : Scalar < string | null > ; scalarType < Src > ( { name , description , serialize , parseValue , parseLiteral , } ) : Scalar < Src | null > ; enumType < Src > ( { name , description , values , } ) : Enum < Src | null > ; arg < Src > ( type , description ? ) : Argument < Src > ; defaultArg < Src > ( type , defaultArg , description ? ) : DefaultArgument < Exclude < Src , null > > ; field < TKey extends string , Src , Arg , Out > ( opts ) : Field < Ctx , Src , any , any > ; abstractField < Out_1 > ( opts ) : AbstractField < Ctx , Out_1 > ; objectType < Src , Ctx = any > ( { name , description , interfaces , fields , isTypeOf , extensions , } ) : ObjectType < Ctx , Src | null > ; inputObjectType < Src > ( { name , description , fields , } ) : InputObject < Src | null > ; unionType < Src > ( { name , description , types , resolveType , } ) : Union < Ctx , Src | null > ; interfaceType < Src > ( { name , description , interfaces , fields , } ) : Interface < Ctx , Src | null > ; List < Src > ( ofType ) : OutputType < Ctx , Src [ ] | null > ; ListInput < Src > ( ofType ) : InputType < Src [ ] | null > ; NonNull < Src > ( ofType ) : OutputType < Ctx , Src > ; NonNullInput < Src > ( ofType ) : InputType < Src > ; queryType < RootSrc > ( { name , fields , } ) : ObjectType < Ctx , RootSrc > ; mutationType < RootSrc > ( { name , fields , } ) : ObjectType < Ctx , RootSrc > ; subscriptionField < RootSrc , Out_2 , Arg_1 > ( { name , type , args , subscribe , description , deprecationReason , } ) : SubscriptionField < Ctx , RootSrc , Arg_1 , Out_2 > ; subscriptionType < Src > ( { name , fields , } ) : SubscriptionObject < Ctx , Src > ; } ; function builtInScalar < Src > ( builtInType ) { return { kind : 'Scalar' , builtInType , } ; } export function createTypesFactory < Ctx = undefined , TExtensions extends ExtensionsMap = { } > ( ) { return { String : builtInScalar < string > ( graphql . GraphQLString ) , Int : builtInScalar < number > ( graphql . GraphQLInt ) , Float : builtInScalar < number > ( graphql . GraphQLFloat ) , Boolean : builtInScalar < boolean > ( graphql . GraphQLBoolean ) , ID : builtInScalar < string > ( graphql . GraphQLID ) , scalarType < Src > ( { name , description , serialize , parseValue , parseLiteral , } ) { return { kind : 'Scalar' , graphqlTypeConfig : { name , description , serialize , parseLiteral , parseValue , } , } ; } , enumType < Src > ( { name , description , values , } ) { return { kind : 'Enum' , name , description , values , } ; } , arg < Src > ( type , description ? ) { return { kind : 'Argument' , type , description , } ; } , defaultArg < Src > ( type , defaultArg , description ? ) { return { kind : 'DefaultArgument' , type : type as any , description , default : defaultArg , } ; } , field : ( { name , type , resolve , args , ... options } ) => ( { kind : 'Field' , name , type , args : args ?? { } , resolve : typeof resolve === 'function' ? resolve : undefined , ... options , } ) , abstractField < Out > ( opts ) { return { kind : 'AbstractField' , name : opts . name , description : opts . description , deprecationReason : opts . deprecationReason , args : opts . args , type : opts . type , } ; } , objectType < Src , Ctx = any > ( { name , description , interfaces = [ ] , fields , isTypeOf , extensions , } ) { const obj = { kind : 'ObjectType' , name , description , interfaces , fieldsFn : undefined as any , isTypeOf , extensions , } ; obj . fieldsFn = ( ) => fields ( obj ) as any ; return obj ; } , inputObjectType < Src > ( { name , description , fields , } ) { let inputObj = { kind : 'InputObject' , name , description , fieldsFn : null as any , } ; inputObj . fieldsFn = ( ) => fields ( inputObj ) ; return inputObj ; } , unionType < Src > ( { name , description , types , resolveType , } ) { return { kind : 'Union' , name , description , types , resolveType , } as Union < Ctx , Src | null > ; } , interfaceType < Src > ( { name , description , interfaces = [ ] , fields , } ) { const obj = { kind : 'Interface' , name , description , interfaces , fieldsFn : undefined as any , } ; obj . fieldsFn = ( ) => fields ( obj ) as any ; return obj ; } , List < Src > ( ofType ) { return { kind : 'List' , ofType : ofType as any , } ; } , ListInput < Src > ( ofType ) { return { kind : 'ListInput' , ofType : ofType as any , } ; } , NonNull < Src > ( ofType ) { return { kind : 'NonNull' , ofType : ofType as any , } ; } , NonNullInput < Src > ( ofType ) { return { kind : 'NonNullInput' , ofType : ofType as any , } ; } , queryType < RootSrc > ( { name = 'Query' , fields , } ) { return { kind : 'ObjectType' , name , interfaces : [ ] , fieldsFn : fields , } ; } , mutationType < RootSrc > ( { name = 'Mutation' , fields , } ) { return { kind : 'ObjectType' , name , interfaces : [ ] , fieldsFn : fields , } ; } , subscriptionField < RootSrc , Out , Arg > ( { name , type , args = { } as ArgMap < Arg > , subscribe , description , deprecationReason , } ) { return { kind : 'SubscriptionField' , name , type , args , subscribe , resolve : ( value ) => value , description , deprecationReason , } ; } , subscriptionType < Src > ( { name = 'Subscription' , fields , } ) { return { kind : 'SubscriptionObject' , name , fields , } ; } , } ; }