Query on a relationship

I am able to query a property of the class directly:

@StateObject var viewModel = PFTour.query("name" == "Notchtop")
        .order([.descending("date")])
        .includeAll()
        .viewModel

But when I query on a relationship, I get no results:

@StateObject var viewModel = PFTour.query("route.state" == "Colorado")
        .order([.descending("date")])
        .includeAll()
        .viewModel

Abbreviated parse objects are below. What am I getting wrong here?

struct PFTour: ParseObject {
    //: These are required by ParseObject
    var objectId: String?
    var createdAt: Date?
    var updatedAt: Date?
    var ACL: ParseACL?
    var originalData: Data?
    //: Your own properties.
    var name: String?
    var published: Bool?
    var route: PFRoute?
}
struct PFRoute: ParseObject {
//: These are required by ParseObject
var objectId: String?
var createdAt: Date?
var updatedAt: Date?
var ACL: ParseACL?
var originalData: Data?

//: Your own properties.
var name: String?
var area: String?
var state: String?
}

Does that query work for other SDKs? I know dot notation works when including nested data, but I don’t know about querying against it. You can post the .debugDescription Of your query and maybe someone on the server team can tell you if it should work.

I suspect there are different ways to construct your query to achieve what you want. Maybe matcheskeyinquery:
https://parseplatform.org/Parse-Swift/release/documentation/parseswift/matcheskeyinquery(key:querykey:query:)

If you look in the documentation under Functions and Operators you can see all of the QueryConstraint‘s

If I add the route objectID as a property to the tour I can use

@StateObject var viewModel = PFTour.query(matchesKeyInQuery(key: "routeObjectId", queryKey: "objectId", query: PFRoute.query("state" == "Colorado")))

Ideally I would like a query where an object’s key points to a relationship that is found in the result of the secondary query:

@StateObject var viewModel = PFTour.query(matchesObjectInQuery(key: "route", query: PFRoute.query("state" == "Colorado")))

Does this make sense?