import { GraphQLFieldResolver } from 'graphql'; import { AllInputTypes, FieldResolver, GetGen, GetGen3, HasGen3, NeedsResolver } from '../typegenTypeHelpers'; import { ArgsRecord } from './args'; import { AllNexusInputTypeDefs, AllNexusOutputTypeDefs, NexusWrapKind } from './wrapping'; import { BaseScalars } from './_types'; export interface CommonFieldConfig { /** * The description to annotate the GraphQL SDL */ description?: string | null; /** * Info about a field deprecation. Formatted as a string and provided with the * deprecated directive on field/enum types and as a comment on input fields. */ deprecation?: string; } export declare type CommonOutputFieldConfig = CommonFieldConfig & { /** * Arguments for the field */ args?: ArgsRecord; } & NexusGenPluginFieldConfig; export declare type CommonInputFieldConfig = CommonFieldConfig & { /** * The default value for the field, if any */ default?: GetGen3<'inputTypes', TypeName, FieldName>; } & NexusGenPluginFieldConfig; /** * Deprecated, prefer core.CommonInputFieldConfig * * TODO(tim): Remove at 1.0 */ export interface ScalarInputFieldConfig extends CommonInputFieldConfig { default?: T; } export interface OutputScalarConfig extends CommonOutputFieldConfig { /** * Resolve method for the field */ resolve?: FieldResolver; } export interface NexusOutputFieldConfig extends OutputScalarConfig { type: GetGen<'allOutputTypes', string> | AllNexusOutputTypeDefs; } export declare type NexusOutputFieldDef = NexusOutputFieldConfig & { name: string; configFor: 'outputField'; parentType: string; subscribe?: GraphQLFieldResolver; wrapping?: NexusWrapKind[]; }; export declare type ScalarOutSpread = NeedsResolver extends true ? [ScalarOutConfig] : HasGen3<'argTypes', TypeName, FieldName> extends true ? [ScalarOutConfig] : [ScalarOutConfig] | []; export declare type ScalarOutConfig = NeedsResolver extends true ? OutputScalarConfig & { resolve: FieldResolver; } : OutputScalarConfig; export declare type FieldOutConfig = NeedsResolver extends true ? NexusOutputFieldConfig & { resolve: FieldResolver; } : NexusOutputFieldConfig; export interface OutputDefinitionBuilder { typeName: string; addField(config: NexusOutputFieldDef): void; addDynamicOutputMembers(block: OutputDefinitionBlock, wrapping?: NexusWrapKind[]): void; warn(msg: string): void; } export interface InputDefinitionBuilder { typeName: string; addField(config: NexusInputFieldDef): void; addDynamicInputFields(block: InputDefinitionBlock, wrapping?: NexusWrapKind[]): void; warn(msg: string): void; } export interface OutputDefinitionBlock extends NexusGenCustomOutputMethods, NexusGenCustomOutputProperties { } /** * The output definition block is passed to the "definition" * function property of the "objectType" / "interfaceType" */ export declare class OutputDefinitionBlock { protected typeBuilder: OutputDefinitionBuilder; protected wrapping?: NexusWrapKind[] | undefined; readonly typeName: string; constructor(typeBuilder: OutputDefinitionBuilder, wrapping?: NexusWrapKind[] | undefined); get list(): OutputDefinitionBlock; get nonNull(): Omit, 'nonNull' | 'nullable'>; get nullable(): Omit, 'nonNull' | 'nullable'>; string(fieldName: FieldName, ...opts: ScalarOutSpread): void; int(fieldName: FieldName, ...opts: ScalarOutSpread): void; boolean(fieldName: FieldName, ...opts: ScalarOutSpread): void; id(fieldName: FieldName, ...opts: ScalarOutSpread): void; float(fieldName: FieldName, ...opts: ScalarOutSpread): void; field(name: FieldName, fieldConfig: FieldOutConfig): void; protected _wrapClass(kind: NexusWrapKind): OutputDefinitionBlock; protected addScalarField(fieldName: string, typeName: BaseScalars, opts: [] | ScalarOutSpread): void; } export interface NexusInputFieldConfig extends CommonInputFieldConfig { type: AllInputTypes | AllNexusInputTypeDefs; } export declare type NexusInputFieldDef = NexusInputFieldConfig & { configFor: 'inputField'; name: string; wrapping?: NexusWrapKind[]; parentType: string; }; export interface InputDefinitionBlock extends NexusGenCustomInputMethods { } export declare class InputDefinitionBlock { protected typeBuilder: InputDefinitionBuilder; protected wrapping?: NexusWrapKind[] | undefined; readonly typeName: string; constructor(typeBuilder: InputDefinitionBuilder, wrapping?: NexusWrapKind[] | undefined); get list(): InputDefinitionBlock; get nonNull(): Omit, 'nonNull' | 'nullable'>; get nullable(): Omit, 'nonNull' | 'nullable'>; string(fieldName: FieldName, opts?: CommonInputFieldConfig): void; int(fieldName: FieldName, opts?: CommonInputFieldConfig): void; boolean(fieldName: FieldName, opts?: CommonInputFieldConfig): void; id(fieldName: FieldName, opts?: CommonInputFieldConfig): void; float(fieldName: FieldName, opts?: CommonInputFieldConfig): void; field(fieldName: FieldName, fieldConfig: NexusInputFieldConfig): void; protected _wrapClass(kind: NexusWrapKind): InputDefinitionBlock; protected addScalarField(fieldName: string, typeName: BaseScalars, opts?: CommonInputFieldConfig): void; }