šŸ‘‹ Next.js Conf 2024: Come build, party, run, and connect with us! See all events

Hi! How to add a doc via sanity client that has a *weak* reference? If I do this, it throws an error `key "weak" not allowed in ref`: ```const author = { _type: 'reference', ...

1 replies
Last updated: Feb 2, 2021
Hi! How to add a doc via sanity client that has a weak reference? If I do this, it throws an error `key "weak" not allowed in ref`:
const author = {
  _type: 'reference',
  _ref: id,
  weak: true,
};
However, if I remove
weak
, after creating the doc via sanity client the studio tells me "Warning: This reference is strong, but should be weak according to schema."
Feb 2, 2021, 11:34 AM
Try
_weak
instead, with the underscore šŸ™‚ Without it only goes for schemas, not the actual JSON. Sorry about the confusion there.
Feb 2, 2021, 11:39 AM

Sanityā€“ build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?