Fetch multiple documents from linked data source in app service function

Hi, I am trying to create a app service function which does some computation on data retrieved from a linked data source. When trying to retrieve multiple documents from the accessGroups collection with the $in operator I found out that the return object from the await context.services.get(... function appears to be a normal list, when returning it from the app service function. However, I was not able to do anything with the returned documents in the app services function as they appear to be interpreted as null values. For now I am using a workaround where I query the accessGroups collection multiple times. Here is a snippet of the code:

// Returns list of ObjectIds of assets the user has access to
exports = async function () {
    // ...
    const assets = []
    // For some reason I am not able to retrieve all access groups like this:
    const accessGroups = await context.services.get("mongodb-atlas").db(context.user.custom_data.databaseName).collection("accessGroups").find({_id: {$in: context.user.custom_data.accessGroups}})
    // Returning accessGroups from the function works, but if I for instance try to retrieve the first element of the list `accessGroups[0]` it returns `null`.
    for (let i=0; i<accessGroups.length; i++) {
        // Do some stuff with accesGroups[i]

    // Workaround: Fetch one access group at a time.
    //for (let i=0; i<context.user.custom_data.accessGroups.length; i++) {
    //  const accessGroup = await context.services.get("mongodb-atlas").db(context.user.custom_data.databaseName).collection("accessGroups").findOne({_id: context.user.custom_data.accessGroups[i]})
    //  assets.push(...(accessGroup.assets))
    return assets

Am I doing something wrong here?