diff --git a/src/plugins/connectionPlugin.ts b/src/plugins/connectionPlugin.ts index 30242b8f..b361eeae 100644 --- a/src/plugins/connectionPlugin.ts +++ b/src/plugins/connectionPlugin.ts @@ -1,17 +1,9 @@ -import { defaultFieldResolver, GraphQLFieldResolver, GraphQLResolveInfo } from 'graphql' -import { ArgsRecord, intArg, stringArg } from '../definitions/args' -import type { CommonFieldConfig, FieldOutConfig } from '../definitions/definitionBlocks' -import { NexusNonNullDef, nonNull } from '../definitions/nonNull' -import { NexusNullDef, nullable } from '../definitions/nullable' -import { ObjectDefinitionBlock, objectType } from '../definitions/objectType' import { AllNexusNamedOutputTypeDefs, AllNexusOutputTypeDefs, applyNexusWrapping, } from '../definitions/wrapping' -import type { NonNullConfig } from '../definitions/_types' -import { dynamicOutputMethod } from '../dynamicMethod' -import { completeValue, plugin } from '../plugin' +import { ArgsRecord, intArg, stringArg } from '../definitions/args' import type { ArgsValue, FieldTypeName, @@ -21,9 +13,18 @@ import type { ResultValue, SourceValue, } from '../typegenTypeHelpers' -import type { MaybePromiseLike } from '../typeHelpersInternal' +import type { CommonFieldConfig, FieldOutConfig } from '../definitions/definitionBlocks' +import { GraphQLFieldResolver, GraphQLResolveInfo, defaultFieldResolver } from 'graphql' +import { NexusNonNullDef, nonNull } from '../definitions/nonNull' +import { NexusNullDef, nullable } from '../definitions/nullable' +import { ObjectDefinitionBlock, objectType } from '../definitions/objectType' +import { completeValue, plugin } from '../plugin' import { eachObj, getOwnPackage, isPromiseLike, mapObj, pathToArray, printedGenTypingImport } from '../utils' +import type { MaybePromiseLike } from '../typeHelpersInternal' +import type { NonNullConfig } from '../definitions/_types' +import { dynamicOutputMethod } from '../dynamicMethod' + export interface ConnectionPluginConfig { /** * The method name in the objectType definition block @@ -309,7 +310,7 @@ export type ConnectionFieldConfig, ctx: GetGen<'context'>, info: GraphQLResolveInfo - ) => MaybePromise> | MaybePromiseDeep> + ) => MaybePromiseDeep> // resolve XOR nodes nodes?: never diff --git a/src/typegenTypeHelpers.ts b/src/typegenTypeHelpers.ts index c1ee610f..733efacd 100644 --- a/src/typegenTypeHelpers.ts +++ b/src/typegenTypeHelpers.ts @@ -1,4 +1,5 @@ import type { GraphQLAbstractType, GraphQLResolveInfo } from 'graphql' + import type { NexusInterfaceTypeDef } from './definitions/interfaceType' import type { NexusObjectTypeDef } from './definitions/objectType' @@ -34,27 +35,20 @@ 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 +export type MaybePromiseDeep = [T] extends [Date] ? MaybePromise - : boolean extends T + : [T] extends [boolean] ? MaybePromise - : number extends T + : [T] extends [number] ? MaybePromise - : string extends T + : [T] extends [string] ? MaybePromise - : T extends Array + : [T] extends [Array] ? MaybePromise>> - : T extends ReadonlyArray + : [T] extends [ReadonlyArray] ? MaybePromise>> - : T extends object - ? MaybePromise< - | T - | { - [P in keyof T]: MaybePromiseDeep - } - > + : [T] extends object + ? MaybePromise<{ [P in keyof T]: MaybePromiseDeep }> : MaybePromise /**