Is it possible to set a weak reference through a mutation in

2 replies
Last updated: Feb 2, 2024
Is it possible to set a weak reference through a mutation? My current mutation is this:

mutation = {
            mutations: [
                    create: {
                        _id: crypto.randomUUID(),
                        _type: "team",
                        badgeUrl: team.logo,
                        isNationalTeam: team.national,
                        country: {
                            _type: 'reference',
                            weak: true,
                            _ref: sanityCountry._id
                        slug: {
                            type: '_slug',
                            current: slugify(`${}-${}`)
Yet, when I add the
weak: true
to the country reference, it returns this error code when this prop is included:
ERROR TypeError: Cannot read properties of undefined (reading '0')

So my question is, is this possible?
Jan 24, 2024, 9:37 AM
I think you need to use
Jan 24, 2024, 9:35 PM
This resolved it, thank you!
Feb 2, 2024, 12:52 PM

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?