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

Revert "Avoid network after incomplete optimistic cache results. (#6419)" #6493

Merged
merged 1 commit into from
Jun 25, 2020
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
1 change: 0 additions & 1 deletion src/cache/core/types/DataProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ export namespace DataProxy {
result?: T;
complete?: boolean;
missing?: MissingFieldError[];
optimistic?: boolean;
}
}

Expand Down
9 changes: 1 addition & 8 deletions src/cache/inmemory/__tests__/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,6 @@ describe("InMemoryCache#broadcastWatches", function () {
},
},
complete: true,
optimistic: false,
}];

expect(receivedCallbackResults).toEqual([
Expand All @@ -1482,7 +1481,6 @@ describe("InMemoryCache#broadcastWatches", function () {
},
},
complete: true,
optimistic: false,
}];

expect(receivedCallbackResults).toEqual([
Expand All @@ -1504,7 +1502,6 @@ describe("InMemoryCache#broadcastWatches", function () {
},
},
complete: true,
optimistic: false,
}];

const received4 = [id4, 1, {
Expand All @@ -1514,7 +1511,6 @@ describe("InMemoryCache#broadcastWatches", function () {
},
},
complete: true,
optimistic: false,
}];

expect(receivedCallbackResults).toEqual([
Expand All @@ -1535,7 +1531,6 @@ describe("InMemoryCache#broadcastWatches", function () {
},
},
complete: true,
optimistic: false,
}];

expect(receivedCallbackResults).toEqual([
Expand Down Expand Up @@ -2113,12 +2108,10 @@ describe("InMemoryCache#modify", () => {
function makeResult(
__typename: string,
value: number,
complete = true,
optimistic = false,
complete: boolean = true,
) {
return {
complete,
optimistic,
result: {
[__typename.toLowerCase()]: {
__typename,
Expand Down
5 changes: 0 additions & 5 deletions src/cache/inmemory/__tests__/entityStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,6 @@ describe('EntityStore', () => {
},
})).toEqual({
complete: false,
optimistic: false,
result: {
authorOfBook: tedWithoutHobby,
},
Expand Down Expand Up @@ -1687,7 +1686,6 @@ describe('EntityStore', () => {
})).toEqual({
complete: false,
missing,
optimistic: true,
result: {
book: {
__typename: "Book",
Expand Down Expand Up @@ -1719,7 +1717,6 @@ describe('EntityStore', () => {
})).toEqual({
complete: false,
missing,
optimistic: false,
result: {
book: {
__typename: "Book",
Expand All @@ -1736,7 +1733,6 @@ describe('EntityStore', () => {
returnPartialData: true,
})).toEqual({
complete: true,
optimistic: false,
result: {
book: {
__typename: "Book",
Expand Down Expand Up @@ -1937,7 +1933,6 @@ describe('EntityStore', () => {

expect(cuckoosCallingDiffResult).toEqual({
complete: false,
optimistic: false,
result: {
book: {
__typename: "Book",
Expand Down
4 changes: 0 additions & 4 deletions src/cache/inmemory/__tests__/policies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,6 @@ describe("type policies", function () {
}],
},
complete: false,
optimistic: false,
missing: [
makeMissingError(1),
makeMissingError(2),
Expand Down Expand Up @@ -1108,7 +1107,6 @@ describe("type policies", function () {
}],
},
complete: false,
optimistic: false,
missing: [
makeMissingError(1),
makeMissingError(3),
Expand Down Expand Up @@ -1166,7 +1164,6 @@ describe("type policies", function () {
}],
},
complete: false,
optimistic: false,
missing: [
makeMissingError(1),
makeMissingError(3),
Expand Down Expand Up @@ -1201,7 +1198,6 @@ describe("type policies", function () {
}],
},
complete: true,
optimistic: false,
});

expect(cache.readQuery({ query })).toEqual({
Expand Down
12 changes: 0 additions & 12 deletions src/cache/inmemory/__tests__/readFromStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,6 @@ describe('reading from the store', () => {

expect(diffChickens()).toEqual({
complete: true,
optimistic: false,
result: {
chickens: [
{ __typename: "Chicken", id: 1, inCoop: true },
Expand All @@ -1052,7 +1051,6 @@ describe('reading from the store', () => {

expect(diffChickens()).toEqual({
complete: false,
optimistic: false,
missing: [
expect.anything(),
expect.anything(),
Expand All @@ -1075,7 +1073,6 @@ describe('reading from the store', () => {

expect(diffDucks()).toEqual({
complete: true,
optimistic: false,
result: {
ducks: [
{ __typename: "Duck", id: 1, quacking: true },
Expand All @@ -1097,7 +1094,6 @@ describe('reading from the store', () => {
// diff, and without altering the positions of later elements.
expect(diffDucks()).toEqual({
complete: true,
optimistic: false,
result: {
ducks: [
{ __typename: "Duck", id: 1, quacking: true },
Expand All @@ -1116,7 +1112,6 @@ describe('reading from the store', () => {

expect(diffOxen()).toEqual({
complete: true,
optimistic: false,
result: {
oxen: [
{ __typename: "Ox", id: 1, gee: true, haw: false },
Expand All @@ -1134,7 +1129,6 @@ describe('reading from the store', () => {

expect(diffOxen()).toEqual({
complete: true,
optimistic: false,
result: {
oxen: [
{ __typename: "Ox", id: 2, gee: false, haw: true },
Expand Down Expand Up @@ -1244,7 +1238,6 @@ describe('reading from the store', () => {
},
},
complete: true,
optimistic: false,
};

// We already have one diff because of the immediate:true above.
Expand All @@ -1268,7 +1261,6 @@ describe('reading from the store', () => {
},
},
complete: true,
optimistic: false,
};

expect(diffs).toEqual([
Expand Down Expand Up @@ -1296,7 +1288,6 @@ describe('reading from the store', () => {
},
},
complete: true,
optimistic: false,
};

expect(diffs).toEqual([
Expand Down Expand Up @@ -1338,7 +1329,6 @@ describe('reading from the store', () => {

const diffWithChildrenOfZeus = {
complete: true,
optimistic: false,
result: {
...diffWithoutDevouredSons.result,
ruler: {
Expand Down Expand Up @@ -1375,7 +1365,6 @@ describe('reading from the store', () => {

const diffWithZeusAsRuler = {
complete: true,
optimistic: false,
result: {
ruler: {
__typename: "Deity",
Expand Down Expand Up @@ -1554,7 +1543,6 @@ describe('reading from the store', () => {

const diffWithApolloAsRuler = {
complete: true,
optimistic: false,
result: apolloRulerResult,
};

Expand Down
3 changes: 1 addition & 2 deletions src/cache/inmemory/readFromStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
NormalizedCache,
ReadMergeModifyContext,
} from './types';
import { supportsResultCaching, EntityStore } from './entityStore';
import { supportsResultCaching } from './entityStore';
import { getTypenameFromStoreObject } from './helpers';
import { Policies } from './policies';
import { InMemoryCache } from './inMemoryCache';
Expand Down Expand Up @@ -154,7 +154,6 @@ export class StoreReader {
result: execResult.result,
missing: execResult.missing,
complete: !hasMissingFields,
optimistic: !(store instanceof EntityStore.Root),
};
}

Expand Down
6 changes: 0 additions & 6 deletions src/core/QueryManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1011,12 +1011,6 @@ export class QueryManager<TStore> {
];
}

if (diff.optimistic) {
return returnPartialData ? [
resultsFromCache(diff, queryInfo.markReady()),
] : [];
}

if (returnPartialData) {
return [
resultsFromCache(diff),
Expand Down
2 changes: 1 addition & 1 deletion src/core/__tests__/fetchPolicies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ describe('no-cache', () => {
});

describe('cache-first', () => {
itAsync('does not trigger network request during optimistic update', (resolve, reject) => {
itAsync.skip('does not trigger network request during optimistic update', (resolve, reject) => {
const results: any[] = [];
const client = new ApolloClient({
link: new ApolloLink((operation, forward) => {
Expand Down