"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
function safeChangeForField(oldType, newType) {
    if (!graphql_1.isWrappingType(oldType) && !graphql_1.isWrappingType(newType)) {
        return oldType === newType;
    }
    if (graphql_1.isNonNullType(newType)) {
        var ofType = graphql_1.isNonNullType(oldType) ? oldType.ofType : oldType;
        return safeChangeForField(ofType, newType.ofType);
    }
    if (graphql_1.isListType(oldType)) {
        return ((graphql_1.isListType(newType) &&
            safeChangeForField(oldType.ofType, newType.ofType)) ||
            (graphql_1.isNonNullType(newType) && safeChangeForField(oldType, newType.ofType)));
    }
    return false;
}
exports.safeChangeForField = safeChangeForField;
function safeChangeForInputValue(oldType, newType) {
    if (!graphql_1.isWrappingType(oldType) && !graphql_1.isWrappingType(newType)) {
        return oldType === newType;
    }
    if (graphql_1.isListType(oldType) && graphql_1.isListType(newType)) {
        return safeChangeForInputValue(oldType.ofType, newType.ofType);
    }
    if (graphql_1.isNonNullType(oldType)) {
        var ofType = graphql_1.isNonNullType(newType) ? newType : newType;
        return safeChangeForInputValue(oldType.ofType, ofType);
    }
    return false;
}
exports.safeChangeForInputValue = safeChangeForInputValue;
function isPrimitive(type) {
    return (['String', 'Int', 'Float', 'Boolean', 'ID'].indexOf(typeof type === 'string' ? type : type.name) !== -1);
}
exports.isPrimitive = isPrimitive;
function isCommon(type) {
    return ([
        '__Schema',
        '__Type',
        '__TypeKind',
        '__Field',
        '__InputValue',
        '__EnumValue',
        '__Directive',
        '__DirectiveLocation',
    ].indexOf(typeof type === 'string' ? type : type.name) !== -1);
}
exports.isCommon = isCommon;
//# sourceMappingURL=graphql.js.map