Include nested objects of array elements in query

My Task class has an array property annotations, which stores pointers to Annotation objects. Annotation has a user property which points to Parse.User:

Task { annotations: Array<Annotation> }
Annotation { user: Parse.User }

I’m looking for a way to fetch tasks together with their annotations and the annotation’s users in a single query.

Getting the annotations is easy with include:

new Parse.Query('Task').include('annotations')

However, this way the user property of returned annotation objects is undefined. I tried include('annotations.user'), but that doesn’t work either.

Is there a way to achieve this with Parse queries, or do I have to manually fetch the array objects to get their content? Thanks in advance :slight_smile:

I believe include('annotations.user') should work but you won’t be able to do that directly from client because you don’t have read public permission to the user class. So I’d try to do the same via cloud code function and passing the useMasterKey option.

You are correct, this seems to be related to read permissions on the User class. My code already is running in a cloud code function, but I’ve been using the calling user’s session in my query so far. By replacing this with masterKey, the user details are filled in correctly. Thanks for your help!