GraphQL Custom Resolver: Custom Payload Type for different object types in an array

I have an Atlas Function which is returning an array of two different objects (each one is from a different Collection and has a different schema). I want to use the Realm GraphQL API to return results so I’m creating a custom resolver. The problem I’m having is in defining the Payload Type for that resolver. JSON Schema would normally allow for anyOf to allow for multiple acceptable types but this doesn’t seem to be accepted in Atlas Services.

Here is a stripped down version of the two objects and the schema that I attempt to copy into the Payload Type field. (They are just simple strings for the example but in my actual use case they contain many other fields):

{
  "type": "array",
  "title": "agentsWithAds",
  "items": {
    "anyOf": [
      {
        "bsonType": "object",
        "properties": { 
          "_id": { "bsonType": "objectId" },
          "advertiser": { "bsonType": "string" }
        }
      },
      {
        "bsonType": "object",
        "properties": { 
          "_id": { "bsonType": "objectId" },
          "agent": { "bsonType": "string"}
        }
      }
    ]
  }
}

The type is array and I want it to accept any of the stated object types .

I receive the following error which prevents me from saving the custom resolver:

How can I get the GraphQL API to serve up results from two different object types?

Is there a different syntax to use for the Payload Type which would allow me to do the same thing? Or is there another way altogether that will allow me to return two different object types from one resolver?

Reference

I’ve read through this topic in depth which suggests using the anyOf syntax but only on a field. The original poster didn’t seem to be able to get that to work either. I also didn’t understand what was meant by:

The generated schema will ignore this field, but it can still be accessed via the custom resolver, (likely by having to define two different types).