Dec 14th - Learn how Tecovas roped in success with Sanity and Shopify 🀠

Query Returning Expected Results in Vision but not in Custom Validation

10 replies
Last updated: Apr 30, 2021
I cannot seem to find the documentation for the recent API changes (2021-03-25). I have a query that will return the expected results in Vision with this version, but using that same query in a custom validation yields no results. It appears that Studio is using the v.1 API internally (for the client it exposes through the parts system). Can anyone confirm this?
Apr 29, 2021, 4:01 PM
This is the query:
count(*[_type == 'product' &&
    $value in variants[(_key != $key && ^._id in [$draft, $published])].id
And these are the params:

β€’ on v2021-03-25: count: 1 (expected)
β€’ on v.1: count: 0
Apr 29, 2021, 4:06 PM
While the query can be rewritten as:
count(*[_type == 'product' &&
   _id in [$draft, $published] && $value in variants[_key != $key].id
It still strikes me as odd that the client that is exposed remains on the v.1 API.
Apr 29, 2021, 4:17 PM
user Y
could you please clarify the difference between the following pieces of GROQ? They yield different results, the first one works as expected during validation, while the other doesn't:
!(_id in [$published]) && $value in variants[].id

$value in variants[!(^._id in [$published])].id
Apr 29, 2021, 5:01 PM
Apr 30, 2021, 1:25 PM
Thanks, that explains the
related differences I was seeing! I couldn't find the changelog linked in the documentation though, where did you find it?
Apr 30, 2021, 1:27 PM
I ended up searching the help-channel, but did the exact same thing as you yesterday: posting here in search of a consolidated listπŸ˜›
Apr 30, 2021, 1:28 PM
Cool, thanks! I just re-checked the site search and it actually doesn't show up there either!
Apr 30, 2021, 1:29 PM
It would, as you note, be helpful to either link to the changelog in the document on api-versioning, or make the changelog searchable πŸ™‚
Apr 30, 2021, 1:30 PM
My hunch that internally, the
API is being used appears to be correct:
Apr 30, 2021, 5:48 PM
Which is good to know when prototyping queries in
with a different API version πŸ˜†
Apr 30, 2021, 5:49 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?