"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
var change_1 = require("./change");
var graphql_2 = require("../utils/graphql");
function directiveRemoved(directive) {
    return {
        criticality: {
            level: change_1.CriticalityLevel.Breaking,
        },
        message: "Directive '" + directive.name + "' was removed",
        path: "@" + directive.name,
    };
}
exports.directiveRemoved = directiveRemoved;
function directiveAdded(directive) {
    return {
        criticality: {
            level: change_1.CriticalityLevel.NonBreaking,
        },
        message: "Directive '" + directive.name + "' was added",
        path: "@" + directive.name,
    };
}
exports.directiveAdded = directiveAdded;
function directiveDescriptionChanged(oldDirective, newDirective) {
    return {
        criticality: {
            level: change_1.CriticalityLevel.NonBreaking,
        },
        message: "Directive '" + oldDirective.name + "' description changed from '" + oldDirective.description + "' to '" + newDirective.description + "'",
        path: "@" + oldDirective.name,
    };
}
exports.directiveDescriptionChanged = directiveDescriptionChanged;
function directiveLocationAdded(directive, location) {
    return {
        criticality: {
            level: change_1.CriticalityLevel.NonBreaking,
        },
        message: "Location '" + location + "' was added to directive '" + directive.name + "'",
        path: "@" + directive.name,
    };
}
exports.directiveLocationAdded = directiveLocationAdded;
function directiveLocationRemoved(directive, location) {
    return {
        criticality: {
            level: change_1.CriticalityLevel.Breaking,
        },
        message: "Location '" + location + "' was removed from directive '" + directive.name + "'",
        path: "@" + directive.name,
    };
}
exports.directiveLocationRemoved = directiveLocationRemoved;
function directiveArgumentAdded(directive, arg) {
    return {
        criticality: {
            level: graphql_1.isNonNullType(arg.type)
                ? change_1.CriticalityLevel.Breaking
                : change_1.CriticalityLevel.NonBreaking,
        },
        message: "Argument '" + arg.name + "' was added to directive '" + directive.name + "'",
        path: "@" + directive.name,
    };
}
exports.directiveArgumentAdded = directiveArgumentAdded;
function directiveArgumentRemoved(directive, arg) {
    return {
        criticality: {
            level: change_1.CriticalityLevel.Breaking,
        },
        message: "Argument '" + arg.name + "' was removed from directive '" + directive.name + "'",
        path: "@" + directive.name + "." + arg.name,
    };
}
exports.directiveArgumentRemoved = directiveArgumentRemoved;
function directiveArgumentDescriptionChanged(directive, oldArg, newArg) {
    return {
        criticality: {
            level: change_1.CriticalityLevel.NonBreaking,
        },
        message: "Description for argument '" + oldArg.name + "' on directive '" + directive.name + "' changed from '" + oldArg.description + "' to '" + newArg.description + "'",
        path: "@" + directive.name + "." + oldArg.name,
    };
}
exports.directiveArgumentDescriptionChanged = directiveArgumentDescriptionChanged;
function directiveArgumentDefaultValueChanged(directive, oldArg, newArg) {
    return {
        criticality: {
            level: change_1.CriticalityLevel.Dangerous,
            reason: 'Changing the default value for an argument may change the runtime behaviour of a field if it was never provided.',
        },
        message: typeof oldArg.defaultValue === 'undefined'
            ? "Default value '" + newArg.defaultValue + "' was added to argument '" + newArg.name + "' on directive '" + directive.name + "'"
            : "Default value for argument '" + oldArg.name + "' on directive '" + directive.name + "' changed from '" + oldArg.defaultValue + "' to '" + newArg.defaultValue + "'",
        path: "@" + directive.name + "." + oldArg.name,
    };
}
exports.directiveArgumentDefaultValueChanged = directiveArgumentDefaultValueChanged;
function directiveArgumentTypeChanged(directive, oldArg, newArg) {
    return {
        criticality: graphql_2.safeChangeForInputValue(oldArg.type, newArg.type)
            ? {
                level: change_1.CriticalityLevel.NonBreaking,
                reason: 'Changing an input field from non-null to null is considered non-breaking.',
            }
            : {
                level: change_1.CriticalityLevel.Breaking,
            },
        message: "Type for argument '" + oldArg.name + "' on directive '" + directive.name + "' changed from '" + oldArg.type + "' to '" + newArg.type + "'",
        path: "@" + directive.name + "." + oldArg.name,
    };
}
exports.directiveArgumentTypeChanged = directiveArgumentTypeChanged;
//# sourceMappingURL=directive.js.map