<commit_before>import client from 'part:@sanity/base/client'
import {set} from 'lodash'

export default function fetchWithPaths(id, paths) {
  const labeledFields = paths.map((selection, i) => `"_f_${i}": ${selection}`)
  return client.fetch(`*[_id==$id]{_id,_type,${labeledFields.join(',')}}`, {id})
    .then(result => result[0])
    .then(result => {
      const {_id, _type, ...labels} = result
      const res = {_id, _type}
      Object.keys(labels).forEach((label, i) => {
        set(res, paths[i], labels[`_f_${i}`])
      })
      return res
    })
}<commit_msg>[previews] Join paths<commit_after>import client from 'part:@sanity/base/client'
import {set} from 'lodash'

export default function fetchWithPaths(id, paths) {
  const labeledFields = paths.map((path, i) => `"_f_${i}": ${path.join('.')}`)
  return client.fetch(`*[_id==$id]{_id,_type,${labeledFields.join(',')}}`, {id})
    .then(result => result[0])
    .then(result => {
      const {_id, _type, ...labels} = result
      const res = {_id, _type}
      Object.keys(labels).forEach((label, i) => {
        set(res, paths[i], labels[`_f_${i}`])
      })
      return res
    })
}
{'fraction_non_alphanumeric': 0.21006944444444445, 'fraction_numerical': 0.001736111111111111, 'mean_word_length': 3.706122448979592, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5623103', 'n_tokens_mistral': 414, 'n_tokens_neox': 407, 'n_words': 84}