πŸ‘€ See Sanity in action: Watch product demo now β†’

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.io – build remarkable experiences at scale

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

Categorized in