How to use the apollo-server-express.ValidationError function in apollo-server-express

To help you get started, we’ve selected a few apollo-server-express examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github terascope / teraslice / packages / data-access-plugin / src / manager / utils.ts View on Github external
return (err: any) => {
        if (err && err.extensions != null) {
            if (removeUserStack && err.extensions.exception) {
                delete err.extensions.exception.stack;
            }
            return err;
        }

        const { statusCode, message, code } = ts.parseErrorInfo(err);
        let error: any;

        if (statusCode >= 400 && statusCode < 500) {
            if (statusCode === 422) {
                error = new apollo.ValidationError(message);
            } else if (statusCode === 401) {
                error = new apollo.AuthenticationError(message);
            } else if (statusCode === 403) {
                error = new apollo.ForbiddenError(message);
            } else {
                error = new apollo.UserInputError(message);
            }

            if (err && err.stack) {
                if (removeUserStack) {
                    error.stack = undefined;
                } else {
                    error.stack = err.stack;
                }
            }
        } else {