text: var __assign = (this && this.__assign) || function () {
      __assign = Object.assign || function(t) {
          for (var s, i = 1, n = arguments.length; i < n; i++) {
              s = arguments[i];
              for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                  t[p] = s[p];
          }
          return t;
      };
      return __assign.apply(this, arguments);
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  var graphql_1 = require("graphql");
  var heal_1 = require("./heal");
  var isSpecifiedScalarType_1 = require("./isSpecifiedScalarType");
  function cloneDirective(directive) {
      return new graphql_1.GraphQLDirective(directive.toConfig());
  }
  exports.cloneDirective = cloneDirective;
  function cloneType(type) {
      if (type instanceof graphql_1.GraphQLObjectType) {
          var config = type.toConfig();
          return new graphql_1.GraphQLObjectType(__assign(__assign({}, config), { interfaces: config.interfaces.slice() }));
      }
      else if (type instanceof graphql_1.GraphQLInterfaceType) {
          return new graphql_1.GraphQLInterfaceType(type.toConfig());
      }
      else if (type instanceof graphql_1.GraphQLUnionType) {
          var config = type.toConfig();
          return new graphql_1.GraphQLUnionType(__assign(__assign({}, config), { types: config.types.slice() }));
      }
      else if (type instanceof graphql_1.GraphQLInputObjectType) {
          return new graphql_1.GraphQLInputObjectType(type.toConfig());
      }
      else if (type instanceof graphql_1.GraphQLEnumType) {
          return new graphql_1.GraphQLEnumType(type.toConfig());
      }
      else if (type instanceof graphql_1.GraphQLScalarType) {
          return isSpecifiedScalarType_1.default(type) ? type : new graphql_1.GraphQLScalarType(type.toConfig());
      }
      else {
          throw new Error("Invalid type " + type);
      }
  }
  exports.cloneType = cloneType;
  function cloneSchema(schema) {
      var newDirectives = schema.getDirectives().map(function (directive) { return cloneDirective(directive); });
      var originalTypeMap = schema.getTypeMap();
      var newTypeMap = {};
      Object.keys(originalTypeMap).forEach(function (typeName) {
          if (!typeName.startsWith('__')) {
              newTypeMap[typeName] = cloneType(originalTypeMap[typeName]);
          }
      });
      heal_1.healTypes(newTypeMap, newDirectives);
      var query = schema.getQueryType();
      var mutation = schema.getMutationType();
      var subscription = schema.getSubscriptionType();
      return new graphql_1.GraphQLSchema(__assign(__assign({}, schema.toConfig()), { query: query ? newTypeMap[query.name] : undefined, mutation: mutation ? newTypeMap[mutation.name] : undefined, subscription: subscription ? newTypeMap[subscription.name] : undefined, types: Object.keys(newTypeMap).map(function (typeName) { return newTypeMap[typeName]; }), directives: newDirectives }));
  }
  exports.cloneSchema = cloneSchema;
  //# sourceMappingURL=clone.js.map