diff --git a/CHANGELOG.md b/CHANGELOG.md
index ac9171a2e77..a703649e049 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -109,6 +109,9 @@
- The `InMemoryCache` version of the `cache.gc` method now supports additional options for removing non-essential (recomputable) result caching data.
[@benjamn](https://github.com/benjamn) in [#8421](https://github.com/apollographql/apollo-client/pull/8421)
+- Suppress noisy `Missing cache result fields...` warnings by default unless `setLogVerbosity("debug")` called.
+ [@benjamn](https://github.com/benjamn) in [#8489](https://github.com/apollographql/apollo-client/pull/8489)
+
### Documentation
TBD
diff --git a/config/processInvariants.ts b/config/processInvariants.ts
index 0a26a01e9ee..6227acd5840 100644
--- a/config/processInvariants.ts
+++ b/config/processInvariants.ts
@@ -90,7 +90,7 @@ function transform(code: string, file: string) {
if (node.callee.type === "MemberExpression" &&
isIdWithName(node.callee.object, "invariant") &&
- isIdWithName(node.callee.property, "log", "warn", "error")) {
+ isIdWithName(node.callee.property, "debug", "log", "warn", "error")) {
if (isDEVLogicalAnd(path.parent.node)) {
return;
}
diff --git a/package-lock.json b/package-lock.json
index 4e01e0cc72e..304f39655a7 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9075,18 +9075,11 @@
}
},
"ts-invariant": {
- "version": "0.8.2",
- "resolved": "https://registry.npmjs.org/ts-invariant/-/ts-invariant-0.8.2.tgz",
- "integrity": "sha512-VI1ZSMW8soizP5dU8DsMbj/TncHf7bIUqavuE7FTeYeQat454HHurJ8wbfCnVWcDOMkyiBUWOW2ytew3xUxlRw==",
+ "version": "0.9.0",
+ "resolved": "https://registry.npmjs.org/ts-invariant/-/ts-invariant-0.9.0.tgz",
+ "integrity": "sha512-+JqhKqywk+ue5JjAC6eTWe57mOIxYXypMUkBDStkAzvnlfkDJ1KGyeMuNRMwOt6GXzHSC1UT9JecowpZDmgXqA==",
"requires": {
"tslib": "^2.1.0"
- },
- "dependencies": {
- "tslib": {
- "version": "2.3.0",
- "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz",
- "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg=="
- }
}
},
"ts-jest": {
diff --git a/package.json b/package.json
index 2ce94e66e24..3a2498cb88b 100644
--- a/package.json
+++ b/package.json
@@ -81,7 +81,7 @@
"optimism": "^0.16.1",
"prop-types": "^15.7.2",
"symbol-observable": "^4.0.0",
- "ts-invariant": "^0.8.2",
+ "ts-invariant": "^0.9.0",
"tslib": "^2.1.0",
"zen-observable-ts": "^1.1.0"
},
diff --git a/src/core/QueryManager.ts b/src/core/QueryManager.ts
index 22221e5055f..a30d1028555 100644
--- a/src/core/QueryManager.ts
+++ b/src/core/QueryManager.ts
@@ -1349,7 +1349,7 @@ export class QueryManager {
isNonEmptyArray(diff.missing) &&
!equal(data, {}) &&
!returnPartialData) {
- invariant.warn(`Missing cache result fields: ${
+ invariant.debug(`Missing cache result fields: ${
diff.missing.map(m => m.path.join('.')).join(', ')
}`, diff.missing);
}
diff --git a/src/core/__tests__/QueryManager/index.ts b/src/core/__tests__/QueryManager/index.ts
index 8c30b7ced94..035e0b6acc7 100644
--- a/src/core/__tests__/QueryManager/index.ts
+++ b/src/core/__tests__/QueryManager/index.ts
@@ -1350,7 +1350,6 @@ describe('QueryManager', () => {
});
itAsync('supports cache-only fetchPolicy fetching only cached data', (resolve, reject) => {
- const spy = jest.spyOn(console, "warn").mockImplementation();
const primeQuery = gql`
query primeQuery {
luke: people_one(id: 1) {
@@ -1395,13 +1394,9 @@ describe('QueryManager', () => {
return handle.result().then(result => {
expect(result.data['luke'].name).toBe('Luke Skywalker');
expect(result.data).not.toHaveProperty('vader');
- expect(spy).toHaveBeenCalledTimes(1);
});
})
- .finally(() => {
- spy.mockRestore();
- })
- .then(resolve, reject)
+ .then(resolve, reject);
});
itAsync('runs a mutation', (resolve, reject) => {
@@ -5785,8 +5780,8 @@ describe('QueryManager', () => {
let verbosity: ReturnType;
let spy: any;
beforeEach(() => {
- verbosity = setVerbosity("warn");
- spy = jest.spyOn(console, "warn").mockImplementation();
+ verbosity = setVerbosity("debug");
+ spy = jest.spyOn(console, "debug").mockImplementation();
});
afterEach(() => {