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

Allow refetchQueries to refetch observerless queries (again) #9616

Closed
Closed
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 src/__tests__/refetchQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,8 @@ describe("client.refetchQueries", () => {
expect(diff.result).toEqual({ b: "B" });
} else if (obs === abObs) {
expect(diff.result).toEqual({ a: "A", b: "B" });
} else if (obs === extraObs) {
expect(diff.result).toEqual({ a: "A", b: "B" });
} else {
reject(`unexpected ObservableQuery ${
obs.queryId
Expand All @@ -475,6 +477,7 @@ describe("client.refetchQueries", () => {
expect(activeResults).toEqual([
{ a: "A" },
{ a: "A", b: "B" },
{ a: "A", b: "B" },
{ b: "B" },
]);

Expand Down
5 changes: 1 addition & 4 deletions src/core/QueryManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -765,10 +765,7 @@ export class QueryManager<TStore> {
options: { fetchPolicy },
} = oq;

if (
fetchPolicy === "standby" ||
(include === "active" && !oq.hasObservers())
) {
if (fetchPolicy === "standby") {
return;
}

Expand Down
8 changes: 5 additions & 3 deletions src/core/__tests__/QueryManager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3742,7 +3742,7 @@ describe('QueryManager', () => {
}, 50);
});

itAsync('should not call refetch on a non-subscribed Observable if the store is reset', (resolve, reject) => {
itAsync('should not call refetch on a standby Observable if the store is reset', (resolve, reject) => {
const query = gql`
query {
author {
Expand All @@ -3758,6 +3758,7 @@ describe('QueryManager', () => {

const options = {
query,
fetchPolicy: "standby",
} as WatchQueryOptions;

let refetchCount = 0;
Expand Down Expand Up @@ -4225,7 +4226,7 @@ describe('QueryManager', () => {
}, 50);
});

itAsync('should not call refetch on a non-subscribed Observable', (resolve, reject) => {
itAsync('should not call refetch on a standby Observable', (resolve, reject) => {
const query = gql`
query {
author {
Expand All @@ -4240,7 +4241,8 @@ describe('QueryManager', () => {
});

const options = {
query
query,
fetchPolicy: "standby",
} as WatchQueryOptions;

let refetchCount = 0;
Expand Down