Join us live Sept. 27 – How Sanity and Vercel powered Morning Brew's transformation –>

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: Get the most out of your content

Sanity.io is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Give your team exactly what they need to edit and publish their content with the customizable Sanity Studio. Get real-time collaboration out of the box. Sanity.io comes with a hosted datastore for JSON documents, query languages like GROQ and GraphQL, CDNs, on-demand asset transformations, presentation agnostic rich text, plugins, and much more.

Don't compromise on developer experience. Join thousands of developers and trusted companies and power your content with Sanity.io. Free to get started, pay-as-you-go on all plans.