Absinthe offset based pagination

Is there any way to customize the output of list response? Like I already have a mechanism to paginate which takes only offset passed from the client, which then decoded, validated and used in list query.
So right now what I achieve is

{
  "data": {
    "items": [
      {
        "id": "2"
      }
    ]
  }
}
  1. Is it possible to modify response to
{
  "data": {
    "items": [
      {
        "id": "2"
      }
    ]
  },
  "pagination": { # Or even add custom headers like Github does with X-PAGE-NEXT, etc.
     "next" : "xyz",
     "prev": null
  }
}

Or shall I create a “type” for my “paged list”. Then how can I achieve it with absinthe. Creating blah_page for each list occasion is a boilerplate code for sure.
2. Does it affect client somehow? Currently didn’t dig into this. So may be somebody already faced with this questions.

@vlad.grb I find Absinthe is not intend for it. Absinthe provides a default Graphql pagination fields (pageInfo / edges) https://hexdocs.pm/absinthe_relay/Absinthe.Relay.Connection.html. However, you can add custom fields for your pagination response (https://hexdocs.pm/absinthe_relay/Absinthe.Relay.Connection.html#module-customizing-types).

In my case, I’ve added total_count info.

field :students, non_null(:class_student_connection) do
  arg :status, :string
  arg :name, :string
  arg :email, :string
  arg :order_by, list_of(:actived_students_order_by)
  relay_paginator_args()
  search_args()
  resolve &SomosIdWeb.Resolvers.Students.find_by_class_paginator/2
end

connection node_type: :class_student do
  field :total_count, :integer do
    resolve fn _, %{source: conn} ->
      {:ok, conn.total_count}
    end
  end
  edge do
  end
end

total_count is a standard pagination info on Graphql ( https://graphql.org/learn/pagination/ )

3 Likes