Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

Rescript Relay connecting mutation with refechable pagination

$
0
0
module Fragment = %relay(`
  fragment AlbumRelayContent_albums on Viewer
  @refetchable(queryName: "AlbumRelayPaginationQuery")
  @argumentDefinitions(
    cursor: { type: "String" },
    count: { type: "Int", defaultValue: 100 }
    filter: { type: "FilterAlbum" }
  )
  {
    ...AlbumRelayComposerFragment
    albums(first: $count, after: $cursor, filter: $filter)
      @connection(key: "AlbumRelayAlbumsSection_albums") 
    {
     __id // here is the connection ID
      edges {
        node {
          id
          state
          ...AlbumRelayFragment_album
        }
      }
      totalCount
      pageInfo {
        hasNextPage
        startCursor
      }
    }
  }
`)
let connectionId = albums_pag.albums.__id

Why don’t you directly get the connection ID from the fragment like this?

If I remember correctly, the connection ID changes when the parameters of the connection change (pagination, filters, etc), so it’s safer to get it this way. Try it, I’m pretty sure it would work this way.


Viewing all articles
Browse latest Browse all 2592

Trending Articles