As doc says
Note: Connections are often associated with cursor-based pagination, due to the use of a cursor. Nonetheless, since the specification describes the cursor as opaque, it can be used to facilitate an offset as well.
Note: While we support offset-based pagination, we highly encourage the use of Connections instead. Connections provide an abstraction which makes it easier to switch to another pagination mechanism later on.
but no example provided.
Any idea how to implement offset pagination with Connection in Hot Chocolate? Its not clear for me.
The information here is based on an implementation of HotChocolate v13
I did find that the HotChocolate v12 documentation has some additional information on Pagination that helps. Best to read both.
https://chillicream.com/docs/hotchocolate/v12/fetching-data/pagination https://chillicream.com/docs/hotchocolate/v13/fetching-data/pagination
Using the [UsePaging] attribute on the query automatically adds the connection to the schema. In the below example, I have a type called AreaType. The AreaTypesConnection was automatically created when using [UsePaging]. You will need to perform some operations on the client-side to populate the parameters highlighted below. These parameters configure the cursor.
Under the connection, the nodes contains your collection of items returned by the query (e.g. areaTypes). The totalCount returns the number of items being retrieved.
Under pageInfo, there are additional values that HotChocolate populates to help configure the cursor on the client-side.
If you were strictly looking for configuring cursor pagination on the client-side, I would not search for HotChocolate examples specifically. I would google the client-side technology you are using (e.g. "cursor pagination in angular"). Combined with the above information should help.
Of course, you can opt to not use connections. You can use the [UseOffsetPaging] attribute instead of the [UsePaging] attribute. When using the [UseOffsetPaging] attribute, a collection segment is created instead of a connection. There is a little more ease in this option. You only need to configure skip and take parameters.
When viewing the collection segment, instead of nodes, the collection of items is simply called items. You can still retrieve your totalCount which can be used to determine your skip and take parameter values. Under pageInfo, is additional properties populated by HotChocolate that you may also need to determine your skip and take parameter values.