apollo-link icon indicating copy to clipboard operation
apollo-link copied to clipboard

queryDeduplication

Open gilesbradshaw opened this issue 7 years ago • 4 comments

Doc says:

"Query deduplication can help reduce the number of queries that are sent over the wire. It is turned on by default, but can be turned off by passing queryDeduplication: false to the context on each requests or using the defaultOptions key on Apollo Client setup. If turned on, query deduplication happens before the query hits the network layer."

https://www.apollographql.com/docs/react/basics/network-layer.html#query-deduplication

however

new ApolloClient({
    defaultOptions: {
        queryDeduplication: false,
    }
})

has no effect

what one does is:

new ApolloClient({
    queryDeduplication: false,
})

moreover should not

import { graphql } from 'react-apollo'

  graphql(
    Query,
    {
      options: () => ({
        context: {
          // this (SHOULD) prevent the query being deduped
          // which means that requerying on reconnection works
          queryDeduplication: false,
        },
        fetchPolicy:'network-only',
      })
    }
  )

work for individual queries?

gilesbradshaw avatar Feb 23 '18 11:02 gilesbradshaw

Turning off query deduplication on composed GraphQL query does not work in my case as well. I am using react-apollo: 2.1.0.

raeesaa avatar Apr 02 '18 12:04 raeesaa

I'm having the same issue. I don't want to turn off queryDeduplication for all my requests but only for one. I tried passing queryDeduplication: false in the context instead of inside the client options but it doesn't work.

client:

export const client = new ApolloClient({
  link,
  cache,
  resolvers,
  typeDefs,
});

Query:

const response = await client.query({
    fetchPolicy: 'no-cache',
    context: { queryDeduplication: false },
    query: GET_SIGNED_UPLOAD_URL,
    variables: { ... },
});

cesar3030 avatar Nov 02 '19 16:11 cesar3030

I'm having the same issue.

igaloly avatar May 03 '20 11:05 igaloly

Hey, Pull request has been opened about this issue :)

igaloly avatar May 10 '20 06:05 igaloly