Creating Pagination for Two Different Resources in AshGraphQL

I’m trying to write an API in AshGraphQL to display list results for two different resources belonging to a user.

https://hexdocs.pm/ash_graphql/use-unions-with-graphql.html

From the above documentation, I know how can build the return value, but I don’t know the rest.

Q1) I should create actions with action types from user resources, right?

user.ex

action :list_posts_by_users, UnionResponseType do
  ...     
end
union_response_type.ex

defmodule MyApp.UnionResponseType do
  use Ash.Type.NewType, subtype_of: :union, constraints: [
    types: [
      dentallab_post: [
        # This is an embedded resource, with its own fields
        type: :struct,
        constraints: [...]
      ],
      question_post: [
        # This is an embedded resource, with its own fields
        type: :struct,
        constraints: [...]
      ]
    ]
  ]

  use AshGraphql.Type

  # Add this to define the union in ash_graphql
  def graphql_type(_), do: :armor
end
  1. Should I use actions in these cases? Can I create pagination in an action?

I got hint from this article And I’m trying.