
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeGreat question! Yes, GROQ has a built-in function for exactly this: array::join().
You can modify your query like this:
*[_type == "technologyProduct"]{
"sectors": array::join(targetIndustries[]->title, ", "),
}The array::join() function takes two parameters:
", " for comma-separated)It returns a single concatenated string.
According to the GROQ Functions Reference, the syntax is:
array::join(source <array[string|number|boolean]>, separator<string>) <string>So in your case, targetIndustries[]->title produces an array of strings, and array::join() combines them into a single comma-separated string.
Note that if any element in the array isn't a string, number, or boolean, the function will return null. Also, if the input itself isn't an array (like if it's a single value), it will return null as well.
You can find more examples in the Query Cheat Sheet which shows examples like array::join(["a", "b", "c"], ".") returning "a.b.c".
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