import { isType } from 'graphql' import { AllNamedTypeDefs, isNexusStruct, NexusListableTypes } from './wrapping' import { NexusTypes, withNexusSymbol } from './_types' /** * list() */ export type NexusListDefConfig = { type: TypeName } export class NexusListDef { // @ts-ignore // Required field for TS to differentiate NonNull from Null from List private _isNexusListDef: boolean = true constructor(readonly ofNexusType: TypeName) { /* istanbul ignore if */ if (typeof ofNexusType !== 'string' && !isNexusStruct(ofNexusType) && !isType(ofNexusType)) { throw new Error('Cannot wrap unknown types in list(). Saw ' + ofNexusType) } } } withNexusSymbol(NexusListDef, NexusTypes.List) export function list(type: TypeName): NexusListDef { return new NexusListDef(type) }