← back to Dw Sarah Rowland Searchfix

test-state.mjs

16 lines

import { gql } from './lib.mjs';
import fs from 'node:fs';
const products=JSON.parse(fs.readFileSync(new URL('./products.json',import.meta.url)));
// pick 5 that were previously invisible (generic or koroseal-named titles, no 'Sarah Rowland' in title)
const invis=products.filter(p=>!/sarah\s*rowland/i.test(p.title)).slice(0,5);
const Q=`query($id:ID!){ product(id:$id){ title vendor
  brand:metafield(namespace:"custom",key:"brand"){value}
  gbrand:metafield(namespace:"global",key:"Brand"){value}
  designer:metafield(namespace:"custom",key:"designer"){value} } }`;
console.log('Sample of formerly-invisible products — what their Designer-row source holds:\n');
for(const p of invis){
  const d=(await gql(Q,{id:p.id})).product;
  console.log(`• ${d.title.slice(0,42)}`);
  console.log(`    vendor=${d.vendor}  custom.brand=${d.brand?.value??'∅'}  global.Brand=${d.gbrand?.value??'∅'}  custom.designer=${d.designer?.value??'∅'}`);
}