Thanks for bringing this to our attention. "Object expected, Object provided." is not a great error message!
Merge and other functions that expect Objects as input expect plain ole objects. Events are not treated as plain objects here. Unfortunately, it looks like the error handling is interpreting an Event as an "Object" when it’s building the message.
It is not clear if Events should or should not be treated as plain objects for the purposes of functions like Merge. And in either case, the error message is unhelpful. I’ve created an internal ticket to straighten this out.
Workarounds
you can define your own Object to return like this:
In general, I recommend handling pagination in your application, rather than doing Select("data",..., but that can be a matter of preference for you and your application.
Just a minor followup, but the Select("data", Paginate(...) is unnecessary. Paginate returns a page, which is an array that contains optional before and after cursor values. Selecting the data field from a Paginate result just gives you the array information that Map would operate on anyway.
There’s no real harm to using Select this way, but it does contribute to the billed compute ops. Removing it saves you 1/50th of a compute op!
This is a Page, so not necessarily tied to being a Page of Events. When you use the Paginate function, this is the result that is always returned. Functions like Filter, Map, and Reduce can accept a Page as an argument, and they will act on the array of data contained in the Page.
(If you are familiar with functional programming, you might consider a Page to be like a kind of monad – roughly speaking, a wrapper around the data that abstracts away some of the functionality of working with it)
Sorry, I didn’t mean to imply not to use Paginate. What I meant is what @ewan said: you don’t have to Select("data", SOME_PAGE) because you can pass the Page directly into Map. The biggest reason I recommend it, though, is because if you Select("data",... then your client will not receive the before or after cursors, which are needed for getting additional Pages. The example I provided does not use Select, so I was offering an example of returning the pagination cursors. Doing so mean that your application needs to be aware it is receiving a page, not just the data, though.