Join live – Get insights, tips, + Q&A from Sanity developers on our latest releases

Can I select which fields to return or expand in the output of a patch operation in Sanity.io?

4 replies
Last updated: Oct 10, 2023
Hello team, question regarding the
patch
operation, is there a way to select which fields to return or expand in the output? I’m using the Javascript client BTW:
const sanityResponse = await sanityClient
    .patch(id)
    .set({[fieldName]: fieldValue})
    .commit();
Oct 10, 2023, 3:26 PM
Hi
user J
. A patch should return the updated object , which you can then filter, output, or work with.
Oct 10, 2023, 7:53 PM
If one of the fields is a reference… can I have it expanded in the output somehow, or do I have to make another query?
Oct 10, 2023, 7:57 PM
Correct; it would require another query.
Oct 10, 2023, 8:14 PM
Gotcha, thank you
Oct 10, 2023, 8:27 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?