"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.createGqlQueryFn = exports.createGqlMutation = exports.toGqlQuery = void 0;

const toGqlQuery = arr => "{".concat(arr.reduce((result, item, index) => result + (index === 0 ? '' : ' ') + (Array.isArray(item) ? "".concat(item[0], " ").concat(toGqlQuery(item.slice(1))) : item), ''), "}");

exports.toGqlQuery = toGqlQuery;

const createGqlFn = (name, vars, responseSnippet = '') => {
  const entries = Object.entries(vars);
  const argsList = entries.map(([name, type]) => "$".concat(name, ":").concat(type)).join(',');
  const argsList2 = entries.map(([name]) => "".concat(name, ":$").concat(name)).join(',');
  return "".concat(name, "(").concat(argsList, "){").concat(name, "(").concat(argsList2, ")").concat(responseSnippet, "}");
};

const createGqlMutation = (name, vars, responseSnippet = '') => "mutation ".concat(createGqlFn(name, vars, responseSnippet));

exports.createGqlMutation = createGqlMutation;

const createGqlQueryFn = (name, vars, responseSnippet = '') => "query ".concat(createGqlFn(name, vars, responseSnippet));

exports.createGqlQueryFn = createGqlQueryFn;