# Merge not working for relay-style pagination

**URL:** <https://community.apollographql.com/t/merge-not-working-for-relay-style-pagination/6810>\
**Category:** Client SDKs\
**Tags:** client\
**Created:** [October 6, 2023, 5:21am UTC](https://community.apollographql.com/t/merge-not-working-for-relay-style-pagination/6810 "2023-10-06T05:21:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![computesalesman](https://avatars.discourse-cdn.com/v4/letter/c/858c86/32.png) [@computesalesman](https://community.apollographql.com/u/computesalesman)\
**Post date:** [October 6, 2023, 5:21am UTC](https://community.apollographql.com/t/merge-not-working-for-relay-style-pagination/6810/1 "2023-10-06T05:21:07Z")

</div>

Hey guys, trying to get relay style pagination working for an infinite scroll feature. From the documentation, it sounds like I don’t need an updateQuery function in my fetchMore call, however if I don’t include it, no re-render happens.

This is my apollo client code:

```auto
const cache = new InMemoryCache({
  typePolicies: {
    Query: {
      fields: {
        home: relayStylePagination(),
      },
    },
  },
});

```

And my page.tsx:

```auto
query CustomQuery($cursor: Cursor) {
  home(first: 5, after: $cursor) {
    edges {
      node {
        id
      }
    }
    pageInfo: {
      hasNextPage
      endCursor
    }
  }
}

const updateQuery = (previousResult, { fetchMoreResult }) => {
    return fetchMoreResult.home.edges.length ? fetchMoreResult : previousResult;
}

return (
  <div>
    <Items data={data} />
    {pageInfo.hasNextPage && (
    <Button onClick={() => {
      if (pageInfo.hasNextPage) {
        fetchMore({
          variables: {
            cursor: pageInfo.endCursor,
          },
          updateQuery
        })
      }
    }}>{loading ? "Loading..." : "Load More"}</Button>
  )}
  </div>
)

```

Does this look right? Should it be automatically merging using that policy, or is there something more I need to do?

Appreciate the help, thanks

---

<div class="post-metadata">

**Author:** ![computesalesman](https://avatars.discourse-cdn.com/v4/letter/c/858c86/32.png) [@computesalesman](https://community.apollographql.com/u/computesalesman)\
**Post date:** [October 6, 2023, 6:33am UTC](https://community.apollographql.com/t/merge-not-working-for-relay-style-pagination/6810/2 "2023-10-06T06:33:17Z")

</div>

I think it might have something to do with the updated code for Next 13 (appDir)

---

<div class="post-metadata">

**Author:** ![computesalesman](https://avatars.discourse-cdn.com/v4/letter/c/858c86/32.png) [@computesalesman](https://community.apollographql.com/u/computesalesman)\
**Post date:** [October 6, 2023, 7:11am UTC](https://community.apollographql.com/t/merge-not-working-for-relay-style-pagination/6810/3 "2023-10-06T07:11:28Z")

</div>

Also `console.log( __APOLLO_DEVTOOLS_GLOBAL_HOOK__.ApolloClient)` is giving me `undefined`, and I can’t see the Apollo Devtools tab in the browser inspector

---

<div class="post-metadata">

**Author:** ![Justin\_Gonzalez](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/justin_gonzalez/32/5359_2.png) [@Justin\_Gonzalez](https://community.apollographql.com/u/Justin_Gonzalez)\
**Post date:** [February 6, 2025, 8:48pm UTC](https://community.apollographql.com/t/merge-not-working-for-relay-style-pagination/6810/4 "2025-02-06T20:48:11Z")

</div>


