import { GraphQLResolveInfo, GraphQLAbstractType } from 'graphql' import { NexusObjectTypeDef } from './definitions/objectType' import { NexusInterfaceTypeDef } from './definitions/interfaceType' declare global { interface NexusGen {} interface NexusGenCustomInputMethods {} interface NexusGenCustomOutputMethods {} interface NexusGenCustomOutputProperties {} interface NexusGenPluginSchemaConfig {} interface NexusGenPluginTypeConfig {} interface NexusGenPluginFieldConfig {} interface NexusGenPluginInputFieldConfig {} interface NexusGenPluginArgConfig {} } export type AllInputTypes = GetGen<'allInputTypes', string> export type AllOutputTypes = GetGen<'allOutputTypes', string> /** * This type captures all output types defined in the app * as well as core GraphQL spec objects. */ export type AllOutputTypesPossible = AllOutputTypes | 'Query' | 'Mutation' | 'Subscription' export type FieldType = GetGen3< 'fieldTypes', TypeName, FieldName > export type MaybePromise = PromiseLike | T /** * Because the GraphQL field execution algorithm automatically * resolves promises at any level of the tree, we use this * to help signify that. */ export type MaybePromiseDeep = Date extends T ? MaybePromise : null extends T ? MaybePromise : boolean extends T ? MaybePromise : number extends T ? MaybePromise : string extends T ? MaybePromise : T extends Array ? MaybePromise>> : T extends ReadonlyArray ? MaybePromise>> : T extends object ? MaybePromise< | T | { [P in keyof T]: MaybePromiseDeep } > : MaybePromise /** * The NexusAbstractTypeResolver type can be used if you want to preserve type-safety * and autocomplete on an abstract type resolver (interface or union) outside of the Nexus * configuration * * @example * ``` * const mediaType: AbstractTypeResolver<'MediaType'> = (root, ctx, info) => { * if (ctx.user.isLoggedIn()) { * return ctx.user.getItems() * } * return null * } * ``` */ export interface AbstractTypeResolver { ( source: RootValue, context: GetGen<'context'>, info: GraphQLResolveInfo, abstractType: GraphQLAbstractType ): MaybePromise | null> } /** * The FieldResolver type can be used when you want to preserve type-safety * and autocomplete on a resolver outside of the Nexus definition block * * @example * ``` * const userItems: FieldResolver<'User', 'items'> = (root, args, ctx, info) => { * if (ctx.user.isLoggedIn()) { * return ctx.user.getItems() * } * return null * } * ``` */ export type FieldResolver = ( root: RootValue, args: ArgsValue, context: GetGen<'context'>, info: GraphQLResolveInfo ) => MaybePromise> | MaybePromiseDeep> export type FieldTypeName = GetGen3< 'fieldTypeNames', TypeName, FieldName > export type SubFieldResolver< TypeName extends string, FieldName extends string, SubFieldName extends string > = ( root: RootValue, args: ArgsValue, context: GetGen<'context'>, info: GraphQLResolveInfo ) => | MaybePromise[SubFieldName]> | MaybePromiseDeep[SubFieldName]> export type AbstractResolveReturn = GetGen2<'abstractTypeMembers', TypeName, any> /** * Generated type helpers: */ export type GenTypesShapeKeys = | 'context' | 'inputTypes' | 'rootTypes' | 'argTypes' | 'fieldTypes' | 'fieldTypeNames' | 'allTypes' | 'typeInterfaces' | 'objectNames' | 'inputNames' | 'enumNames' | 'interfaceNames' | 'scalarNames' | 'unionNames' | 'allInputTypes' | 'allOutputTypes' | 'allNamedTypes' | 'abstractTypes' | 'abstractTypeMembers' | 'objectsUsingAbstractStrategyIsTypeOf' | 'abstractsUsingStrategyResolveType' | 'features' /** * Helpers for handling the generated schema */ export type GenTypesShape = Record export type GetGen = NexusGen extends infer GenTypes ? GenTypes extends GenTypesShape ? GenTypes[K] : Fallback : Fallback export type GetGen2< K extends GenTypesShapeKeys, K2 extends Extract, Fallback = any > = K2 extends keyof GetGen ? GetGen[K2] : Fallback export type GetGen3< K extends GenTypesShapeKeys, K2 extends Extract, K3 extends Extract, Fallback = any > = K2 extends keyof GetGen ? K3 extends keyof GetGen[K2] ? GetGen[K2][K3] : Fallback : Fallback export type HasGen = NexusGen extends infer GenTypes ? GenTypes extends GenTypesShape ? K extends keyof GenTypes ? true : false : false : false export type HasGen2< K extends GenTypesShapeKeys, K2 extends Extract > = NexusGen extends infer GenTypes ? GenTypes extends GenTypesShape ? K extends keyof GenTypes ? K2 extends keyof GenTypes[K] ? true : false : false : false : false export type HasGen3< K extends GenTypesShapeKeys, K2 extends Extract, K3 extends Extract > = NexusGen extends infer GenTypes ? GenTypes extends GenTypesShape ? K extends keyof GenTypes ? K2 extends keyof GenTypes[K] ? K3 extends keyof GenTypes[K][K2] ? true : false : false : false : false : false export type RootValue = GetGen2<'rootTypes', TypeName> export type RootValueField = GetGen3< 'rootTypes', TypeName, FieldName > export type ArgsValue = HasGen3< 'fieldTypes', TypeName, FieldName > extends true ? GetGen3<'argTypes', TypeName, FieldName, {}> : any export type ResultValue = GetGen3< 'fieldTypes', TypeName, FieldName > export type NeedsResolver = HasGen3< 'fieldTypes', TypeName, FieldName > extends true ? null extends GetGen3<'fieldTypes', TypeName, FieldName> ? false : HasGen3<'rootTypes', TypeName, FieldName> extends true ? null extends GetGen3<'rootTypes', TypeName, FieldName> ? true : false : true : HasGen3<'rootTypes', TypeName, FieldName> extends true ? null extends GetGen3<'rootTypes', TypeName, FieldName> ? true : false : false export type IsFeatureEnabled2 = GetGen3< 'features', PathPart1, PathPart2, false > extends true ? true : false export type Discriminate< TypeName extends string, Required extends 'required' | 'optional', Type = RootValue > = Type extends { __typename: TypeName } ? Type : Type extends { __typename?: TypeName } ? Type : Required extends 'required' ? Type & { __typename: TypeName } : Type & { __typename?: TypeName } export type InterfaceFieldsFor = { [K in GetGen2<'typeInterfaces', TypeName, never>]: keyof GetGen2<'fieldTypeNames', K> }[GetGen2<'typeInterfaces', TypeName, never>] export type ModificationType = TypeName extends string ? FieldName extends string ? GetGen2< 'abstractTypeMembers', GetGen3<'fieldTypeNames', GetGen2<'typeInterfaces', TypeName, never>, FieldName>, never > extends infer U ? U extends string ? U | ConcreteModificationType : never : never : any : any export type ConcreteModificationType = GetGen2<'objectNames', U, never> extends string ? NexusObjectTypeDef : NexusInterfaceTypeDef