Multiple connections in same fragment using usePaginationFragment

Viewed 143

Looking through the doc https://relay.dev/docs/guided-tour/list-data/advanced-pagination/ looks like it is possible to have multiple connections in the same component but in different fragments.

For my use case, I need to have multiple connections in the same fragment. Example what I have in mind:

fragment Component_viewer on Viewer
@refetchable(queryName: "ComponentRefetchQuery") {
    myConnection1 @connection(key: "Component_myConnection1") {
        totalResults
        ...ComponentThatHandlesConnection_myConnection1
    }
    myConnection2 @connection(key: "Component_myConnection2") {
        totalResults
        ...ComponentThatHandlesConnection_myConnection2
    }
}

The reason why I need this functionality is that I need the data of totalResults field above the connection component in the component tree. Is this possible to achieve with usePaginationFragment? Or maybe there is a better way to achieve this?

1 Answers

I've implemented it like so, we spread the first fragment on a query and then second fragment on the first fragment.

enter image description here

Related