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

Add a dataState enum to ApolloQueryResult #12350

Open
wants to merge 35 commits into
base: release-4.0
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1b53b61
Make ApolloQueryResult a union with a `dataStatus` enum.
jerelmiller Feb 6, 2025
cc414e9
Add dataState to result returned from fetchQueryByPolicy
jerelmiller Feb 6, 2025
3a9a40f
Mark dataState from result in link
jerelmiller Feb 6, 2025
8514df9
Remove union for now
jerelmiller Feb 6, 2025
f750adc
Remove anys
jerelmiller Feb 6, 2025
7108f7e
Set dataState in getCurrentResult
jerelmiller Feb 6, 2025
0e6d661
Update all ObservableQuery tests to check for dataState
jerelmiller Feb 6, 2025
5e5b00f
Fix bugs related to incorrect behavior found in updated tests
jerelmiller Feb 6, 2025
cbed014
Update ApolloClient/general tests to check for dataState
jerelmiller Feb 6, 2025
13d4428
Fix dataState with cache-only and partial data
jerelmiller Feb 6, 2025
e1fad85
Check for dataState in multiple-results tests
jerelmiller Feb 6, 2025
15d9bd2
Check for dataState in fetchMore tests
jerelmiller Feb 6, 2025
653975f
Update client tests to check for dataState
jerelmiller Feb 6, 2025
0fba6a3
Update refetchQueries tests to check for dataState
jerelmiller Feb 6, 2025
4b9b041
Update local-state tests to check for dataState
jerelmiller Feb 6, 2025
86effde
Update subscribeToMore tests to check for dataState
jerelmiller Feb 6, 2025
d02ac92
Update updated APIs in a data masking test
jerelmiller Feb 6, 2025
f02c996
Update fetchPolicies tests to check for dataState
jerelmiller Feb 6, 2025
5f621ff
Update cache tests to check for dataState
jerelmiller Feb 6, 2025
bd702d2
Don't set dataState in useQuery
jerelmiller Feb 6, 2025
185cc25
Update react tests to check for dataState
jerelmiller Feb 6, 2025
dfa5cc4
Update type of ApolloQueryResult back to union
jerelmiller Feb 6, 2025
9a5c843
Update fetchMore tests to assert on dataState
jerelmiller Feb 6, 2025
c730b6e
Update ApolloClient type tests to check dataState and data
jerelmiller Feb 6, 2025
f2332a6
Use invariant to check for dataState in dataMasking tests
jerelmiller Feb 6, 2025
aee1f0c
Switch to toEmitValue
jerelmiller Feb 6, 2025
c6367a7
Check for dataState in mutationResults
jerelmiller Feb 6, 2025
c3be1f1
Update type tests in useBackgroundQuery to check for data state
jerelmiller Feb 6, 2025
96ffc78
Use some necessary type casts
jerelmiller Feb 6, 2025
c88bd79
Update type tests for useLazyQuery
jerelmiller Feb 6, 2025
dc20ddc
Update type tests for useSuspenseQuery
jerelmiller Feb 6, 2025
8df4a86
Add some necessary type casts
jerelmiller Feb 6, 2025
7117e81
Minor type manipulation
jerelmiller Feb 6, 2025
57b1b3b
Update behavior in data masking test
jerelmiller Feb 6, 2025
e05d975
Add changeset
jerelmiller Feb 6, 2025
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
Prev Previous commit
Next Next commit
Update fetchPolicies tests to check for dataState
  • Loading branch information
jerelmiller committed Feb 7, 2025
commit f02c996200cb8d516967623ebc3f4da0b8fd34b7
34 changes: 34 additions & 0 deletions src/core/__tests__/fetchPolicies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ describe("no-cache", () => {

await expect(stream).toEmitApolloQueryResult({
data: dataWithId(1),
dataState: "complete",
loading: false,
networkStatus: NetworkStatus.ready,
partial: false,
Expand All @@ -430,13 +431,15 @@ describe("no-cache", () => {

await expect(stream).toEmitApolloQueryResult({
data: undefined,
dataState: "none",
loading: true,
networkStatus: NetworkStatus.setVariables,
partial: true,
});

await expect(stream).toEmitApolloQueryResult({
data: dataWithId(2),
dataState: "complete",
loading: false,
networkStatus: NetworkStatus.ready,
partial: false,
Expand All @@ -447,6 +450,7 @@ describe("no-cache", () => {

await expect(stream).toEmitApolloQueryResult({
data: dataWithId(2),
dataState: "complete",
loading: true,
networkStatus: NetworkStatus.refetch,
partial: false,
Expand All @@ -455,6 +459,7 @@ describe("no-cache", () => {

await expect(stream).toEmitApolloQueryResult({
data: dataWithId(2),
dataState: "complete",
loading: false,
networkStatus: NetworkStatus.ready,
partial: false,
Expand All @@ -465,6 +470,7 @@ describe("no-cache", () => {

await expect(stream).toEmitApolloQueryResult({
data: undefined,
dataState: "none",
loading: true,
networkStatus: NetworkStatus.setVariables,
partial: true,
Expand All @@ -473,6 +479,7 @@ describe("no-cache", () => {

await expect(stream).toEmitApolloQueryResult({
data: dataWithId(3),
dataState: "complete",
loading: false,
networkStatus: NetworkStatus.ready,
partial: false,
Expand Down Expand Up @@ -509,6 +516,7 @@ describe("cache-first", () => {

await expect(stream).toEmitApolloQueryResult({
data: undefined,
dataState: "none",
loading: true,
networkStatus: NetworkStatus.loading,
partial: true,
Expand All @@ -524,6 +532,7 @@ describe("cache-first", () => {
lastName: "Smith",
},
},
dataState: "complete",
loading: false,
networkStatus: NetworkStatus.ready,
partial: false,
Expand All @@ -550,6 +559,7 @@ describe("cache-first", () => {
__typename: "Bogus",
},
},
dataState: "partial",
loading: false,
networkStatus: NetworkStatus.ready,
partial: true,
Expand All @@ -570,6 +580,7 @@ describe("cache-first", () => {
lastName: "Smith",
},
},
dataState: "complete",
loading: false,
networkStatus: NetworkStatus.ready,
partial: false,
Expand Down Expand Up @@ -600,6 +611,7 @@ describe("cache-first", () => {
lastName: "Achebe",
},
},
dataState: "complete",
loading: false,
networkStatus: NetworkStatus.ready,
partial: false,
Expand Down Expand Up @@ -648,6 +660,7 @@ describe("cache-only", () => {
data: {
count: 1,
},
dataState: "complete",
partial: false,
});
expect(observable.options.fetchPolicy).toBe("cache-only");
Expand All @@ -660,6 +673,7 @@ describe("cache-only", () => {
data: {
count: 2,
},
dataState: "complete",
partial: false,
});

Expand Down Expand Up @@ -715,6 +729,7 @@ describe("cache-and-network", function () {

await expect(stream).toEmitApolloQueryResult({
data: dataWithId(1),
dataState: "complete",
loading: false,
networkStatus: NetworkStatus.ready,
partial: false,
Expand All @@ -724,13 +739,15 @@ describe("cache-and-network", function () {

await expect(stream).toEmitApolloQueryResult({
data: undefined,
dataState: "none",
loading: true,
networkStatus: NetworkStatus.setVariables,
partial: true,
});

await expect(stream).toEmitApolloQueryResult({
data: dataWithId(2),
dataState: "complete",
loading: false,
networkStatus: NetworkStatus.ready,
partial: false,
Expand All @@ -740,13 +757,15 @@ describe("cache-and-network", function () {

await expect(stream).toEmitApolloQueryResult({
data: dataWithId(2),
dataState: "complete",
loading: true,
networkStatus: NetworkStatus.refetch,
partial: false,
});

await expect(stream).toEmitApolloQueryResult({
data: dataWithId(2),
dataState: "complete",
loading: false,
networkStatus: NetworkStatus.ready,
partial: false,
Expand All @@ -756,13 +775,15 @@ describe("cache-and-network", function () {

await expect(stream).toEmitApolloQueryResult({
data: undefined,
dataState: "none",
loading: true,
networkStatus: NetworkStatus.setVariables,
partial: true,
});

await expect(stream).toEmitApolloQueryResult({
data: dataWithId(3),
dataState: "complete",
loading: false,
networkStatus: NetworkStatus.ready,
partial: false,
Expand Down Expand Up @@ -904,6 +925,7 @@ describe("nextFetchPolicy", () => {
},
},
},
dataState: "complete",
loading: false,
networkStatus: NetworkStatus.ready,
partial: false,
Expand All @@ -921,6 +943,7 @@ describe("nextFetchPolicy", () => {
},
},
},
dataState: "complete",
loading: false,
networkStatus: NetworkStatus.ready,
partial: false,
Expand All @@ -946,6 +969,7 @@ describe("nextFetchPolicy", () => {
},
},
},
dataState: "complete",
loading: false,
networkStatus: NetworkStatus.ready,
partial: false,
Expand All @@ -966,6 +990,7 @@ describe("nextFetchPolicy", () => {
},
},
},
dataState: "complete",
loading: false,
networkStatus: NetworkStatus.ready,
partial: false,
Expand Down Expand Up @@ -1053,6 +1078,7 @@ describe("nextFetchPolicy", () => {
},
},
},
dataState: "complete",
loading: false,
networkStatus: NetworkStatus.ready,
partial: false,
Expand All @@ -1070,6 +1096,7 @@ describe("nextFetchPolicy", () => {
},
},
},
dataState: "complete",
loading: false,
networkStatus: NetworkStatus.ready,
partial: false,
Expand All @@ -1096,6 +1123,7 @@ describe("nextFetchPolicy", () => {
},
},
},
dataState: "complete",
loading: false,
networkStatus: NetworkStatus.ready,
partial: false,
Expand All @@ -1113,6 +1141,7 @@ describe("nextFetchPolicy", () => {
},
},
},
dataState: "complete",
loading: true,
networkStatus: NetworkStatus.setVariables,
partial: false,
Expand All @@ -1131,6 +1160,7 @@ describe("nextFetchPolicy", () => {
},
},
},
dataState: "complete",
loading: false,
networkStatus: NetworkStatus.ready,
partial: false,
Expand Down Expand Up @@ -1225,6 +1255,7 @@ describe("nextFetchPolicy", () => {
},
},
},
dataState: "complete",
loading: false,
networkStatus: NetworkStatus.ready,
partial: false,
Expand All @@ -1242,6 +1273,7 @@ describe("nextFetchPolicy", () => {
},
},
},
dataState: "complete",
loading: false,
networkStatus: NetworkStatus.ready,
partial: false,
Expand All @@ -1266,6 +1298,7 @@ describe("nextFetchPolicy", () => {
},
},
},
dataState: "complete",
loading: false,
networkStatus: NetworkStatus.ready,
partial: false,
Expand All @@ -1289,6 +1322,7 @@ describe("nextFetchPolicy", () => {
},
},
},
dataState: "complete",
loading: false,
networkStatus: NetworkStatus.ready,
partial: false,
Expand Down