@apollion-dsi/relay 0.27.2 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +146 -0
- package/lib/chunks/chunk-54QV6DFY.esm.js +1 -0
- package/lib/chunks/chunk-FYOI5Q5V.esm.js +0 -0
- package/lib/chunks/chunk-GZONWSRB.esm.js +1 -0
- package/lib/chunks/chunk-KIA6YWO5.esm.js +1 -0
- package/lib/chunks/chunk-RMYDTZUF.esm.js +1 -0
- package/lib/chunks/chunk-XJA2SRQY.esm.js +1 -0
- package/lib/commitMutation/commitMutation.d.ts +15 -15
- package/lib/commitMutation/index.d.ts +4 -4
- package/lib/commitMutation/index.esm.js +1 -0
- package/lib/index.d.ts +10 -10
- package/lib/index.esm.js +1 -1
- package/lib/index.js +1 -1
- package/lib/mutationUtils/index.d.ts +5 -5
- package/lib/mutationUtils/index.esm.js +1 -0
- package/lib/mutationUtils/mutationUtils.d.ts +60 -60
- package/lib/relayArgsInterface/index.d.ts +3 -3
- package/lib/relayArgsInterface/index.esm.js +1 -0
- package/lib/relayArgsInterface/relayArgsInterface.d.ts +106 -79
- package/lib/setupRelayEnvironment/executeEnvironment.d.ts +13 -13
- package/lib/setupRelayEnvironment/fetchQuery.d.ts +19 -19
- package/lib/setupRelayEnvironment/fetchWithRetries.d.ts +20 -20
- package/lib/setupRelayEnvironment/index.d.ts +11 -0
- package/lib/setupRelayEnvironment/index.esm.js +1 -0
- package/lib/setupRelayEnvironment/setupRelayEnvironment.d.ts +74 -57
- package/lib/setupRelayEnvironment/setupRelayEnvironment.helpers.d.ts +64 -56
- package/lib/setupRelayEnvironment/storage.d.ts +17 -17
- package/lib/setupRelayEnvironment/subscriptionHandler.d.ts +26 -20
- package/lib/useEnvironment/index.d.ts +5 -5
- package/lib/useEnvironment/index.esm.js +1 -0
- package/lib/useEnvironment/useEnvironment.d.ts +16 -16
- package/package.json +33 -6
- package/README.MD +0 -119
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../chunks/chunk-FYOI5Q5V.esm.js";
|
|
@@ -1,207 +1,234 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview
|
|
3
|
-
* (`RelayArgsInterface`)
|
|
2
|
+
* @fileoverview Public types consumed by `setupRelayEnvironment`
|
|
3
|
+
* (`RelayArgsInterface`) and by its internals (`Sink`).
|
|
4
4
|
*
|
|
5
|
-
* `RelayArgsInterface`
|
|
6
|
-
* `CreateRelayEnvironment` —
|
|
7
|
-
*
|
|
5
|
+
* `RelayArgsInterface` is the configuration contract of
|
|
6
|
+
* `CreateRelayEnvironment` — any change here is part of the package's
|
|
7
|
+
* public API.
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* Relay `Observable` sink. Implemented by the Relay runtime and
|
|
11
|
+
* passed to the `Observable.create` callback. The fetch/subscription
|
|
12
|
+
* internals use this interface to propagate data, errors
|
|
13
|
+
* and completion to the stream.
|
|
14
14
|
*/
|
|
15
15
|
export interface Sink {
|
|
16
|
-
/**
|
|
16
|
+
/** Pushes the next value into the stream. */
|
|
17
17
|
next(value: any): void;
|
|
18
|
-
/**
|
|
18
|
+
/** Reports an error and closes the stream. */
|
|
19
19
|
error(error: Error, isUncaughtThrownError?: boolean): void;
|
|
20
|
-
/**
|
|
20
|
+
/** Signals normal stream completion. */
|
|
21
21
|
complete(): void;
|
|
22
|
-
/** `true`
|
|
22
|
+
/** `true` when the stream has already been closed (sink complete/error). */
|
|
23
23
|
readonly closed: boolean;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* Configuration accepted by the `CreateRelayEnvironment` constructor.
|
|
27
27
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
28
|
+
* Only `url` is required. All the other fields have sensible defaults
|
|
29
|
+
* defined in the constructor.
|
|
30
30
|
*
|
|
31
|
-
* @see {@link "../setupRelayEnvironment/setupRelayEnvironment"}
|
|
31
|
+
* @see {@link "../setupRelayEnvironment/setupRelayEnvironment"} for the defaults.
|
|
32
32
|
*/
|
|
33
33
|
export interface RelayArgsInterface {
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* HTTP endpoint of the GraphQL server. Required.
|
|
36
36
|
*/
|
|
37
37
|
url: string;
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* `useAuthorization`
|
|
39
|
+
* Authentication server endpoint. Used by the session verification
|
|
40
|
+
* flow (`${authUrl}user/me`). Required when
|
|
41
|
+
* `useAuthorization` is `true`.
|
|
42
42
|
*/
|
|
43
43
|
authUrl?: string;
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
46
|
-
* `useSubscription`
|
|
45
|
+
* WebSocket endpoint for GraphQL subscriptions. Required when
|
|
46
|
+
* `useSubscription` is `true`.
|
|
47
47
|
*/
|
|
48
48
|
socket?: string;
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
50
|
+
* List of delays (ms) between retry attempts, with backoff.
|
|
51
51
|
*
|
|
52
52
|
* @defaultValue `[1s, 2s, 3s, 5s, 8s, 13s, 21s, 34s]` (fibonacci-like)
|
|
53
53
|
*/
|
|
54
54
|
retries?: number[];
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
56
|
+
* Per-request timeout in ms.
|
|
57
57
|
*
|
|
58
|
-
* @defaultValue 15
|
|
58
|
+
* @defaultValue 15 minutes
|
|
59
59
|
*/
|
|
60
60
|
timeout?: number;
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
62
|
+
* Enables the GraphQL subscriptions handler over WebSocket.
|
|
63
63
|
*
|
|
64
64
|
* @defaultValue false
|
|
65
65
|
*/
|
|
66
66
|
useSubscription?: boolean;
|
|
67
67
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
68
|
+
* Enables JWT authentication — injects `Authorization: Bearer <token>`
|
|
69
|
+
* on every request using the stored `sessionToken`.
|
|
70
70
|
*
|
|
71
71
|
* @defaultValue false
|
|
72
72
|
*/
|
|
73
73
|
useAuthorization?: boolean;
|
|
74
74
|
/**
|
|
75
|
-
*
|
|
75
|
+
* Authentication model used by the Environment.
|
|
76
76
|
*
|
|
77
|
-
* - `'bearer'` (default,
|
|
78
|
-
* JS-
|
|
79
|
-
*
|
|
80
|
-
* - `'cookie'`:
|
|
81
|
-
* **
|
|
82
|
-
*
|
|
83
|
-
* `credentials` (default `'include'`
|
|
84
|
-
*
|
|
85
|
-
*
|
|
77
|
+
* - `'bearer'` (default, backwards-compatible): reads the `sessionToken`
|
|
78
|
+
* from JS-readable storage and injects `Authorization: Bearer <token>`
|
|
79
|
+
* on every request. Session verification uses the `${authUrl}user/me` probe.
|
|
80
|
+
* - `'cookie'`: **httpOnly cookie session** model. The Environment does
|
|
81
|
+
* **not** read the token in JS nor inject `Authorization` — the session
|
|
82
|
+
* cookie (httpOnly + SameSite) travels on its own as long as the fetch uses
|
|
83
|
+
* `credentials` (default `'include'` in this mode). Session renewal
|
|
84
|
+
* is triggered by an auth error (e.g. 401) calling `authUrl`
|
|
85
|
+
* with `credentials:'include'`, without probing `user/me`.
|
|
86
86
|
*
|
|
87
87
|
* @defaultValue `'bearer'`
|
|
88
88
|
*/
|
|
89
89
|
authMode?: 'bearer' | 'cookie';
|
|
90
90
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
91
|
+
* `credentials` value forwarded to the GraphQL and session
|
|
92
|
+
* verification/refresh fetches. Use `'include'` so the browser
|
|
93
|
+
* automatically attaches httpOnly session cookies (including
|
|
94
94
|
* cross-origin).
|
|
95
95
|
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
96
|
+
* When not set: `'include'` in `authMode:'cookie'` mode, and
|
|
97
|
+
* omitted (browser default) in `'bearer'` mode — preserving
|
|
98
|
+
* backwards compatibility for existing Bearer consumers.
|
|
99
99
|
*
|
|
100
|
-
* @defaultValue `authMode:'cookie'` → `'include'`;
|
|
100
|
+
* @defaultValue `authMode:'cookie'` → `'include'`; otherwise omitted.
|
|
101
101
|
*/
|
|
102
102
|
credentials?: RequestCredentials;
|
|
103
103
|
/**
|
|
104
|
-
* URL
|
|
105
|
-
*
|
|
104
|
+
* URL used to verify/renew the session when an auth error is
|
|
105
|
+
* detected. Makes the probe configurable/optional:
|
|
106
106
|
*
|
|
107
|
-
* - `string` —
|
|
108
|
-
* - `false` — **
|
|
109
|
-
* logout
|
|
110
|
-
*
|
|
111
|
-
* -
|
|
112
|
-
*
|
|
113
|
-
* `cookie`).
|
|
107
|
+
* - `string` — overrides the default probe URL.
|
|
108
|
+
* - `false` — **disables** the probe; an auth error is treated as
|
|
109
|
+
* a direct logout (clears storage + redirects to `loginRoute`),
|
|
110
|
+
* without any extra request.
|
|
111
|
+
* - not set — uses the mode's default: `${authUrl}user/me` (GET,
|
|
112
|
+
* `bearer` mode) or `authUrl` (POST + `credentials:'include'`,
|
|
113
|
+
* `cookie` mode).
|
|
114
114
|
*
|
|
115
|
-
* @defaultValue
|
|
115
|
+
* @defaultValue depends on `authMode` (see above).
|
|
116
116
|
*/
|
|
117
117
|
sessionCheckUrl?: string | false;
|
|
118
118
|
/**
|
|
119
|
-
*
|
|
120
|
-
*
|
|
119
|
+
* Enables response caching via Relay's `QueryResponseCache`.
|
|
120
|
+
* Per the Relay team's recommendation, it is off by default.
|
|
121
121
|
*
|
|
122
122
|
* @defaultValue false
|
|
123
123
|
*/
|
|
124
124
|
useCache?: boolean;
|
|
125
125
|
/**
|
|
126
|
-
* TTL (ms)
|
|
126
|
+
* TTL (ms) of the query cache entries.
|
|
127
127
|
*
|
|
128
|
-
* @defaultValue 8
|
|
128
|
+
* @defaultValue 8 minutes
|
|
129
129
|
*/
|
|
130
130
|
cacheTime?: number;
|
|
131
131
|
/**
|
|
132
|
-
*
|
|
132
|
+
* Maximum cache size (number of distinct queries kept).
|
|
133
133
|
*
|
|
134
134
|
* @defaultValue 250
|
|
135
135
|
*/
|
|
136
136
|
cacheSize?: number;
|
|
137
137
|
/**
|
|
138
|
-
*
|
|
138
|
+
* Storage key name for the session token (JWT).
|
|
139
139
|
*
|
|
140
140
|
* @defaultValue `'USER_SESSION_TOKEN'`
|
|
141
141
|
*/
|
|
142
142
|
sessionStorageProp?: string;
|
|
143
143
|
/**
|
|
144
|
-
*
|
|
144
|
+
* Storage key name for the refresh token.
|
|
145
145
|
*
|
|
146
146
|
* @defaultValue `'USER_REFRESH_TOKEN'`
|
|
147
147
|
*/
|
|
148
148
|
refreshStorageProp?: string;
|
|
149
149
|
/**
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
150
|
+
* Internal route the user is redirected to when the
|
|
151
|
+
* session expires (or on auth errors, if `redirectOnError` is
|
|
152
|
+
* enabled).
|
|
153
153
|
*
|
|
154
154
|
* @defaultValue `'/'`
|
|
155
155
|
*/
|
|
156
156
|
loginRoute?: string;
|
|
157
157
|
/**
|
|
158
|
-
*
|
|
159
|
-
*
|
|
158
|
+
* Turns on verbose logs (useful in development). Do not enable in
|
|
159
|
+
* production.
|
|
160
160
|
*
|
|
161
161
|
* @defaultValue false
|
|
162
162
|
*/
|
|
163
163
|
useDebug?: boolean;
|
|
164
164
|
/**
|
|
165
|
-
*
|
|
165
|
+
* Enables retries on error/timeout, using the delays from
|
|
166
166
|
* `retries`.
|
|
167
167
|
*
|
|
168
168
|
* @defaultValue false
|
|
169
169
|
*/
|
|
170
170
|
useRetries?: boolean;
|
|
171
171
|
/**
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
172
|
+
* Redirects the user to `loginRoute` when an error with a status
|
|
173
|
+
* in `authenticationErrors` is detected and the session is considered
|
|
174
|
+
* invalid.
|
|
175
175
|
*
|
|
176
176
|
* @defaultValue false
|
|
177
177
|
*/
|
|
178
178
|
redirectOnError?: boolean;
|
|
179
179
|
/**
|
|
180
|
-
*
|
|
181
|
-
* `true`). Defaults
|
|
180
|
+
* List of HTTP statuses that trigger a retry (when `useRetries` is
|
|
181
|
+
* `true`). Defaults cover typical Cloudflare errors.
|
|
182
182
|
*
|
|
183
183
|
* @defaultValue `[503, 504, 521, 522, 524]`
|
|
184
184
|
* @see https://support.cloudflare.com/hc/pt-br/articles/115003011431-Solu%C3%A7%C3%A3o-de-problemas-de-erros-5XX-da-Cloudflare
|
|
185
185
|
*/
|
|
186
186
|
retryWhen?: number[];
|
|
187
187
|
/**
|
|
188
|
-
*
|
|
189
|
-
* `redirectOnError
|
|
188
|
+
* Statuses treated as authentication errors for the
|
|
189
|
+
* `redirectOnError` flow.
|
|
190
190
|
*
|
|
191
191
|
* @defaultValue `[401, 403]`
|
|
192
192
|
*/
|
|
193
193
|
authenticationErrors?: number[];
|
|
194
194
|
/**
|
|
195
|
-
*
|
|
195
|
+
* Browser storage strategy for tokens.
|
|
196
196
|
*
|
|
197
197
|
* @defaultValue `'localStorage'`
|
|
198
198
|
*/
|
|
199
199
|
storageType?: 'cookie' | 'localStorage';
|
|
200
200
|
/**
|
|
201
|
-
*
|
|
202
|
-
*
|
|
201
|
+
* Partner identifier sent on every request via the
|
|
202
|
+
* `X-Partner` header. Useful for tenants/whitelabels.
|
|
203
203
|
*
|
|
204
204
|
* @defaultValue undefined
|
|
205
205
|
*/
|
|
206
206
|
partner?: string;
|
|
207
|
+
/**
|
|
208
|
+
* Enables **persisted queries**: the request carries only the
|
|
209
|
+
* operation hash generated at build time by `relay-compiler`
|
|
210
|
+
* (`persistConfig`) plus the variables — the GraphQL text never
|
|
211
|
+
* leaves the build.
|
|
212
|
+
*
|
|
213
|
+
* The server must hold the matching query map (hash → text) and
|
|
214
|
+
* accept the hash in the field named by `persistedOperationField`
|
|
215
|
+
* — in the JSON body for queries/mutations, or in
|
|
216
|
+
* `payload.extensions` for subscriptions over `graphql-ws`.
|
|
217
|
+
*
|
|
218
|
+
* Requires the consumer's `relay.config.json` to define
|
|
219
|
+
* `persistConfig` — with the flag on, an artifact without an `id`
|
|
220
|
+
* (compiler ran without `persistConfig`) throws a descriptive error
|
|
221
|
+
* instead of silently sending nothing.
|
|
222
|
+
*
|
|
223
|
+
* @defaultValue false
|
|
224
|
+
*/
|
|
225
|
+
usePersistedQueries?: boolean;
|
|
226
|
+
/**
|
|
227
|
+
* Name of the request field that carries the persisted-operation
|
|
228
|
+
* hash when `usePersistedQueries` is on. Lets the client match
|
|
229
|
+
* whatever field the server's allowlist middleware expects.
|
|
230
|
+
*
|
|
231
|
+
* @defaultValue `'doc_id'`
|
|
232
|
+
*/
|
|
233
|
+
persistedOperationField?: string;
|
|
207
234
|
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview
|
|
3
|
-
* Worker, viewport)
|
|
4
|
-
*
|
|
2
|
+
* @fileoverview Execution environment detection (browser/DOM,
|
|
3
|
+
* Worker, viewport) used by `setupRelayEnvironment` to switch
|
|
4
|
+
* behavior between browser and SSR.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* Not exposed by the root barrel — internal implementation of
|
|
7
7
|
* `CreateRelayEnvironment`.
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* Set of boolean flags indicating the current environment's capabilities.
|
|
11
|
+
* Inspired by the old `fbjs/ExecutionEnvironment`. Used to avoid
|
|
12
|
+
* circular dependencies and let code react to SSR without
|
|
13
|
+
* importing React directly.
|
|
14
14
|
*/
|
|
15
15
|
declare const _default: {
|
|
16
|
-
/** `true`
|
|
16
|
+
/** `true` in browsers. */
|
|
17
17
|
canUseDOM: boolean;
|
|
18
|
-
/** `true`
|
|
18
|
+
/** `true` if `Worker` is globally available. */
|
|
19
19
|
canUseWorkers: boolean;
|
|
20
|
-
/** `true`
|
|
20
|
+
/** `true` in browsers supporting `addEventListener` or IE `attachEvent`. */
|
|
21
21
|
canUseEventListeners: boolean;
|
|
22
|
-
/** `true`
|
|
22
|
+
/** `true` in browsers with `window.screen` (measurable viewport). */
|
|
23
23
|
canUseViewport: boolean;
|
|
24
|
-
/** `true`
|
|
24
|
+
/** `true` when running in a Worker (no DOM). */
|
|
25
25
|
isInWorker: boolean;
|
|
26
26
|
};
|
|
27
27
|
export default _default;
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview
|
|
3
|
-
* `setupRelayEnvironment`.
|
|
4
|
-
* `fetchWithRetries`,
|
|
5
|
-
*
|
|
6
|
-
* `Network.create`
|
|
2
|
+
* @fileoverview Factory for the Relay `fetchFn` used by
|
|
3
|
+
* `setupRelayEnvironment`. Encapsulates response caching, retries via
|
|
4
|
+
* `fetchWithRetries`, error handling (including redirect when the
|
|
5
|
+
* session expires) and the adaptation to the `Observable` model that
|
|
6
|
+
* Relay's `Network.create` expects.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* Not exposed by the root barrel — internal implementation of
|
|
9
9
|
* `CreateRelayEnvironment`.
|
|
10
10
|
*/
|
|
11
11
|
import { CacheConfig, Observable, RequestParameters, UploadableMap, Variables } from 'relay-runtime';
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Creates the fetch function that will be passed to Relay's `Network.create`.
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
* -
|
|
17
|
-
* (`QueryResponseCache`)
|
|
18
|
-
* -
|
|
19
|
-
*
|
|
20
|
-
* -
|
|
21
|
-
* (
|
|
22
|
-
* refresh
|
|
23
|
-
*
|
|
24
|
-
* -
|
|
15
|
+
* Behavior:
|
|
16
|
+
* - For queries with `useCache` on, tries to serve from the cache
|
|
17
|
+
* (`QueryResponseCache`) before making the request.
|
|
18
|
+
* - For mutations with `useCache` on, clears the cache (full
|
|
19
|
+
* invalidation — Relay will re-fetch affected queries).
|
|
20
|
+
* - When an authentication error is detected, verifies/renews the session
|
|
21
|
+
* (bearer mode: `${authUrl}user/me` probe; httpOnly cookie mode:
|
|
22
|
+
* refresh at `authUrl` with `credentials:'include'`) and, if invalid,
|
|
23
|
+
* clears storage and redirects to `loginRoute`.
|
|
24
|
+
* - Errors are propagated via `sink.error()`.
|
|
25
25
|
*
|
|
26
|
-
* @param config -
|
|
27
|
-
* @returns
|
|
26
|
+
* @param config - Configured `CreateRelayEnvironment` instance.
|
|
27
|
+
* @returns Function compatible with `Network.create(fetchFn, ...)`.
|
|
28
28
|
*/
|
|
29
29
|
export declare const createFetchFunction: (config: any) => (request: RequestParameters, variables: Variables, cacheConfig: CacheConfig, uploadables: UploadableMap) => Observable<unknown>;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview
|
|
3
|
-
*
|
|
2
|
+
* @fileoverview `fetch` implementation with retries and timeout, used
|
|
3
|
+
* internally by `fetchQuery` in `setupRelayEnvironment`.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* - timeout
|
|
7
|
-
* - retry
|
|
8
|
-
* status
|
|
9
|
-
* - debug logs
|
|
5
|
+
* Adds on top of the native `fetch`:
|
|
6
|
+
* - per-request timeout (`AbortController`);
|
|
7
|
+
* - retry with configurable delays (`retries` in the config) when the
|
|
8
|
+
* HTTP status is in `retryWhen` or a timeout occurred;
|
|
9
|
+
* - optional debug logs via `useDebug`.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* Not exposed by the root barrel — internal implementation of
|
|
12
12
|
* `CreateRelayEnvironment`.
|
|
13
13
|
*/
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* Subset of `RequestInit` accepted by `fetchWithRetries`. We keep
|
|
16
|
+
* only the fields actually forwarded to the native `fetch`.
|
|
17
17
|
*/
|
|
18
18
|
export type InitWithRetries = {
|
|
19
19
|
body?: BodyInit | null;
|
|
@@ -24,18 +24,18 @@ export type InitWithRetries = {
|
|
|
24
24
|
mode?: RequestMode;
|
|
25
25
|
};
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* Creates a `fetch` function configured with timeout and retries.
|
|
28
28
|
*
|
|
29
|
-
*
|
|
30
|
-
* -
|
|
31
|
-
* -
|
|
32
|
-
*
|
|
33
|
-
* - Retries
|
|
34
|
-
*
|
|
35
|
-
* -
|
|
29
|
+
* Behavior:
|
|
30
|
+
* - Each attempt has a timeout of `config.timeout` ms (via `AbortController`).
|
|
31
|
+
* - On timeout, or when the status is in `config.retryWhen`, it schedules
|
|
32
|
+
* the next attempt with the corresponding delay in `config.retries`.
|
|
33
|
+
* - Retries only happen when a DOM is available and `config.useRetries`
|
|
34
|
+
* is `true` — in SSR the first attempt is the only one.
|
|
35
|
+
* - Errors unrelated to `AbortError` are rejected immediately.
|
|
36
36
|
*
|
|
37
|
-
* @param config -
|
|
37
|
+
* @param config - Environment configuration (timeout, retries,
|
|
38
38
|
* retryWhen, useRetries, useDebug, url).
|
|
39
|
-
* @returns
|
|
39
|
+
* @returns Function that takes a `RequestInit` and returns a `Promise<Response>`.
|
|
40
40
|
*/
|
|
41
41
|
export declare function fetchWithRetries(config: any): (init?: InitWithRetries | null) => Promise<any>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public barrel for the `setupRelayEnvironment` module.
|
|
3
|
+
*
|
|
4
|
+
* Exports only the public surface: the `CreateRelayEnvironment` class
|
|
5
|
+
* (default export of the `setupRelayEnvironment.ts` file). The internals
|
|
6
|
+
* `fetchQuery`, `fetchWithRetries`, `storage`, `subscriptionHandler`,
|
|
7
|
+
* `executeEnvironment` and `setupRelayEnvironment.helpers` stay hidden
|
|
8
|
+
* — they are part of the implementation and not part of the contract.
|
|
9
|
+
*/
|
|
10
|
+
export { default as CreateRelayEnvironment } from './setupRelayEnvironment';
|
|
11
|
+
export { default } from './setupRelayEnvironment';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"../chunks/chunk-KIA6YWO5.esm.js";import"../chunks/chunk-GZONWSRB.esm.js";export{a as CreateRelayEnvironment,a as default};
|