# Weird behaviour after cache.modify

**URL:** <https://community.apollographql.com/t/weird-behaviour-after-cache-modify/6680>\
**Category:** Client SDKs\
**Tags:** client\
**Created:** [September 1, 2023, 6:50am UTC](https://community.apollographql.com/t/weird-behaviour-after-cache-modify/6680 "2023-09-01T06:50:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![reactjs\_team](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/reactjs_team/32/4559_2.png) [@reactjs\_team](https://community.apollographql.com/u/reactjs_team)\
**Post date:** [September 1, 2023, 6:50am UTC](https://community.apollographql.com/t/weird-behaviour-after-cache-modify/6680/1 "2023-09-01T06:50:28Z")

</div>

This problem happened on react.

This is my cache modify code, and i have a pagination of projects that is based on skip and limit. After cache modification the pagination query refetched from skip:0 or the initial variable values. I don’t to refetch the pagination from the begining it should just give me the all cached projects. That’s one problem. Another one is if i go into a single project page and added one asset which uses the same below code to modify the cache, and after that if i came to pagination page, it successfully fetches the initial variables with skip:0 limit:6, after that when i’m doing pagination it’s going on a loop graphql query call every fetchMore using skip:6 , limit:2 also calls skip:0 limit:6. Every fetchMore triggers two queries.

```auto
        const validate = cache?.modify({
          id: "Project:" + projectId,
          fields: {
            assets: (existingRefs) => {
              const newAssetRef = cache.writeFragment({
                data: data.createAsset,
                fragment: gql`
                  fragment NewAsset on Asset {
                    id
                    name
                  }
                `,
              });
              console.log(newAssetRef, "newAssetRef");
              return [...existingRefs, newAssetRef];
            },
          },
        });
        console.log(validate, "validate");

```

tried with broadcast:false, nothing worked.

anyone can help me?

---

<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/weird-behaviour-after-cache-modify/6680/2 "2025-02-06T20:48:23Z")

</div>


