# Sharing data between filtered queries

**URL:** <https://community.apollographql.com/t/sharing-data-between-filtered-queries/7925>\
**Category:** Client SDKs\
**Tags:** client, web\
**Created:** [November 2, 2024, 9:48am UTC](https://community.apollographql.com/t/sharing-data-between-filtered-queries/7925 "2024-11-02T09:48:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![misha-erm](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/misha-erm/32/5056_2.png) [@misha-erm](https://community.apollographql.com/u/misha-erm)\
**Post date:** [November 2, 2024, 9:48am UTC](https://community.apollographql.com/t/sharing-data-between-filtered-queries/7925/1 "2024-11-02T09:48:33Z")

</div>

Hello,

I have a query like this: `comments(type: All | Upvoted | Downvoted)` and I use `type` as a keyArg.

When user opens the page he fetches all the comments and later he can narrow his search. I wonder if it’s possible to somehow prepopulate store of `type: Upvoted |Downvoted` with the results from `type: All` query. Unfortunately `preloadQuery` doesn’t have `update` function as mutation do so not sure what’s the best way to achiive that.

I tried to use `read` field policy but that gives me `Already recomputing error`  
here is an example of what I tried:

```auto
comments: {
  keyArgs: ['type'],
  merge: mergePaginatedCollections,
  read(existing, { cache, args }) {
    const variables = args as CommentsQueryQueryVariables;
    if (!existing && variables.type !== VoteTypeFilter.All) {
      const d = cache.readQuery({
        query: CommentsQuery,
        variables,
      });

      return {
        ...d,
        comments: {
          ...d?.comments,
          items: d?.comments.items.filter(
            (c) => c.type === variables.type,
          ),
        },
      };
    }

    return existing;
  },
},

```

Thanks in advance for any tips 🙇‍♂️
