0
votes

I want to implement simple pagination with skip and limit parameters

In documentation ( https://graphql.org/learn/pagination/ ) I see:

We could do something like friends(first:2 after:$friendId), to ask for the next two after the last friend we fetched.

But if I pass first parameter in my query I get error:

"message": "Unknown argument \"first\" on field \"documents\" of type \"Query\".",

My query typeDef:

  extend type Query {
   documents(search: String, paragraphSize: Int, filters: DocumentFilters, sort: DocumentSort): [Document]

Question: should I add parameters first in my documents endpoint and handle all limits/skips/etc by myself on server side or I missed something and GraphQL handles by itself all limits etc?

1

1 Answers

0
votes

From your typeDef there is no parameter stating first or skip. it is not a parameter that exists already, it has to be defined

So something like this

documents(search: String, paragraphSize: Int, filters: DocumentFilters, sort: DocumentSort, skip: Int, limit: Int): [Document]

You could make another input to hold all these values if you wish