UNPKG

1.09 kBMarkdownView Raw
1---
2title: apollo-link-dedup
3description: Deduplicate matching requests before making a request
4---
5
6*NOTE* This link is included by default when using apollo-client so you don't need to add it to your link chain if using apollo-client.
7
8## Installation
9
10`npm install apollo-link-dedup --save`
11
12## Usage
13```js
14import { DedupLink } from "apollo-link-dedup";
15
16const link = new DedupLink();
17```
18
19## Options
20The Dedup Link does not take any options when creating the link.
21
22## Context
23The Dedup Link can be overridden by using the context on a per operation basis:
24- `forceFetch`: a true or false (defaults to false) to bypass deduplication per request
25
26```js
27import { createHttpLink } from "apollo-link-http";
28import ApolloClient from "apollo-client";
29import InMemoryCache from "apollo-cache-inmemory";
30
31const client = new ApolloClient({
32 link: createHttpLink({ uri: "/graphql" }),
33 cache: new InMemoryCache()
34});
35
36// a query with apollo-client that will not be deduped
37client.query({
38 query: MY_QUERY,
39 context: {
40 forceFetch: true
41 }
42})
43```