Grapher limit and skip (pagination) does not work for the second iteration

Grapher limit and skip does not work for the second iteration. I have a query as follows

import Group from '/imports/api/groupMembers/collection.js';

export default Group.createQuery({
	$filter({filters, params}) {
		filters.groupId = params.groupId;
	},
	$paginate: true,
	userId: 1,
	groupId: 1,
});
	

I use this query client side as follows:

import query from '/imports/api/groupMembers/query/membersOfaGroup.js';
.
.
.
export default withQuery(
    props => {
		var limit = Session.get('limit');
		var skip = Session.get('skip');
		var page = Session.get('page');
		var groupId = localStorage.getItem("groupId");
    
		if (!limit)
		{
			limit = 2;
			Session.setDefault('limit', limit)
		}
		if (!skip)
		{
			skip = 0;
			Session.setDefault('skip', skip)
		}
		if (!page)
		{
			page = 0
			Session.setDefault('page', page)
		}
		
        return query.clone({
			groupId:groupId,
			limit:limit,
			skip:skip
		});
    },
    { 
		reactive: true, 
})(Members);

Where obviously Members is my class.

First time around limit = 2, skip = 0, I get back the first userId and groupId as expected
Second time around when I click next to go to the next page where limit is still 2 but skip is now 2, I still get the same userId and groupId as in the first page, as if limit is also limiting the records server side instead limiting what comes back to me but doing the skipping on the database where all records exist. So I was expecting the skipping to be done database side but limiting to be done client side when the extraction has happened. For example if there is 12 records and we are on page 2 going to page 3 we would skip 4 records extract the rest but only display 2 records, as we limit what we see to 2 records, something like that.
Why does it not work for me? What am I missing? Have you tried grapher pagination before. Did it work for you? Are you willing to maybe try it and tell me if it works for you and also tell me what you did differently? Please help. Thank you.
B.

You need to put it inside the options


options:
	sort:
	skip:
	limit:

Thank you so much for your reply.
Please change my code above to demonstrate exactly what you mean. I have done the following and it does not yield the result I want:

export default Group.createQuery({
	//$filter({filters, options, params}) {
	$filter({filters, options, params}) {
		filters.groupId = params.groupId;
                //The below does not work either!!!
		//options.sort = {userId: -1}
		//options.skip = params.skip
		//options.limit = params.limit
	},
        //This does not work.
	$options({params}) {
		sort = {userId: -1}
		skip = params.skip
		limit = params.limit
	},
	$paginate: true,
	userId: 1,
	groupId: 1,
});

Do you maybe mean to put inside options at this level.

        return query.clone({
			groupId:groupId,
			limit:limit,
			skip:skip
		});

If so, it is not in the documentation. Please change my code to demonstrate how you would do it.

Thanks.

For what I am using I do not need a bridge to Apollo graphql do I? I do not need to install cultofcoders:apollo?

I have installed the following to use grapher:

meteor add cultofcoders:grapher
meteor add cultofcoders:grapher-react

Do I need to install more than this to get my code working?

Adding cultofcoders:apollo does not work.

export default withQuery(
    props => {
		var limit = Session.get('limit');
		var skip = Session.get('skip');
		var page = Session.get('page');
		var groupId = localStorage.getItem("groupId");
               
               // Session is a global object. Try to work with local variables and pass them through your props. In this case, limit, skip and page
// should be in the local state of your view that needs to be paginated. You may
// initialize an object as { limit: 2, skip: 0, page: 0 } to have some defaults. Otherwise ... you need to write a lot of code and ifs or switches.
		if (!limit)
		{
			limit = 2;
			Session.setDefault('limit', limit)
		}
		if (!skip)
		{
			skip = 0;
			Session.setDefault('skip', skip)
		}
		if (!page)
		{
			page = 0
			Session.setDefault('page', page)
		}
		
        return query.clone({
			groupId:groupId,
			limit:limit,
			skip:skip
		}); // Just to make sure first that you get your data, try to make it non-reactive and do a fetch() here and console log it. Also try with hard coded limit, skip and page.
    },
    { 
		reactive: true, 
})(Members);

Thanks for your reply and good advise Paul. Do you have an advise about the issue I am battling with as per my first post above?

Here is a simple example. This should clear things up for you.

export query = Collection.createQuery('getQuery',
	$paginate: true
	$filter: ({ filters, options, params }) ->
		if params.filters then Object.assign(filters, params.filters)
		if params.options then Object.assign(options, params.options)
		return { filters, options, params }
	name:1
)
queryFilter =
	filters:
		name:
			$regex: "something"
			$options:"i"
	options:
		limit: 20
		skip: 20

query.clone(queryFilter)

Ok, I was saying that you could let go the entire tracker and client part and work it out on the server by fetching your data there (do fetch() for your query). In this way you take away one possible area of failure. Also try working with hard coded limit and sort numbers just to make sure you get them right. Then you can channels your limit and skip data from the client.
Whenever you use limit, you need to use sort as well for a field which you are sure it is being returned and whenever you search/query for a field you need to have a DB index created for that field in the sort option that you are planning to use.
E.g.

Groups._ensureIndex({ userId: 1, createdAt: -1 }) // where Groups is a Mongo Collection

Okay, I got it. I was supposed to use the $postOptions because when you clone the query some of the “options” that I passed are lost. I found the solution in this post. Had to do some reading and putting 2 and 2 together though. Here is the $postOptions:

	$postOptions: {
		sort:{userId: 1},
		limit:limit,
		skip:skip

As per the same query I must move away from using global query and use named query instead. So I must figure out how to write a named query equivalent of the same query.

Thanks for your help guys.