If sourcePath alone isn't enough to tell you if it's safe to contain stega strings, then you can use sourceDocument
for additional metadata.
It'll always have a _type property, which can be used to trace it to the Studio Schema that were used initially.
It also has _id to help you debug and look at the whole document when troubleshooting.
Finally, if the document origins in a Cross Dataset Reference you'll also have _projectId and _dataset properties to help you trace it.
If you don't colocate your Studio Schemas with your GROQ queries it might be hard to make sense of sourcePath,
as it operates on the original shape of a document.
In that case resultPath can be used, as it mirrors the path to the value in the result.
For example in a query like this:
*[_type == "author"][0]{"slug": slug.current}
The resultPath for result.slug would be ['slug'], while sourcePath will be ['slug', 'current'].
You can also use your own string validation logic to determine if it's safe.
If you want to keep the default filtering behavior, but only override it for a specific path, you can use filterDefault to do that.
For example, here all "icon" documents in a Page Builder skips encoding:
{
filter: (props) => {
switch (props.sourceDocument._type) {
case 'icon':
return false
default:
return props.filterDefault(props)
}
}
}
*
The path to the value in the source document, for example if you queried for a document like this:
*[_type == "author"][0]{"slug": slug.current}Then thesourcePathforresult.slugwould be['slug', 'current'].