import { ArgsOptions , ReturnTypeFunc } from '@nestjs/graphql' ; const BASE_KEY = 'nestjs-relay' ; const METHOD_KEY = 'method' ; const METHOD_METADATA_KEY = `${ BASE_KEY }:${ METHOD_KEY }` ; const CLASS_KEY = 'class' ; const CLASS_METADATA_KEY = `${ BASE_KEY }:${ CLASS_KEY }` ; export interface MethodIdentifier { target : Object ; key : string | symbol ; } export type ParameterMetadata = Omit < ArgsOptions , 'type' > & { typeFunc : ReturnTypeFunc ; paramIndex : number ; } ; export interface ClassIdentifier { target : Function ; } export type ClassMetadata = { name : string ; } ; export class MetadataStorage { static addMethodMetadata ( args ) { const { target , key , ... data } = args ; const existingMetadata = MetadataStorage . getMethodMetadata ( { target , key } ) ; const metadata = [ ... existingMetadata , data ] ; Reflect . defineMetadata ( METHOD_METADATA_KEY , metadata , target , key ) ; } static getMethodMetadata ( { target , key } ) { return Reflect . getMetadata ( METHOD_METADATA_KEY , target , key ) || [ ] ; } static addClassMetadata ( args ) { const { target , ... data } = args ; const existingMetadata = MetadataStorage . getClassMetadata ( { target } ) ; const metadata = { ... existingMetadata , ... data } ; Reflect . defineMetadata ( CLASS_METADATA_KEY , metadata , target ) ; } static getClassMetadata ( { target } ) { return Reflect . getMetadata ( CLASS_METADATA_KEY , target ) ; } }