import { GraphQLResolveInfo } from 'graphql'; import { core } from 'nexus'; import { CommonFieldConfig } from 'nexus/dist/core'; import * as Helpers from './helpers'; /** * Framework-only * Note: PrismaClient type is now generic to support both prisma-client-js and prisma-client generators */ declare global { interface NexusTestContextApp { db: { client: any; }; } } /** * Framework & Library */ export type ModelNameInGraphQLTypes = ReturnType extends core.GetGen<'objectNames'> ? true : false; export type CustomFieldResolver = (root: core.SourceValue, args: core.ArgsValue, context: core.GetGen<'context'>, info: GraphQLResolveInfo, originalResolve: core.FieldResolver) => core.MaybePromise> | core.MaybePromiseDeep>; type NexusPrismaScalarOpts = { /** * Alias the field name */ alias?: Alias; /** * Provide a custom resolver on any resolver generated by the plugin via t.crud or t.model. * You can either entirely replace the generated resolver, or wrap it via the use of the `originalResolve` parameter. * * @example * * ```ts * t.crud.posts({ * async resolve(root, args, ctx, info, originalResolve) { * console.log('logic before the resolver') * const res = await originalResolve(root, args, ctx, info) * console.log('logic after the resolver') * return res * } * }) * ``` */ resolve?: CustomFieldResolver; } & NexusGenPluginFieldConfig & CommonFieldConfig; type RootObjectTypes = Pick, core.GetGen<'objectNames'>>; /** * Determine if `B` is a subset (or equivalent to) of `A`. */ type IsSubset = keyof A extends never ? false : B extends A ? true : false; type OmitByValue = Pick; type GetSubsetTypes = keyof OmitByValue<{ [P in keyof RootObjectTypes]: ModelName extends keyof Helpers.GetGen<'models'> ? IsSubset> extends true ? RootObjectTypes[P] : never : never; }, never>; type SubsetTypes = GetSubsetTypes extends never ? "ERROR: No subset types are available. Please make sure that one of your GraphQL type is a subset of your t.model('')" : GetSubsetTypes; type DynamicRequiredType = ModelNameInGraphQLTypes extends true ? { type?: SubsetTypes; } : { type: SubsetTypes; }; type GetNexusPrismaInput = ModelName extends keyof Helpers.GetGen<'inputs'> ? MethodName extends keyof Helpers.GetGen2<'inputs', ModelName> ? InputName extends keyof Helpers.GetGen3<'inputs', ModelName, MethodName> ? Helpers.GetGen3<'inputs', ModelName, MethodName>[InputName] & string : never : never : never; /** * Represents arguments required by Prisma Client JS that will * be derived from a request's input (args, context, and info) * and omitted from the GraphQL API. The object itself maps the * names of these args to a function that takes an object representing * the request's input and returns the value to pass to the prisma * arg of the same name. */ export type LocalComputedInputs = Record) => unknown>; export type GlobalComputedInputs = Record unknown>; type BaseMutationResolverParams = { info: GraphQLResolveInfo; ctx: Context; }; export type GlobalMutationResolverParams = BaseMutationResolverParams & { args: Record & { data: unknown; }; }; export type LocalMutationResolverParams = BaseMutationResolverParams & { args: MethodName extends keyof core.GetGen2<'argTypes', 'Mutation'> ? core.GetGen3<'argTypes', 'Mutation', MethodName> : any; }; export type Context = core.GetGen<'context'>; export type BaseRelationOptions = DynamicRequiredType & { /** * Alias the default field name */ alias?: Alias; /** * Enable the usage of a custom resolver on any resolver generated by the plugin via t.crud or t.model. * You can either entirely replace the generated resolver, or wrap it via the use of the `originalResolve` parameter. * * @example * * ```ts * t.crud.posts({ * async resolve(root, args, ctx, info, originalResolve) { * console.log('logic before the resolver') * const res = await originalResolve(root, args, ctx, info) * console.log('logic after the resolver') * return res * } * }) * ``` */ resolve?: CustomFieldResolver; computedInputs?: LocalComputedInputs; } & NexusGenPluginFieldConfig & CommonFieldConfig; type NexusPrismaRelationOpts = GetNexusPrismaInput extends never ? BaseRelationOptions : GetNexusPrismaInput extends never ? BaseRelationOptions : BaseRelationOptions & { filtering?: boolean | Partial, boolean>>; ordering?: boolean | Partial, boolean>>; pagination?: boolean | Helpers.GetGen<'pagination'>; }; type IsScalar = TypeName extends core.GetGen<'scalarNames'> ? true : false; type IsObject = Name extends core.GetGen<'objectNames'> ? true : false; type IsEnum = Name extends core.GetGen<'enumNames'> ? true : false; type IsInputObject = Name extends core.GetGen<'inputNames'> ? true : false; /** * The kind that a GraphQL type may be. */ type Kind = 'Enum' | 'Object' | 'Scalar' | 'InputObject'; /** * Helper to safely reference a Kind type. For example instead of the following * which would admit a typo: * * ```ts * type Foo = Bar extends 'scalar' ? ... * ``` * * You can do this which guarantees a correct reference: * * ```ts * type Foo = Bar extends AKind<'Scalar'> ? ... * ``` * */ type AKind = T; type GetKind = IsEnum extends true ? 'Enum' : IsScalar extends true ? 'Scalar' : IsObject extends true ? 'Object' : IsInputObject extends true ? 'InputObject' : 'Object'; export type NexusPrismaFields & string> = { [MethodName in keyof Helpers.GetGen2<'outputs', ModelName> & string]: NexusPrismaMethod & string>>; }; type NexusPrismaMethod & string, MethodName extends keyof Helpers.GetGen2<'outputs', ModelName> & string, ThisKind extends Kind, ReturnType extends string = Helpers.GetGen3<'outputs', ModelName, MethodName> & string> = ThisKind extends AKind<'Enum'> ? () => NexusPrismaFields : ThisKind extends AKind<'Scalar'> ? (opts?: NexusPrismaScalarOpts) => NexusPrismaFields : ModelNameInGraphQLTypes extends true ? (opts?: NexusPrismaRelationOpts) => NexusPrismaFields : (opts: NexusPrismaRelationOpts) => NexusPrismaFields; type GetNexusPrismaMethod = TypeName extends keyof Helpers.GetGen<'methods'> ? Helpers.GetGen2<'methods', TypeName> : >(typeName: CustomTypeName) => Helpers.GetGen2<'methods', CustomTypeName>; export type GetNexusPrisma = ModelOrCrud extends 'model' ? TypeName extends 'Mutation' ? never : TypeName extends 'Query' ? never : GetNexusPrismaMethod : ModelOrCrud extends 'crud' ? TypeName extends 'Mutation' ? GetNexusPrismaMethod : TypeName extends 'Query' ? GetNexusPrismaMethod : never : never; export {}; //# sourceMappingURL=static.d.ts.map