import { MultiError , notNull } from "@adpt/utils" ; import { ExecutionResult , GraphQLError } from "graphql" ; import { flatten } from "lodash" ; import { CustomError } from "ts-custom-error" ; export class ObserverNeedsData extends CustomError { public constructor ( message ? ) { super ( "Adapt Observer Needs Data: " + ( message ? message : "<no message>" ) ) ; } } export function throwObserverErrors ( results ) { const errors = results . map ( ( r ) => r . errors ) . filter ( notNull ) ; if ( errors . length === 0 ) return ; throw new MultiError ( flatten ( errors as GraphQLError [ ] [ ] ) ) ; }