Offset pagination with total count

I've found one solution to have totalCount query while using auto-generated queries.
Its a bit hacky, but works.

Lets say you have such type definition:

type Question  {
  nodeId: ID! @id
  title: String!
  text: String!
  totalCount: Int # will be used to implement total count on query resolver
}

And you can make such query type definition:

type Query {
	QuestionCount: Question  # only `totalCount` field will be actually resolved
}

Then create such custom query resolver:

import { cypherQuery } from 'neo4j-graphql-js'

const questionResolvers = {
		QuestionCount: async (_parent, params, context, resolveInfo) => {

             // generating querystring with all necessary filters and params
			const [queryString, queryParams] = cypherQuery(params, context, resolveInfo)

            // using neo4j-graphql driver injected in context to perform custom call
			const resultsCount = await context.driver
				.session()
				.run(queryString, queryParams)
				.then((res) => res.records.length) // getting count of the results

			const requiredFieldsMessage =
				'### Only `totalCount` field can be resolved with this query'

			return {
				nodeId: requiredFieldsMessage, // fields required in type definitions have to be resolved somehow
				title: requiredFieldsMessage, // fields required in type definitions have to be resolved somehow
				text: requiredFieldsMessage,// fields required in type definitions have to be resolved somehow
				totalCount: resultsCount, // <--- Here you get your results total count
			}
		},
}

After implementing above code you can query api with following graphql query:

query{
  Question(filter:{
    title_contains:"a" # your filters
  }){
    nodeId
    title
    text
  }
  QuestionCount(filter:{
    title_contains:"a" # <-- repeat your filters for count query
  }) {
      totalCount
    }
}

And you will get following result:

{
  "data": {
    "Question": [
      {
        "nodeId": "aeede919-4e01-4946-a13d-172702e4997a",
        "title": "Question containing 'a' letter 1",
        "text": "Question containing a letter 1"
      },
      {
        "nodeId": "5a17bd7c-74f9-4c64-ad7d-9f2675d31fe3",
        "title": "Question containing 'a' letter 2",
        "text": "Question containing 'a' letter 2"
      },
    ],
    "QuestionCount": {
      "totalCount": 2
    }
  }
}

I'm sure original neo4jgraphql() call to database also can return count() under the hood, but it is not so easy to get it out from there.

Any way, above solution works for me, hope it will help to you also.