text: "use strict";
  var __extends = (this && this.__extends) || (function () {
      var extendStatics = function (d, b) {
          extendStatics = Object.setPrototypeOf ||
              ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
              function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
          return extendStatics(d, b);
      };
      return function (d, b) {
          extendStatics(d, b);
          function __() { this.constructor = d; }
          d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
      };
  })();
  Object.defineProperty(exports, "__esModule", { value: true });
  var generator_1 = require("../../generator");
  var prisma_datamodel_1 = require("prisma-datamodel");
  var graphql_1 = require("graphql");
  var QueryGenerator = /** @class */ (function (_super) {
      __extends(QueryGenerator, _super);
      function QueryGenerator() {
          return _super !== null && _super.apply(this, arguments) || this;
      }
      QueryGenerator.prototype.getTypeName = function (input, args) {
          return 'Query';
      };
      QueryGenerator.prototype.generateInternal = function (input, args) {
          var _this = this;
          var fieldMaps = input
              .filter(function (type) { return !type.isEnum && !type.isEmbedded; })
              .map(function (type) {
              return generator_1.FieldConfigUtils.merge(_this.generateOneQueryField(type), _this.generateManyQueryField(type));
          });
          return new graphql_1.GraphQLObjectType({
              name: this.getTypeName(input, args),
              fields: generator_1.FieldConfigUtils.merge.apply(generator_1.FieldConfigUtils, fieldMaps.concat([this.getNodeField()])),
          });
      };
      QueryGenerator.prototype.getNodeField = function () {
          var fields = {};
          fields.node = {
              type: this.generators.node.generate(null, {}),
              args: {
                  id: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID) },
              },
          };
          return fields;
      };
      QueryGenerator.prototype.generateOneQueryField = function (model) {
          var fields = {};
          if (this.generators.uniqueQueryArguments.wouldBeEmpty(model, {})) {
              return fields;
          }
          fields[prisma_datamodel_1.camelCase(model.name)] = {
              type: this.generators.model.generate(model, {}),
              args: this.generators.uniqueQueryArguments.generate(model, {}),
          };
          return fields;
      };
      QueryGenerator.prototype.generateManyQueryField = function (model) {
          var fields = {};
          fields[prisma_datamodel_1.camelCase(prisma_datamodel_1.plural(model.name))] = {
              type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(this.generators.model.generate(model, {}))),
              args: this.generators.manyQueryArguments.generate(model, {}),
          };
          fields[prisma_datamodel_1.camelCase(prisma_datamodel_1.plural(model.name)) + "Connection"] = {
              type: new graphql_1.GraphQLNonNull(this.generators.modelConnection.generate(model, {})),
              args: this.generators.manyQueryArguments.generate(model, {}),
          };
          return fields;
      };
      return QueryGenerator;
  }(generator_1.RootGenerator));
  exports.default = QueryGenerator;
  //# sourceMappingURL=queryGenerator.js.map