DEV Community

Discussion on: Pagination with minimal effort in Relay

Collapse
 
sebastienh profile image
Sébastien Hamel • Edited

Really great article! Not so much information about Relay and this is quite a welcome addition.

I was wondering, I am starting a new project in Relay so I am quite new, but in your example you use a connection which is a field of a type (friends of User) to demonstrate the use of usePaginationFragment hook. Is there a way to use that same mecanic outside a type's field? I am basically looking at using an independant query for pagination: the same kind of query you defined in the previous article:

    type Query {
      searchMovies(
        query: String!
        first: Int, 
        last: Int, 
        after: String, 
        before: String
      ): MovieConnection
    }
Enter fullscreen mode Exit fullscreen mode

Does Relay offer anything to directly deal with these?

Thanks again! :)

Collapse
 
zth profile image
Gabriel Nordeborn • Edited

Hi! Sorry, completely missed this question 🙈 if I understand you correctly you're after whether it's possible to paginate on the top level? If so then yes, totally possible! The top level Query type is just another type, so you can make a fragment on Query, just like you would on User.

Collapse
 
sebastienh profile image
Sébastien Hamel

Thanks! Really appreciated!!!