Skip to content

Commit 2436f3b

Browse files
authored
enhance: Support endpoint.update in existing useFetcher (#853)
1 parent a552977 commit 2436f3b

10 files changed

+262
-6
lines changed

packages/core/src/react-integration/__tests__/__snapshots__/hooks-endpoint.web.tsx.snap

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
exports[`useFetcher should dispatch an action that fetches a create 1`] = `
44
Object {
55
"meta": Object {
6+
"args": Array [
7+
Object {},
8+
Object {
9+
"content": "hi",
10+
},
11+
],
612
"createdAt": 1970-01-01T00:00:00.000Z,
713
"key": "POST http://test.com/article-cooler/",
814
"options": Object {
@@ -28,6 +34,14 @@ Object {
2834
exports[`useFetcher should dispatch an action that fetches a full update 1`] = `
2935
Object {
3036
"meta": Object {
37+
"args": Array [
38+
Object {
39+
"id": 1,
40+
},
41+
Object {
42+
"content": "changed",
43+
},
44+
],
3145
"createdAt": 1970-01-01T00:00:00.000Z,
3246
"key": "PUT http://test.com/article-cooler/1",
3347
"options": Object {
@@ -53,6 +67,14 @@ Object {
5367
exports[`useFetcher should dispatch an action that fetches a partial update 1`] = `
5468
Object {
5569
"meta": Object {
70+
"args": Array [
71+
Object {
72+
"id": 1,
73+
},
74+
Object {
75+
"content": "changed",
76+
},
77+
],
5678
"createdAt": 1970-01-01T00:00:00.000Z,
5779
"key": "PATCH http://test.com/article-cooler/1",
5880
"optimisticResponse": Object {
@@ -83,6 +105,12 @@ Object {
83105
exports[`useFetcher should dispatch an action with multiple updaters in the meta if update shapes params are passed in 1`] = `
84106
Object {
85107
"meta": Object {
108+
"args": Array [
109+
Object {},
110+
Object {
111+
"content": "hi",
112+
},
113+
],
86114
"createdAt": 1970-01-01T00:00:00.000Z,
87115
"key": "POST http://test.com/article/",
88116
"optimisticResponse": Object {
@@ -116,6 +144,12 @@ Object {
116144
exports[`useFetcher should dispatch an action with updater in the meta if update shapes params are passed in 1`] = `
117145
Object {
118146
"meta": Object {
147+
"args": Array [
148+
Object {},
149+
Object {
150+
"content": "hi",
151+
},
152+
],
119153
"createdAt": 1970-01-01T00:00:00.000Z,
120154
"key": "POST http://test.com/article-cooler/",
121155
"options": Object {
@@ -144,6 +178,12 @@ Object {
144178
exports[`useFetcher should refresh get details 1`] = `
145179
Object {
146180
"meta": Object {
181+
"args": Array [
182+
Object {
183+
"id": 1,
184+
},
185+
undefined,
186+
],
147187
"createdAt": 1970-01-01T00:00:00.000Z,
148188
"key": "GET http://test.com/article-cooler/1",
149189
"options": Object {
@@ -169,6 +209,19 @@ Object {
169209
exports[`useRetrieve should dispatch singles 1`] = `
170210
Object {
171211
"meta": Object {
212+
"args": Array [
213+
Object {
214+
"content": "whatever",
215+
"id": 5,
216+
"tags": Array [
217+
"a",
218+
"best",
219+
"react",
220+
],
221+
"title": "hi ho",
222+
},
223+
undefined,
224+
],
172225
"createdAt": 1970-01-01T00:00:00.000Z,
173226
"key": "GET http://test.com/article-cooler/5",
174227
"options": Object {
@@ -194,6 +247,19 @@ Object {
194247
exports[`useRetrieve should dispatch with fetch shape defined dataExpiryLength 1`] = `
195248
Object {
196249
"meta": Object {
250+
"args": Array [
251+
Object {
252+
"content": "whatever",
253+
"id": 5,
254+
"tags": Array [
255+
"a",
256+
"best",
257+
"react",
258+
],
259+
"title": "hi ho",
260+
},
261+
undefined,
262+
],
197263
"createdAt": 1970-01-01T00:00:00.000Z,
198264
"key": "GET http://test.com/article-static/5",
199265
"options": Object {
@@ -220,6 +286,19 @@ Object {
220286
exports[`useRetrieve should dispatch with fetch shape defined errorExpiryLength 1`] = `
221287
Object {
222288
"meta": Object {
289+
"args": Array [
290+
Object {
291+
"content": "whatever",
292+
"id": 5,
293+
"tags": Array [
294+
"a",
295+
"best",
296+
"react",
297+
],
298+
"title": "hi ho",
299+
},
300+
undefined,
301+
],
223302
"createdAt": 1970-01-01T00:00:00.000Z,
224303
"key": "GET http://test.com/article-static/5",
225304
"options": Object {
@@ -246,6 +325,19 @@ Object {
246325
exports[`useRetrieve should dispatch with resource defined dataExpiryLength 1`] = `
247326
Object {
248327
"meta": Object {
328+
"args": Array [
329+
Object {
330+
"content": "whatever",
331+
"id": 5,
332+
"tags": Array [
333+
"a",
334+
"best",
335+
"react",
336+
],
337+
"title": "hi ho",
338+
},
339+
undefined,
340+
],
249341
"createdAt": 1970-01-01T00:00:00.000Z,
250342
"key": "GET http://test.com/article-static/5",
251343
"options": Object {

packages/core/src/react-integration/__tests__/__snapshots__/hooks.web.tsx.snap

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
exports[`useFetcher should dispatch an action that fetches a create 1`] = `
44
Object {
55
"meta": Object {
6+
"args": Array [
7+
Object {},
8+
Object {
9+
"content": "hi",
10+
},
11+
],
612
"createdAt": 1970-01-01T00:00:00.000Z,
713
"key": "POST http://test.com/article-cooler/",
814
"options": Object {
@@ -28,6 +34,14 @@ Object {
2834
exports[`useFetcher should dispatch an action that fetches a full update 1`] = `
2935
Object {
3036
"meta": Object {
37+
"args": Array [
38+
Object {
39+
"id": 1,
40+
},
41+
Object {
42+
"content": "changed",
43+
},
44+
],
3145
"createdAt": 1970-01-01T00:00:00.000Z,
3246
"key": "PUT http://test.com/article-cooler/1",
3347
"options": Object {
@@ -53,6 +67,14 @@ Object {
5367
exports[`useFetcher should dispatch an action that fetches a partial update 1`] = `
5468
Object {
5569
"meta": Object {
70+
"args": Array [
71+
Object {
72+
"id": 1,
73+
},
74+
Object {
75+
"content": "changed",
76+
},
77+
],
5678
"createdAt": 1970-01-01T00:00:00.000Z,
5779
"key": "PATCH http://test.com/article-cooler/1",
5880
"optimisticResponse": Object {
@@ -77,6 +99,12 @@ Object {
7799
exports[`useFetcher should dispatch an action with multiple updaters in the meta if update shapes params are passed in 1`] = `
78100
Object {
79101
"meta": Object {
102+
"args": Array [
103+
Object {},
104+
Object {
105+
"content": "hi",
106+
},
107+
],
80108
"createdAt": 1970-01-01T00:00:00.000Z,
81109
"key": "POST http://test.com/article/",
82110
"optimisticResponse": Object {
@@ -104,6 +132,12 @@ Object {
104132
exports[`useFetcher should dispatch an action with updater in the meta if update shapes params are passed in 1`] = `
105133
Object {
106134
"meta": Object {
135+
"args": Array [
136+
Object {},
137+
Object {
138+
"content": "hi",
139+
},
140+
],
107141
"createdAt": 1970-01-01T00:00:00.000Z,
108142
"key": "POST http://test.com/article-cooler/",
109143
"options": Object {
@@ -132,6 +166,12 @@ Object {
132166
exports[`useFetcher should refresh get details 1`] = `
133167
Object {
134168
"meta": Object {
169+
"args": Array [
170+
Object {
171+
"id": 1,
172+
},
173+
undefined,
174+
],
135175
"createdAt": 1970-01-01T00:00:00.000Z,
136176
"key": "GET http://test.com/article-cooler/1",
137177
"options": Object {
@@ -157,6 +197,19 @@ Object {
157197
exports[`useRetrieve should dispatch singles 1`] = `
158198
Object {
159199
"meta": Object {
200+
"args": Array [
201+
Object {
202+
"content": "whatever",
203+
"id": 5,
204+
"tags": Array [
205+
"a",
206+
"best",
207+
"react",
208+
],
209+
"title": "hi ho",
210+
},
211+
undefined,
212+
],
160213
"createdAt": 1970-01-01T00:00:00.000Z,
161214
"key": "GET http://test.com/article-cooler/5",
162215
"options": Object {
@@ -182,6 +235,19 @@ Object {
182235
exports[`useRetrieve should dispatch with fetch shape defined dataExpiryLength 1`] = `
183236
Object {
184237
"meta": Object {
238+
"args": Array [
239+
Object {
240+
"content": "whatever",
241+
"id": 5,
242+
"tags": Array [
243+
"a",
244+
"best",
245+
"react",
246+
],
247+
"title": "hi ho",
248+
},
249+
undefined,
250+
],
185251
"createdAt": 1970-01-01T00:00:00.000Z,
186252
"key": "GET http://test.com/article-static/5",
187253
"options": Object {
@@ -208,6 +274,19 @@ Object {
208274
exports[`useRetrieve should dispatch with fetch shape defined errorExpiryLength 1`] = `
209275
Object {
210276
"meta": Object {
277+
"args": Array [
278+
Object {
279+
"content": "whatever",
280+
"id": 5,
281+
"tags": Array [
282+
"a",
283+
"best",
284+
"react",
285+
],
286+
"title": "hi ho",
287+
},
288+
undefined,
289+
],
211290
"createdAt": 1970-01-01T00:00:00.000Z,
212291
"key": "GET http://test.com/article-static/5",
213292
"options": Object {
@@ -234,6 +313,19 @@ Object {
234313
exports[`useRetrieve should dispatch with resource defined dataExpiryLength 1`] = `
235314
Object {
236315
"meta": Object {
316+
"args": Array [
317+
Object {
318+
"content": "whatever",
319+
"id": 5,
320+
"tags": Array [
321+
"a",
322+
"best",
323+
"react",
324+
],
325+
"title": "hi ho",
326+
},
327+
undefined,
328+
],
237329
"createdAt": 1970-01-01T00:00:00.000Z,
238330
"key": "GET http://test.com/article-static/5",
239331
"options": Object {

packages/core/src/react-integration/__tests__/__snapshots__/useFetchDispatcher.tsx.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
exports[`useFetchDispatcher should dispatch an action that fetches a create 1`] = `
44
Object {
55
"meta": Object {
6+
"args": Array [
7+
Object {},
8+
Object {
9+
"content": "hi",
10+
},
11+
],
612
"createdAt": 1970-01-01T00:00:00.000Z,
713
"key": "POST http://test.com/article-cooler/",
814
"options": Object {

packages/core/src/react-integration/__tests__/__snapshots__/useResource-endpoint.web.tsx.snap

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
exports[`useResource() should dispatch an action that fetches 1`] = `
44
Object {
55
"meta": Object {
6+
"args": Array [
7+
Object {
8+
"id": 5,
9+
},
10+
undefined,
11+
],
612
"createdAt": 1970-01-01T00:00:00.000Z,
713
"key": "GET http://test.com/article-cooler/5",
814
"options": Object {
@@ -28,6 +34,12 @@ Object {
2834
exports[`useResource() should dispatch fetch when sent multiple arguments 1`] = `
2935
Object {
3036
"meta": Object {
37+
"args": Array [
38+
Object {
39+
"id": 5,
40+
},
41+
undefined,
42+
],
3143
"createdAt": 1970-01-01T00:00:00.000Z,
3244
"key": "GET http://test.com/article-cooler/5",
3345
"options": Object {
@@ -53,6 +65,10 @@ Object {
5365
exports[`useResource() should dispatch fetch when sent multiple arguments 2`] = `
5466
Object {
5567
"meta": Object {
68+
"args": Array [
69+
Object {},
70+
undefined,
71+
],
5672
"createdAt": 1970-01-01T00:00:00.000Z,
5773
"key": "GET http://test.com/user/",
5874
"options": Object {

0 commit comments

Comments
 (0)