Your IP : 216.73.216.220


Current Path : /home/deltalab/PMS/ims-connector/node_modules/graphql-compose-mongoose/lib/errors/
Upload File :
Current File : //home/deltalab/PMS/ims-connector/node_modules/graphql-compose-mongoose/lib/errors/index.js

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getErrorInterface = exports.RuntimeError = exports.ValidationError = void 0;
const graphql_compose_1 = require("graphql-compose");
const MongoError_1 = require("./MongoError");
const ValidationError_1 = require("./ValidationError");
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return ValidationError_1.ValidationError; } });
const RuntimeError_1 = require("./RuntimeError");
Object.defineProperty(exports, "RuntimeError", { enumerable: true, get: function () { return RuntimeError_1.RuntimeError; } });
function getErrorInterface(schemaComposer) {
    const ErrorInterface = schemaComposer.getOrCreateIFTC('ErrorInterface', (iftc) => {
        iftc.addFields({
            message: {
                description: 'Generic error message',
                type: 'String',
            },
        });
        const ValidationErrorOTC = (0, ValidationError_1.getValidationErrorOTC)(schemaComposer);
        const MongoErrorOTC = (0, MongoError_1.getMongoErrorOTC)(schemaComposer);
        const RuntimeErrorOTC = (0, RuntimeError_1.getRuntimeErrorOTC)(schemaComposer);
        ValidationErrorOTC.addInterface(iftc);
        MongoErrorOTC.addInterface(iftc);
        RuntimeErrorOTC.addInterface(iftc);
        schemaComposer.addSchemaMustHaveType(ValidationErrorOTC);
        schemaComposer.addSchemaMustHaveType(MongoErrorOTC);
        schemaComposer.addSchemaMustHaveType(RuntimeErrorOTC);
        let ValidationErrorType;
        let MongoErrorType;
        let RuntimeErrorType;
        if (graphql_compose_1.graphqlVersion >= 16) {
            ValidationErrorType = ValidationErrorOTC.getTypeName();
            MongoErrorType = MongoErrorOTC.getTypeName();
            RuntimeErrorType = RuntimeErrorOTC.getTypeName();
        }
        else {
            ValidationErrorType = ValidationErrorOTC.getType();
            MongoErrorType = MongoErrorOTC.getType();
            RuntimeErrorType = RuntimeErrorOTC.getType();
        }
        iftc.setResolveType((value) => {
            switch (value === null || value === void 0 ? void 0 : value.name) {
                case 'ValidationError':
                    return ValidationErrorType;
                case 'MongoError':
                    return MongoErrorType;
                default:
                    return RuntimeErrorType;
            }
        });
    });
    return ErrorInterface;
}
exports.getErrorInterface = getErrorInterface;
//# sourceMappingURL=index.js.map