import { loadFallbackRootTypes } from './definition/rootTypes' ; import { loadBuiltInScalar } from './definition/scalar' ; import { DefinitionKind } from './metadata/Definition' ; import { MetadataStorage } from './metadata/MetadataStorage' ; import { DefinitionParser } from './sdl/ast' ; import { coerceType } from './type-expression/coerceType' ; import { TypeExpression } from './type-expression/TypeExpression' ; import { Thunk , ResolverMap } from './types' ; import { TypeArg } from './type-expression/types' ; /**
 * Create a new MetadataStorage initialized with default metadata
 */ export function createMetadataStorage ( ) { const storage = new MetadataStorage ( ) ; loadBuiltInScalar ( storage ) ; loadFallbackRootTypes ( storage ) ; return storage ; } /**
 * Global MetadataStorage used by default.
 */ export let globalMetadataStorage ; export function getGlobalMetadataStorage ( ) { if ( ! globalMetadataStorage ) { globalMetadataStorage = createMetadataStorage ( ) ; } return globalMetadataStorage ; } param typeArg param storage export function getType ( typeArg , kind = 'any' ) { const storage = getGlobalMetadataStorage ( ) ; return coerceType ( typeArg ) . getType ( { kind , storage } ) ; } param metadataOrThunk export function defineType ( parsersOrThunk ) { const storage = getGlobalMetadataStorage ( ) ; return function defDecoratorFn < T extends ResolverMap > ( definitionClass ) { storage . deferRegister ( ( ) => { ( Array . isArray ( parsersOrThunk ) ? parsersOrThunk : parsersOrThunk ( ) ) . forEach ( parser => { storage . registerMetadata ( parser . parseWithResolverMap ( definitionClass ) ) ; } ) ; } ) ; return definitionClass ; } ; }