Best way to handle nested filtering?

Hi everyone,
I’m building an API using JSON:API spec and I’m a bit stuck on how to properly implement filtering on a nested relationship (e.g., /articles?filter[comments.author.name]=John).
Is this kind of deep filtering considered valid, or should it be handled differently?

Appreciate any advice!

The JSON:API specification is agnostic about filtering. It only defines that filter query parameter family should be used for it. How filtering is implemented is up to each implementation. It may be specified by a profile.

Filtering a collection based on attributes of related resources (or their existence) is a common use case. Reusing the concept of relationship paths defined by the specification for the include query parameter is a good choice in my opinion. Doing so ensures that the filtering semantics are well aligned with the rest of the specification.

I think someone should formalize that strategy as a profile at some point in time.