Error with Xcode 15 beta 5

I am getting the following error on this line of code

@Query(sort: \.id, order: .reverse) private var artList: [ArtInventory]

Cannot infer key path type from context; consider explicitly specifying a root type

So, I select fix and then the line of code then look like this

 @Query(sort: \<#Root#>.id, order: .reverse) private var artList: [ArtInventory]
with this error

Invalid component of Swift key path

Some seems to have changed with the @Query macro in beta 5, which now needs a root type, but not sure how to proceed.

Any ideas how to fix?

You must provide the model type used for the root type of the key path, i.e. \ModelType.property instead of .property. Apple uses the following example in the Xcode 15 beta 5 release notes:

 @Query(sort: \Person.name) var people: [Person]

In your case it would be something like,

@Query(sort: \Person.id, order: .reverse) private var artList: [ArtInventory]
Error with Xcode 15 beta 5
 
 
Q