UNPKG

@graphql-mesh/transport-rest

Version:
19 lines (18 loc) 569 B
import graphqlFields from '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(','); } export function getJsonApiFieldsQuery(info) { const fields = graphqlFields(info); return handleFields(fields); }