Skip to content

Commit 659440c

Browse files
authored
Merge branch 'main' into jerel/use-lazy-query-poll-interval
2 parents 028377b + 5957d6f commit 659440c

10 files changed

Lines changed: 236 additions & 17 deletions

File tree

.github/workflows/api-extractor.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ jobs:
2121
with:
2222
node-version: ">=23.6.0"
2323

24-
- name: Install dependencies (with cache)
25-
uses: bahmutov/npm-install@20216767ca67f0f7b4d095dc5859c5700a6581cb # v1
24+
- run: npm ci
2625

2726
# Builds the library and runs the api extractor
2827
- name: Run Api-Extractor

.github/workflows/arethetypeswrong.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ jobs:
2323
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
2424
with:
2525
node-version: ">=23.6.0"
26-
- name: Install dependencies (with cache)
27-
uses: bahmutov/npm-install@20216767ca67f0f7b4d095dc5859c5700a6581cb # v1
26+
27+
- run: npm ci
2828

2929
- name: Run build
3030
run: npm run build

.github/workflows/cleanup-checks.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ jobs:
4949
with:
5050
node-version: ">=23.6.0"
5151

52-
- name: Install dependencies (with cache)
53-
uses: bahmutov/npm-install@20216767ca67f0f7b4d095dc5859c5700a6581cb # v1
52+
- run: npm ci
5453

5554
- name: Run Api-Extractor
5655
run: npm run extract-api

.github/workflows/compare-build-output.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ jobs:
2222
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
2323
with:
2424
node-version: ">=23.6.0"
25-
- name: Install dependencies (with cache)
26-
uses: bahmutov/npm-install@20216767ca67f0f7b4d095dc5859c5700a6581cb # v1
25+
26+
- run: npm ci
2727

2828
- name: Run comparison script
2929
id: attw

.github/workflows/docmodel.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ jobs:
2121
with:
2222
node-version: ">=23.6.0"
2323

24-
- name: Install dependencies (with cache)
25-
uses: bahmutov/npm-install@20216767ca67f0f7b4d095dc5859c5700a6581cb # v1
24+
- run: npm ci
2625

2726
- name: Generate documentation model
2827
run: npm run docmodel

.github/workflows/knip.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jobs:
1616
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
1717
with:
1818
node-version: "24.x"
19-
- name: Install dependencies (with cache)
20-
uses: bahmutov/npm-install@20216767ca67f0f7b4d095dc5859c5700a6581cb # v1
19+
- run: npm ci
2120
- name: Run knip
2221
run: npm run knip

.github/workflows/publish-pr-releases.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ jobs:
4242
with:
4343
file-filter: "scripts/codemods/ac3-to-ac4/**"
4444

45-
- name: Install dependencies with cache
46-
uses: bahmutov/npm-install@20216767ca67f0f7b4d095dc5859c5700a6581cb # v1
45+
- run: npm ci
4746

4847
- name: Build AC
4948
run: npm run build

.github/workflows/scheduled-test-canary.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
3434
with:
3535
node-version: ">=23.6.0"
36-
- uses: bahmutov/npm-install@20216767ca67f0f7b4d095dc5859c5700a6581cb # v1
36+
- run: npm ci
3737
- run: |
3838
npm install react@${MATRIX_TAG} react-dom@${MATRIX_TAG}
3939
env:

.github/workflows/size-limit.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ jobs:
2020
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
2121
with:
2222
node-version: ">=23.6.0"
23-
- name: Install dependencies (with cache)
24-
uses: bahmutov/npm-install@20216767ca67f0f7b4d095dc5859c5700a6581cb # v1
23+
- run: npm ci
2524
- name: Run size-limit
2625
uses: andresz1/size-limit-action@e7493a72a44b113341c0cf6186ab49c17c4b65c1 # v1
2726
with:
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
import {
2+
ApolloClient,
3+
CombinedGraphQLErrors,
4+
gql,
5+
InMemoryCache,
6+
NetworkStatus,
7+
} from "@apollo/client";
8+
import { MockLink } from "@apollo/client/testing";
9+
import { ObservableStream } from "@apollo/client/testing/internal";
10+
11+
test("maintains data with errorPolicy: none when refetch returns error with no data", async () => {
12+
const query = gql`
13+
query people {
14+
allPeople {
15+
people {
16+
name
17+
}
18+
}
19+
}
20+
`;
21+
22+
const data = { allPeople: { people: [{ name: "Luke Skywalker" }] } };
23+
24+
const client = new ApolloClient({
25+
cache: new InMemoryCache(),
26+
link: new MockLink([
27+
{
28+
request: { query },
29+
result: { data },
30+
delay: 20,
31+
},
32+
{
33+
request: { query },
34+
result: { errors: [{ message: "Oops" }] },
35+
delay: 20,
36+
},
37+
]),
38+
});
39+
40+
const observable = client.watchQuery({ query, errorPolicy: "none" });
41+
const stream = new ObservableStream(observable);
42+
43+
await expect(stream).toEmitTypedValue({
44+
data: undefined,
45+
dataState: "empty",
46+
loading: true,
47+
networkStatus: NetworkStatus.loading,
48+
partial: true,
49+
});
50+
51+
await expect(stream).toEmitTypedValue({
52+
data,
53+
dataState: "complete",
54+
loading: false,
55+
networkStatus: NetworkStatus.ready,
56+
partial: false,
57+
});
58+
59+
await expect(observable.refetch()).rejects.toStrictEqualTyped(
60+
new CombinedGraphQLErrors({ errors: [{ message: "Oops" }] })
61+
);
62+
63+
await expect(stream).toEmitTypedValue({
64+
data,
65+
dataState: "complete",
66+
loading: true,
67+
networkStatus: NetworkStatus.refetch,
68+
partial: false,
69+
});
70+
71+
await expect(stream).toEmitTypedValue({
72+
data,
73+
dataState: "complete",
74+
error: new CombinedGraphQLErrors({ errors: [{ message: "Oops" }] }),
75+
loading: false,
76+
networkStatus: NetworkStatus.error,
77+
partial: false,
78+
});
79+
80+
await expect(stream).not.toEmitAnything();
81+
});
82+
83+
test("returns data as undefined with errorPolicy: all when refetch returns error with no data", async () => {
84+
const query = gql`
85+
query people {
86+
allPeople {
87+
people {
88+
name
89+
}
90+
}
91+
}
92+
`;
93+
94+
const data = { allPeople: { people: [{ name: "Luke Skywalker" }] } };
95+
96+
const client = new ApolloClient({
97+
cache: new InMemoryCache(),
98+
link: new MockLink([
99+
{
100+
request: { query },
101+
result: { data },
102+
delay: 20,
103+
},
104+
{
105+
request: { query },
106+
result: { errors: [{ message: "Oops" }] },
107+
delay: 20,
108+
},
109+
]),
110+
});
111+
112+
const observable = client.watchQuery({ query, errorPolicy: "all" });
113+
const stream = new ObservableStream(observable);
114+
115+
await expect(stream).toEmitTypedValue({
116+
data: undefined,
117+
dataState: "empty",
118+
loading: true,
119+
networkStatus: NetworkStatus.loading,
120+
partial: true,
121+
});
122+
123+
await expect(stream).toEmitTypedValue({
124+
data,
125+
dataState: "complete",
126+
loading: false,
127+
networkStatus: NetworkStatus.ready,
128+
partial: false,
129+
});
130+
131+
await expect(observable.refetch()).resolves.toStrictEqualTyped({
132+
data: undefined,
133+
error: new CombinedGraphQLErrors({ errors: [{ message: "Oops" }] }),
134+
});
135+
136+
await expect(stream).toEmitTypedValue({
137+
data,
138+
dataState: "complete",
139+
loading: true,
140+
networkStatus: NetworkStatus.refetch,
141+
partial: false,
142+
});
143+
144+
await expect(stream).toEmitTypedValue({
145+
data: undefined,
146+
dataState: "empty",
147+
error: new CombinedGraphQLErrors({ errors: [{ message: "Oops" }] }),
148+
loading: false,
149+
networkStatus: NetworkStatus.error,
150+
partial: true,
151+
});
152+
153+
await expect(stream).not.toEmitAnything();
154+
});
155+
156+
test("returns data as undefined with errorPolicy: ignore when refetch returns error with no data", async () => {
157+
const query = gql`
158+
query people {
159+
allPeople {
160+
people {
161+
name
162+
}
163+
}
164+
}
165+
`;
166+
167+
const data = { allPeople: { people: [{ name: "Luke Skywalker" }] } };
168+
169+
const client = new ApolloClient({
170+
cache: new InMemoryCache(),
171+
link: new MockLink([
172+
{
173+
request: { query },
174+
result: { data },
175+
delay: 20,
176+
},
177+
{
178+
request: { query },
179+
result: { errors: [{ message: "Oops" }] },
180+
delay: 20,
181+
},
182+
]),
183+
});
184+
185+
const observable = client.watchQuery({ query, errorPolicy: "ignore" });
186+
const stream = new ObservableStream(observable);
187+
188+
await expect(stream).toEmitTypedValue({
189+
data: undefined,
190+
dataState: "empty",
191+
loading: true,
192+
networkStatus: NetworkStatus.loading,
193+
partial: true,
194+
});
195+
196+
await expect(stream).toEmitTypedValue({
197+
data,
198+
dataState: "complete",
199+
loading: false,
200+
networkStatus: NetworkStatus.ready,
201+
partial: false,
202+
});
203+
204+
await expect(observable.refetch()).resolves.toStrictEqualTyped({
205+
data: undefined,
206+
});
207+
208+
await expect(stream).toEmitTypedValue({
209+
data,
210+
dataState: "complete",
211+
loading: true,
212+
networkStatus: NetworkStatus.refetch,
213+
partial: false,
214+
});
215+
216+
await expect(stream).toEmitTypedValue({
217+
data: undefined,
218+
dataState: "empty",
219+
loading: false,
220+
networkStatus: NetworkStatus.ready,
221+
partial: true,
222+
});
223+
224+
await expect(stream).not.toEmitAnything();
225+
});

0 commit comments

Comments
 (0)