Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress Missing cache result fields... warnings unless setLogVerbosity("debug") configured #8489

Merged
merged 3 commits into from
Jul 12, 2021
Merged
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
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")) {
brainkim marked this conversation as resolved.
Show resolved Hide resolved
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();
benjamn marked this conversation as resolved.
Show resolved Hide resolved
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