How to paginate a union in graphql?

Say you have three mongo collections, three graphql types respectively, and they come together in a graphql endpoint that uses a union to return an array [Type1, Type2, Type3].

Does anyone have experience they could share paginating something like this?

For cursor based pagination, I ended up keeping track of the cursor for each type and sending those cursors to the resolver as parameters.

That’s a nice solution

1 Like