@graphql-mesh/transport-rest
Version:
24 lines (23 loc) • 817 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getJsonApiFieldsQuery = void 0;
const tslib_1 = require("tslib");
const graphql_fields_1 = tslib_1.__importDefault(require("graphql-fields"));
function handleFields(fields) {
const fieldsStrsArray = [];
for (const fieldName in fields) {
const subFields = fields[fieldName];
const subFieldsStr = handleFields(subFields);
let fieldStr = fieldName;
if (subFieldsStr) {
fieldStr += `(${subFieldsStr})`;
}
fieldsStrsArray.push(fieldStr);
}
return fieldsStrsArray.join(',');
}
function getJsonApiFieldsQuery(info) {
const fields = (0, graphql_fields_1.default)(info);
return handleFields(fields);
}
exports.getJsonApiFieldsQuery = getJsonApiFieldsQuery;
;