UNPKG

graphql-yoga

Version:
22 lines (21 loc) 603 B
import { AggregateError } from '@graphql-tools/utils'; export function getAggregateErrorFromErrors(errors) { errors.forEach((error) => { error.extensions.http = { status: 400, }; }); throw new AggregateError(errors); } export function useHTTPValidationError() { return { onValidate() { return ({ valid, result }) => { if (!valid) { // Typecasting since Envelop is Agnostic to GraphQL.js throw getAggregateErrorFromErrors(result); } }; }, }; }