Found the issue
I was doing this to find the max value
let maxDhvResult = await collection.aggregate([{ $group : { _id: null, maxDataHubVersion: { $max : "$dataHubVersion" }}}]).toArray();
And it’s weird that it works with mongo cloud function editor/graphql but not when I call the graphql customresolver from a C# client.
Changing it to below fixed my issue
let maxDhvResult = await (collection.find({},{dataHubVersion: 1}).sort({datahubVersion:-1}).limit(1).toArray());