
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storePerfect! I found the exact solution to your problem. The trick is to use the count() function combined with the @ filter operator to check if any elements from one array exist in another array.
Here's how to solve your problem:
*[_type == 'blog' && count(categories[@ in $categories]) > 0] {
_id,
_updatedAt,
categories,
description,
title,
timeToRead,
publishedAt,
}Where $categories is your array parameter (e.g., ["Design", "Research"]).
How it works:
The expression categories[@ in $categories] filters the categories array to only include elements that exist in your $categories parameter array. Then count() counts how many matches there are. If the count is greater than 0, it means at least one category matches, and that blog post is included in the results.
Example:
categories: ["Design", "UX", "Frontend"]$categories: ["Design", "Research"]categories[@ in $categories] evaluates to ["Design"]count(["Design"]) returns 11 > 0, this blog is included in resultsThis is exactly the "array intersection" check you need! The @ symbol in GROQ represents the current element being iterated over, and the in operator checks if that element exists in the comparison array.
This pattern comes from this community discussion about comparing arrays and checking for string overlap in GROQ queries, which is exactly your use case.
You can test this in Vision (Sanity's query testing tool) with your parameters to verify it works as expected!
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store