"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 inputFieldRemoved(input, field) {
    return {
        criticality: {
            level: change_1.CriticalityLevel.Breaking,
            reason: 'Removing an input field will cause existing queries that use this input field to error.',
        },
        message: "Input field '" + field.name + "' was removed from input object type '" + input.name + "'",
        path: [input.name, field.name].join('.'),
    };
}
exports.inputFieldRemoved = inputFieldRemoved;
function inputFieldAdded(input, field) {
    return {
        criticality: graphql_1.isNonNullType(field.type)
            ? {
                level: change_1.CriticalityLevel.Breaking,
                reason: 'Adding a possible type to Unions may break existing clients that were not programming defensively against a new possible type.',
            }
            : {
                level: change_1.CriticalityLevel.NonBreaking,
            },
        message: "Input field '" + field.name + "' was added to input object type '" + input.name + "'",
        path: [input.name, field.name].join('.'),
    };
}
exports.inputFieldAdded = inputFieldAdded;
function inputFieldDescriptionChanged(input, oldField, newField) {
    return {
        criticality: {
            level: change_1.CriticalityLevel.NonBreaking,
        },
        message: "Input field '" + input.name + "." + oldField.name + "' description changed from '" + oldField.description + "' to '" + newField.description + "'",
        path: [input.name, oldField.name].join('.'),
    };
}
exports.inputFieldDescriptionChanged = inputFieldDescriptionChanged;
function inputFieldDefaultValueChanged(input, oldField, newField) {
    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: "Input field '" + input.name + "." + oldField.name + "' default value changed from '" + oldField.defaultValue + "' to '" + newField.defaultValue + "'",
        path: [input.name, oldField.name].join('.'),
    };
}
exports.inputFieldDefaultValueChanged = inputFieldDefaultValueChanged;
function inputFieldTypeChanged(input, oldField, newField) {
    return {
        criticality: graphql_2.safeChangeForInputValue(oldField.type, newField.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,
                reason: 'Changing the type of an input field can cause existing queries that use this field to error.',
            },
        message: "Input field '" + input.name + "." + oldField.name + "' changed type from '" + oldField.type.toString() + "' to '" + newField.type.toString() + "'",
        path: [input.name, oldField.name].join('.'),
    };
}
exports.inputFieldTypeChanged = inputFieldTypeChanged;
//# sourceMappingURL=input.js.map