# Multiple identical queries - only one is performed

**URL:** <https://community.apollographql.com/t/multiple-identical-queries-only-one-is-performed/5559>\
**Category:** Client SDKs\
**Tags:** client, web\
**Created:** [January 24, 2023, 9:39pm UTC](https://community.apollographql.com/t/multiple-identical-queries-only-one-is-performed/5559 "2023-01-24T21:39:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![disl0rn](https://avatars.discourse-cdn.com/v4/letter/d/f9ae1b/32.png) [@disl0rn](https://community.apollographql.com/u/disl0rn)\
**Post date:** [January 24, 2023, 9:39pm UTC](https://community.apollographql.com/t/multiple-identical-queries-only-one-is-performed/5559/1 "2023-01-24T21:39:12Z")

</div>

Hi,

I have a case where I need to make the same graphql query multiple times, with the same variables, but with a different authorization token for each request. I am setting the token in the context options of the actual query

```auto
 const response = await apolloClient.query({
      query: myQuery,
      fetchPolicy: 'no-cache',
      context: { headers: { authorization: getToken() }}),
    });

```

However only one of the query requests I generate is actually sent, the rest are fulfilled with the response data of the first request. I realize this must have something to do with the caching - I’ve tried setting `fetchPolicy` to `'no-cache'`, and the `resultCaching: false` in the `cache/InMemoryCache` options, but still getting the same behaviour.

Was hoping someone could point me in the right direction?

Thanks!

---

<div class="post-metadata">

**Author:** ![jerelmiller](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/jerelmiller/32/3314_2.png) [@jerelmiller](https://community.apollographql.com/u/jerelmiller)\
**Post date:** [January 24, 2023, 9:53pm UTC](https://community.apollographql.com/t/multiple-identical-queries-only-one-is-performed/5559/2 "2023-01-24T21:53:29Z")

</div>

Hey @disl0rn 👋 !

What you’re seeing is [query deduplication](https://www.apollographql.com/docs/react/api/core/ApolloClient/#querydeduplication) at work. Query deduplication is enabled by default and will only issue a single query if an existing query is in flight with the same query string, operation name, and variables. You can choose to disable this 1 of 2 ways:

1. Globally disable query deduplication in the `ApolloClient` constructor.

```plaintext
const client = new ApolloClient({
  queryDeduplication: false
})

```

1. Disable it on a per query basis. You can do this with `context.queryDeduplication` if you’d like to leave this behavior on by default, but turn it off for select queries.

```plaintext
const response = await client.query({
  context: { queryDeduplication: false }
});

```

As an FYI, we are considering [allowing headers to play a role in query deduplication](https://github.com/apollographql/apollo-client/pull/10273). We are still figuring out the mechanics of this, but this behavior might be more in line with what you’re expecting.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![disl0rn](https://avatars.discourse-cdn.com/v4/letter/d/f9ae1b/32.png) [@disl0rn](https://community.apollographql.com/u/disl0rn)\
**Post date:** [January 25, 2023, 8:36am UTC](https://community.apollographql.com/t/multiple-identical-queries-only-one-is-performed/5559/3 "2023-01-25T08:36:09Z")

</div>

Thanks @jerelmiller, that worked! ⭐
