Skip to content

Commit

Permalink
Suppress Missing cache result fields... warnings unless `setLogVerb…
Browse files Browse the repository at this point in the history
…osity("debug")` configured (#8489)
  • Loading branch information
benjamn committed Jul 12, 2021
1 parent 3cfe83c commit e9cf7c1
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 21 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@
- The `InMemoryCache` version of the `cache.gc` method now supports additional options for removing non-essential (recomputable) result caching data. <br/>
[@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. <br/>
[@benjamn](https://github.com/benjamn) in [#8489](https://github.com/apollographql/apollo-client/pull/8489)

### Documentation
TBD

Expand Down
2 changes: 1 addition & 1 deletion config/processInvariants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
13 changes: 3 additions & 10 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion src/core/QueryManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,7 @@ export class QueryManager<TStore> {
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);
}
Expand Down
11 changes: 3 additions & 8 deletions src/core/__tests__/QueryManager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -5785,8 +5780,8 @@ describe('QueryManager', () => {
let verbosity: ReturnType<typeof setVerbosity>;
let spy: any;
beforeEach(() => {
verbosity = setVerbosity("warn");
spy = jest.spyOn(console, "warn").mockImplementation();
verbosity = setVerbosity("debug");
spy = jest.spyOn(console, "debug").mockImplementation();
});

afterEach(() => {
Expand Down

0 comments on commit e9cf7c1

Please sign in to comment.