Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
email = artifactoryadmins@netflix.com
registry = https://artifacts.netflix.com/api/npm/npm-netflix

@dta:registry=http://npm.dta.netflix.com
15 changes: 0 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@

## Description

This is a simple Create React App demonstrating a bug (or potentially expected behavior) where unmounting a component that
has a "fetchPolicy" of "cache-and-network" and "nextFetchPolicy" of "cache-first" essentially resets the fetchPolicy state,
such that returning to the component utilizes the "fetchPolicy" rather than the "nextFetchPolicy", which means the query will
re-fire even though the data exists in cache.

The way I work around this is wrapping my useQuery utilization and keeping a global tracker of whether the query has been run
once. If it has, I force the fetchPolicy to be "cache-first", this feels like a hack and I wonder if this behavior is expected
or is a bug w/Apollo.

## Duplicating

```sh
npm install
npm run start
```

1. Click "Click me to unmount to another route"
2. Click "Click me to go back to home and see the query re-fire"
3. You'll see the "loading.." indicator, which indicates the query has re-fired.
173 changes: 146 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@apollo/client": "^3.2.5",
"@apollo/client": "^3.3.13",
"@testing-library/jest-dom": "^5.11.5",
"@testing-library/react": "^11.1.2",
"@testing-library/user-event": "^12.2.2",
Expand All @@ -12,6 +12,7 @@
"@types/react": "^16.9.56",
"@types/react-dom": "^16.9.9",
"apollo-server-express": "^2.19.0",
"apollo3-cache-persist": "^0.9.1",
"express": "^4.17.1",
"faker": "^5.1.0",
"gql": "^1.1.2",
Expand Down
Loading