rescript-relay 1.1.0 → 1.1.1
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/package.json +1 -1
- package/ppx-macos-arm64 +0 -0
- package/ppx-windows-latest +0 -0
- package/relay-compiler-linux-musl/relay +0 -0
- package/relay-compiler-linux-x64/relay +0 -0
- package/relay-compiler-win-x64/relay.exe +0 -0
- package/src/RescriptRelay.res +1 -1
- package/src/RescriptRelay.resi +187 -265
- package/src/RescriptRelayUtils.resi +3 -5
package/package.json
CHANGED
package/ppx-macos-arm64
CHANGED
|
Binary file
|
package/ppx-windows-latest
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/RescriptRelay.res
CHANGED
package/src/RescriptRelay.resi
CHANGED
|
@@ -1,94 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
"Abstract type for arguments, used when selecting fields on `RecordProxy` and friends when interacting with the store imperatively."
|
|
3
|
-
)
|
|
1
|
+
/**Abstract type for arguments, used when selecting fields on `RecordProxy` and friends when interacting with the store imperatively.*/
|
|
4
2
|
type arguments
|
|
5
3
|
|
|
6
|
-
|
|
4
|
+
/**Abstract type for uploadables.
|
|
7
5
|
|
|
8
6
|
### Constructing an `uploadables`
|
|
9
|
-
Use `makeUploadable`: `makeUploadable({
|
|
7
|
+
Use `makeUploadable`: `makeUploadable({ "someFile": theFileYouWantToUpload })` to construct an `uploadables`, and then pass it to your mutation via the `uploadables` prop.
|
|
10
8
|
|
|
11
|
-
Please note that you'll need to handle _sending_ the uploadables to your server yourself in the network layer. [Here's an example](https://github.com/facebook/relay/issues/1844#issuecomment-316893590) in regular JS that you can adapt to ReScript as you need/want
|
|
9
|
+
Please note that you'll need to handle _sending_ the uploadables to your server yourself in the network layer. [Here's an example](https://github.com/facebook/relay/issues/1844#issuecomment-316893590) in regular JS that you can adapt to ReScript as you need/want.*/
|
|
12
10
|
type uploadables
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
"If you see this, it means that all fields have been masked in this selection, which is why it contains no data. Relay uses [_data masking_](https://relay.dev/docs/en/thinking-in-relay.html#data-masking) to hide data you haven't explicitly asked for, even if it exists on the object."
|
|
16
|
-
)
|
|
12
|
+
/**If you see this, it means that all fields have been masked in this selection, which is why it contains no data. Relay uses [_data masking_](https://relay.dev/docs/en/thinking-in-relay.html#data-masking) to hide data you haven't explicitly asked for, even if it exists on the object.*/
|
|
17
13
|
type allFieldsMasked = {.}
|
|
18
14
|
|
|
19
|
-
|
|
20
|
-
"Abstract helper type to signify something that could not be generated in a type-safe way."
|
|
21
|
-
)
|
|
15
|
+
/**Abstract helper type to signify something that could not be generated in a type-safe way.*/
|
|
22
16
|
type any
|
|
23
17
|
|
|
24
|
-
|
|
25
|
-
"A query node, used internally by Relay. These are runtime artifacts produced by the Relay compiler."
|
|
26
|
-
)
|
|
18
|
+
/**A query node, used internally by Relay. These are runtime artifacts produced by the Relay compiler.*/
|
|
27
19
|
type queryNode<'node>
|
|
28
20
|
|
|
29
|
-
|
|
30
|
-
"A fragment node, used internally by Relay. These are runtime artifacts produced by the Relay compiler."
|
|
31
|
-
)
|
|
21
|
+
/**A fragment node, used internally by Relay. These are runtime artifacts produced by the Relay compiler.*/
|
|
32
22
|
type fragmentNode<'node>
|
|
33
23
|
|
|
34
|
-
|
|
35
|
-
"A mutation node, used internally by Relay. These are runtime artifacts produced by the Relay compiler."
|
|
36
|
-
)
|
|
24
|
+
/**A mutation node, used internally by Relay. These are runtime artifacts produced by the Relay compiler.*/
|
|
37
25
|
type mutationNode<'node>
|
|
38
26
|
|
|
39
|
-
|
|
40
|
-
"A subscription node, used internally by Relay. These are runtime artifacts produced by the Relay compiler."
|
|
41
|
-
)
|
|
27
|
+
/**A subscription node, used internally by Relay. These are runtime artifacts produced by the Relay compiler.*/
|
|
42
28
|
type subscriptionNode<'node>
|
|
43
29
|
|
|
44
|
-
|
|
30
|
+
/**This type shows all of the fragments that has been spread on this particular object.*/
|
|
45
31
|
type fragmentRefs<'fragments>
|
|
46
32
|
|
|
47
|
-
|
|
33
|
+
/**The type of the id Relay uses to identify records in its store.*/
|
|
48
34
|
type dataId
|
|
49
35
|
|
|
50
|
-
|
|
36
|
+
/**Turns a `dataId` into a `string`.*/
|
|
51
37
|
external dataIdToString: dataId => string = "%identity"
|
|
52
38
|
|
|
53
|
-
|
|
39
|
+
/**Turns a `string` into a `dataId`.*/
|
|
54
40
|
external makeDataId: string => dataId = "%identity"
|
|
55
41
|
|
|
56
|
-
|
|
42
|
+
/**Construct an `arguments` object for use with certain Relay store APIs.
|
|
57
43
|
|
|
58
44
|
### Usage
|
|
59
|
-
Use it like this: `makeArguments({
|
|
45
|
+
Use it like this: `makeArguments({ "someArgument": someValue, "anotherArgument": anotherValue })`. Notice the "" surrounding the property names - these are important and tells ReScript that we want this to be a JS object.*/
|
|
60
46
|
external makeArguments: {..} => arguments = "%identity"
|
|
61
47
|
|
|
62
|
-
|
|
63
|
-
"Construct an `uploadables` object from a `Js.Dict` with your desired file format, that you can use for uploads via Relay."
|
|
64
|
-
)
|
|
48
|
+
/**Construct an `uploadables` object from a `Js.Dict` with your desired file format, that you can use for uploads via Relay.*/
|
|
65
49
|
external makeUploadables: Js.Dict.t<'file> => uploadables = "%identity"
|
|
66
50
|
|
|
67
|
-
|
|
68
|
-
"Unwraps `uploadables` into a Js.Dict.t with your expected file type, so you can use that dict to attach the provided files to your request."
|
|
69
|
-
)
|
|
51
|
+
/**Unwraps `uploadables` into a Js.Dict.t with your expected file type, so you can use that dict to attach the provided files to your request.*/
|
|
70
52
|
external unwrapUploadables: uploadables => Js.Dict.t<'file> = "%identity"
|
|
71
53
|
|
|
72
|
-
|
|
73
|
-
"This generates a `dataId` for use on the _client_ side. However, this is farily low level, and what you're probably really looking for is `generateUniqueClientID` that'll let you generate a new, unique `dataId` that you can use for client side only records (like when doing optimistic updates)."
|
|
74
|
-
)
|
|
54
|
+
/**This generates a `dataId` for use on the _client_ side. However, this is farily low level, and what you're probably really looking for is `generateUniqueClientID` that'll let you generate a new, unique `dataId` that you can use for client side only records (like when doing optimistic updates).*/
|
|
75
55
|
@module("relay-runtime")
|
|
76
56
|
external generateClientID: (~dataId: dataId, ~storageKey: string, ~index: int=?, unit) => dataId =
|
|
77
57
|
"generateClientID"
|
|
78
58
|
|
|
79
|
-
|
|
80
|
-
"This generates a unique `dataId` that's safe to use on the _client_ side. Useful when doing optimistic updates and you need to create IDs that the optimistic update can use."
|
|
81
|
-
)
|
|
59
|
+
/**This generates a unique `dataId` that's safe to use on the _client_ side. Useful when doing optimistic updates and you need to create IDs that the optimistic update can use.*/
|
|
82
60
|
@module("relay-runtime")
|
|
83
61
|
external generateUniqueClientID: unit => dataId = "generateUniqueClientID"
|
|
84
62
|
|
|
85
|
-
|
|
63
|
+
/**Checks whether the provided `dataId` is guaranteed to be a client side only id.*/
|
|
86
64
|
@module("relay-runtime")
|
|
87
65
|
external isClientID: dataId => bool = "isClientID"
|
|
88
66
|
|
|
89
|
-
|
|
90
|
-
"Relay feature flags. Mutate this record as soon as your application boots to enable/disable features."
|
|
91
|
-
)
|
|
67
|
+
/**Relay feature flags. Mutate this record as soon as your application boots to enable/disable features.*/
|
|
92
68
|
type featureFlags = {
|
|
93
69
|
@as("DELAY_CLEANUP_OF_PENDING_PRELOAD_QUERIES")
|
|
94
70
|
mutable delayCleanupOfPendingPreloadQueries: bool,
|
|
@@ -126,55 +102,47 @@ type featureFlags = {
|
|
|
126
102
|
mutable useReactCache: bool,
|
|
127
103
|
}
|
|
128
104
|
|
|
129
|
-
|
|
130
|
-
"Relay feature flags. Mutate this record as soon as your application boots to enable/disable features."
|
|
131
|
-
)
|
|
105
|
+
/**Relay feature flags. Mutate this record as soon as your application boots to enable/disable features.*/
|
|
132
106
|
@module("relay-runtime")
|
|
133
107
|
external relayFeatureFlags: featureFlags = "RelayFeatureFlags"
|
|
134
108
|
|
|
135
|
-
|
|
109
|
+
/**Representing all records in the store serialized to JSON in a way that you can use to re-hydrate the store.
|
|
136
110
|
|
|
137
|
-
See `RecordSource.toJSON` for how to produce it
|
|
111
|
+
See `RecordSource.toJSON` for how to produce it.*/
|
|
138
112
|
type recordSourceRecords = Js.Json.t
|
|
139
113
|
|
|
140
|
-
|
|
141
|
-
"The `dataId` for the Relay store's root. Useful when for example referencing the `parentID` of a connection that's on the store root."
|
|
142
|
-
)
|
|
114
|
+
/**The `dataId` for the Relay store's root. Useful when for example referencing the `parentID` of a connection that's on the store root.*/
|
|
143
115
|
@module("relay-runtime")
|
|
144
116
|
external storeRootId: dataId = "ROOT_ID"
|
|
145
117
|
|
|
146
|
-
|
|
118
|
+
/**The `type` for the Relay store's root `RecordProxy`.*/
|
|
119
|
+
@module("relay-runtime")
|
|
147
120
|
external storeRootType: string = "ROOT_TYPE"
|
|
148
121
|
|
|
149
|
-
|
|
122
|
+
/**Internal, do not use.*/
|
|
123
|
+
@module("./utils")
|
|
150
124
|
external convertObj: ('a, Js.Dict.t<Js.Dict.t<Js.Dict.t<string>>>, 'b, 'c) => 'd = "traverser"
|
|
151
125
|
|
|
152
|
-
|
|
153
|
-
"Read the following section on working with the Relay store: https://relay.dev/docs/en/relay-store"
|
|
154
|
-
)
|
|
126
|
+
/**Read the following section on working with the Relay store: https://relay.dev/docs/en/relay-store*/
|
|
155
127
|
module RecordProxy: {
|
|
156
|
-
|
|
157
|
-
"Read the following section on working with the Relay store: https://relay.dev/docs/en/relay-store"
|
|
158
|
-
)
|
|
128
|
+
/**Read the following section on working with the Relay store: https://relay.dev/docs/en/relay-store*/
|
|
159
129
|
type t
|
|
160
130
|
|
|
161
|
-
|
|
131
|
+
/**Copies all fields from one `RecordProxy` to another.*/
|
|
132
|
+
@send
|
|
162
133
|
external copyFieldsFrom: (t, ~sourceRecord: t) => unit = "copyFieldsFrom"
|
|
163
134
|
|
|
164
|
-
|
|
135
|
+
/**Gets the \`dataId\` for a particular record.*/
|
|
136
|
+
@send
|
|
165
137
|
external getDataId: t => dataId = "getDataID"
|
|
166
138
|
|
|
167
|
-
|
|
168
|
-
"Gets a single linked record. A linked record is another object in the store, and not a scalar field like an int or float."
|
|
169
|
-
)
|
|
139
|
+
/**Gets a single linked record. A linked record is another object in the store, and not a scalar field like an int or float.*/
|
|
170
140
|
@send
|
|
171
141
|
@return(nullable)
|
|
172
142
|
external getLinkedRecord: (t, ~name: string, ~arguments: arguments=?, unit) => option<t> =
|
|
173
143
|
"getLinkedRecord"
|
|
174
144
|
|
|
175
|
-
|
|
176
|
-
"Gets an array of linked records, for when a field is a list (meaning a link to multiple records)."
|
|
177
|
-
)
|
|
145
|
+
/**Gets an array of linked records, for when a field is a list (meaning a link to multiple records).*/
|
|
178
146
|
let getLinkedRecords: (
|
|
179
147
|
t,
|
|
180
148
|
~name: string,
|
|
@@ -182,9 +150,7 @@ module RecordProxy: {
|
|
|
182
150
|
unit,
|
|
183
151
|
) => option<array<option<t>>>
|
|
184
152
|
|
|
185
|
-
|
|
186
|
-
"This returns an existing linked record, or creates one at the configured place if one does not already exist."
|
|
187
|
-
)
|
|
153
|
+
/**This returns an existing linked record, or creates one at the configured place if one does not already exist.*/
|
|
188
154
|
@send
|
|
189
155
|
external getOrCreateLinkedRecord: (
|
|
190
156
|
t,
|
|
@@ -194,14 +160,17 @@ module RecordProxy: {
|
|
|
194
160
|
unit,
|
|
195
161
|
) => t = "getOrCreateLinkedRecord"
|
|
196
162
|
|
|
197
|
-
|
|
163
|
+
/**Returns the `__typename` of this particular record.*/
|
|
164
|
+
@send
|
|
198
165
|
external getType: t => string = "getType"
|
|
199
166
|
|
|
200
|
-
|
|
167
|
+
/**Returns a field value, expecting it to be a string.*/
|
|
168
|
+
@send
|
|
169
|
+
@return(nullable)
|
|
201
170
|
external getValueString: (t, ~name: string, ~arguments: arguments=?, unit) => option<string> =
|
|
202
171
|
"getValue"
|
|
203
172
|
|
|
204
|
-
|
|
173
|
+
/**Returns a field value, expecting it to be an array of strings.*/
|
|
205
174
|
@send
|
|
206
175
|
@return(nullable)
|
|
207
176
|
external getValueStringArray: (
|
|
@@ -211,11 +180,15 @@ module RecordProxy: {
|
|
|
211
180
|
unit,
|
|
212
181
|
) => option<array<option<string>>> = "getValue"
|
|
213
182
|
|
|
214
|
-
|
|
183
|
+
/**Returns a field value, expecting it to be an int.*/
|
|
184
|
+
@send
|
|
185
|
+
@return(nullable)
|
|
215
186
|
external getValueInt: (t, ~name: string, ~arguments: arguments=?, unit) => option<int> =
|
|
216
187
|
"getValue"
|
|
217
188
|
|
|
218
|
-
|
|
189
|
+
/**Returns a field value, expecting it to be an array of ints.*/
|
|
190
|
+
@send
|
|
191
|
+
@return(nullable)
|
|
219
192
|
external getValueIntArray: (
|
|
220
193
|
t,
|
|
221
194
|
~name: string,
|
|
@@ -223,11 +196,13 @@ module RecordProxy: {
|
|
|
223
196
|
unit,
|
|
224
197
|
) => option<array<option<int>>> = "getValue"
|
|
225
198
|
|
|
226
|
-
|
|
199
|
+
/**Returns a field value, expecting it to be a float.*/
|
|
200
|
+
@send
|
|
201
|
+
@return(nullable)
|
|
227
202
|
external getValueFloat: (t, ~name: string, ~arguments: arguments=?, unit) => option<float> =
|
|
228
203
|
"getValue"
|
|
229
204
|
|
|
230
|
-
|
|
205
|
+
/**Returns a field value, expecting it to be an array of floats.*/
|
|
231
206
|
@send
|
|
232
207
|
@return(nullable)
|
|
233
208
|
external getValueFloatArray: (
|
|
@@ -237,11 +212,13 @@ module RecordProxy: {
|
|
|
237
212
|
unit,
|
|
238
213
|
) => option<array<option<float>>> = "getValue"
|
|
239
214
|
|
|
240
|
-
|
|
215
|
+
/**Returns a field value, expecting it to be a boolean.*/
|
|
216
|
+
@send
|
|
217
|
+
@return(nullable)
|
|
241
218
|
external getValueBool: (t, ~name: string, ~arguments: arguments=?, unit) => option<bool> =
|
|
242
219
|
"getValue"
|
|
243
220
|
|
|
244
|
-
|
|
221
|
+
/**Returns a field value, expecting it to be an array of booleans.*/
|
|
245
222
|
@send
|
|
246
223
|
@return(nullable)
|
|
247
224
|
external getValueBoolArray: (
|
|
@@ -251,11 +228,13 @@ module RecordProxy: {
|
|
|
251
228
|
unit,
|
|
252
229
|
) => option<array<option<bool>>> = "getValue"
|
|
253
230
|
|
|
254
|
-
|
|
231
|
+
/**Sets a `RecordProxy.t` as the linked record for a particular field.*/
|
|
232
|
+
@send
|
|
255
233
|
external setLinkedRecord: (t, ~record: t, ~name: string, ~arguments: arguments=?, unit) => t =
|
|
256
234
|
"setLinkedRecord"
|
|
257
235
|
|
|
258
|
-
|
|
236
|
+
/**Sets an array of `RecordProxy.t` as the linked records for a particular field.*/
|
|
237
|
+
@send
|
|
259
238
|
external setLinkedRecords: (
|
|
260
239
|
t,
|
|
261
240
|
~records: array<option<t>>,
|
|
@@ -264,11 +243,13 @@ module RecordProxy: {
|
|
|
264
243
|
unit,
|
|
265
244
|
) => t = "setLinkedRecords"
|
|
266
245
|
|
|
267
|
-
|
|
246
|
+
/**Sets a string as field value.*/
|
|
247
|
+
@send
|
|
268
248
|
external setValueString: (t, ~value: string, ~name: string, ~arguments: arguments=?, unit) => t =
|
|
269
249
|
"setValue"
|
|
270
250
|
|
|
271
|
-
|
|
251
|
+
/**Sets an array of strings as field value.*/
|
|
252
|
+
@send
|
|
272
253
|
external setValueStringArray: (
|
|
273
254
|
t,
|
|
274
255
|
~value: array<string>,
|
|
@@ -277,11 +258,13 @@ module RecordProxy: {
|
|
|
277
258
|
unit,
|
|
278
259
|
) => t = "setValue"
|
|
279
260
|
|
|
280
|
-
|
|
261
|
+
/**Sets an int as field value.*/
|
|
262
|
+
@send
|
|
281
263
|
external setValueInt: (t, ~value: int, ~name: string, ~arguments: arguments=?, unit) => t =
|
|
282
264
|
"setValue"
|
|
283
265
|
|
|
284
|
-
|
|
266
|
+
/**Sets an array of ints as field value.*/
|
|
267
|
+
@send
|
|
285
268
|
external setValueIntArray: (
|
|
286
269
|
t,
|
|
287
270
|
~value: array<int>,
|
|
@@ -290,11 +273,13 @@ module RecordProxy: {
|
|
|
290
273
|
unit,
|
|
291
274
|
) => t = "setValue"
|
|
292
275
|
|
|
293
|
-
|
|
276
|
+
/**Sets a float as field value.*/
|
|
277
|
+
@send
|
|
294
278
|
external setValueFloat: (t, ~value: float, ~name: string, ~arguments: arguments=?, unit) => t =
|
|
295
279
|
"setValue"
|
|
296
280
|
|
|
297
|
-
|
|
281
|
+
/**Sets an array of floats as field value.*/
|
|
282
|
+
@send
|
|
298
283
|
external setValueFloatArray: (
|
|
299
284
|
t,
|
|
300
285
|
~value: array<float>,
|
|
@@ -303,11 +288,13 @@ module RecordProxy: {
|
|
|
303
288
|
unit,
|
|
304
289
|
) => t = "setValue"
|
|
305
290
|
|
|
306
|
-
|
|
291
|
+
/**Sets a boolean as field value.*/
|
|
292
|
+
@send
|
|
307
293
|
external setValueBool: (t, ~value: bool, ~name: string, ~arguments: arguments=?, unit) => t =
|
|
308
294
|
"setValue"
|
|
309
295
|
|
|
310
|
-
|
|
296
|
+
/**Sets an array of booleans as field value.*/
|
|
297
|
+
@send
|
|
311
298
|
external setValueBoolArray: (
|
|
312
299
|
t,
|
|
313
300
|
~value: array<bool>,
|
|
@@ -316,7 +303,7 @@ module RecordProxy: {
|
|
|
316
303
|
unit,
|
|
317
304
|
) => t = "setValue"
|
|
318
305
|
|
|
319
|
-
|
|
306
|
+
/**Sets the field value to `undefined` (meaning Relay will treat it as missing data).*/
|
|
320
307
|
@send
|
|
321
308
|
external setValueToUndefined: (
|
|
322
309
|
t,
|
|
@@ -326,7 +313,8 @@ module RecordProxy: {
|
|
|
326
313
|
unit,
|
|
327
314
|
) => t = "setValue"
|
|
328
315
|
|
|
329
|
-
|
|
316
|
+
/**Sets the field value to `null`.*/
|
|
317
|
+
@send
|
|
330
318
|
external setValueToNull: (
|
|
331
319
|
t,
|
|
332
320
|
@as(json`null`) _,
|
|
@@ -335,9 +323,7 @@ module RecordProxy: {
|
|
|
335
323
|
unit,
|
|
336
324
|
) => t = "setValue"
|
|
337
325
|
|
|
338
|
-
|
|
339
|
-
"Sets this linked record to `undefined` (meaning Relay will treat it as missing data)."
|
|
340
|
-
)
|
|
326
|
+
/**Sets this linked record to `undefined` (meaning Relay will treat it as missing data).*/
|
|
341
327
|
@send
|
|
342
328
|
external setLinkedRecordToUndefined: (
|
|
343
329
|
t,
|
|
@@ -347,7 +333,8 @@ module RecordProxy: {
|
|
|
347
333
|
unit,
|
|
348
334
|
) => t = "setValue"
|
|
349
335
|
|
|
350
|
-
|
|
336
|
+
/**Sets this linked record to `null`.*/
|
|
337
|
+
@send
|
|
351
338
|
external setLinkedRecordToNull: (
|
|
352
339
|
t,
|
|
353
340
|
@as(json`null`) _,
|
|
@@ -356,9 +343,7 @@ module RecordProxy: {
|
|
|
356
343
|
unit,
|
|
357
344
|
) => t = "setValue"
|
|
358
345
|
|
|
359
|
-
|
|
360
|
-
"Sets the field holding these linked records to `undefined` (meaning Relay will treat it as missing data)."
|
|
361
|
-
)
|
|
346
|
+
/**Sets the field holding these linked records to `undefined` (meaning Relay will treat it as missing data).*/
|
|
362
347
|
@send
|
|
363
348
|
external setLinkedRecordsToUndefined: (
|
|
364
349
|
t,
|
|
@@ -368,7 +353,8 @@ module RecordProxy: {
|
|
|
368
353
|
unit,
|
|
369
354
|
) => t = "setValue"
|
|
370
355
|
|
|
371
|
-
|
|
356
|
+
/**Sets the field holding these linked records to `null`.*/
|
|
357
|
+
@send
|
|
372
358
|
external setLinkedRecordsToNull: (
|
|
373
359
|
t,
|
|
374
360
|
@as(json`null`) _,
|
|
@@ -377,82 +363,72 @@ module RecordProxy: {
|
|
|
377
363
|
unit,
|
|
378
364
|
) => t = "setValue"
|
|
379
365
|
|
|
380
|
-
|
|
366
|
+
/**Invalidates this record.
|
|
381
367
|
|
|
382
368
|
Invalidating a record means that the _next_ time Relay evaluates this record, it'll be treated as missing.
|
|
383
369
|
|
|
384
|
-
_Beware_ that this doesn't mean that queries using this record will refetch immediately. Rather, it'll happen the next time the query _renders_. Have a look at `useSubscribeToInvalidationState`, that'll allow you to subscribe to whenever records are invalidated, if you're looking for a way to refetch immediately as something invalidates
|
|
370
|
+
_Beware_ that this doesn't mean that queries using this record will refetch immediately. Rather, it'll happen the next time the query _renders_. Have a look at `useSubscribeToInvalidationState`, that'll allow you to subscribe to whenever records are invalidated, if you're looking for a way to refetch immediately as something invalidates.*/
|
|
385
371
|
@send
|
|
386
372
|
external invalidateRecord: t => unit = "invalidateRecord"
|
|
387
373
|
}
|
|
388
374
|
|
|
389
|
-
|
|
390
|
-
"RecordSourceSelectorProxy and RecordSourceProxy are the two modules representing the store, with various capabilities."
|
|
391
|
-
)
|
|
375
|
+
/**RecordSourceSelectorProxy and RecordSourceProxy are the two modules representing the store, with various capabilities.*/
|
|
392
376
|
module RecordSourceSelectorProxy: {
|
|
393
|
-
|
|
377
|
+
/**Type type representing a `RecordSourceSelectorProxy`.*/
|
|
394
378
|
type t
|
|
395
379
|
|
|
396
|
-
|
|
380
|
+
/**Creates a new `RecordProxy`.*/
|
|
381
|
+
@send
|
|
397
382
|
external create: (t, ~dataId: dataId, ~typeName: string) => RecordProxy.t = "create"
|
|
398
383
|
|
|
399
|
-
|
|
384
|
+
/**Deletes the `RecordProxy` with the provided `dataId`.*/
|
|
385
|
+
@send
|
|
400
386
|
external delete: (t, ~dataId: dataId) => unit = "delete"
|
|
401
387
|
|
|
402
|
-
|
|
388
|
+
/**Returns the `RecordProxy` with the provided `dataId`, if it exists.*/
|
|
403
389
|
@send
|
|
404
390
|
@return(nullable)
|
|
405
391
|
external get: (t, ~dataId: dataId) => option<RecordProxy.t> = "get"
|
|
406
392
|
|
|
407
|
-
|
|
408
|
-
"Returns the _root_ `RecordProxy`, meaning the `RecordProxy` holding your top level fields."
|
|
409
|
-
)
|
|
393
|
+
/**Returns the _root_ `RecordProxy`, meaning the `RecordProxy` holding your top level fields.*/
|
|
410
394
|
@send
|
|
411
395
|
external getRoot: t => RecordProxy.t = "getRoot"
|
|
412
396
|
|
|
413
|
-
|
|
414
|
-
"Returns the `RecordProxy` for the `fieldName` at root. You should prefer using `RecordSourceSelectorProxy.getRoot()` and traverse from there if you need access to root fields rather than use this."
|
|
415
|
-
)
|
|
397
|
+
/**Returns the `RecordProxy` for the `fieldName` at root. You should prefer using `RecordSourceSelectorProxy.getRoot()` and traverse from there if you need access to root fields rather than use this.*/
|
|
416
398
|
@send
|
|
417
399
|
@return(nullable)
|
|
418
400
|
external getRootField: (t, ~fieldName: string) => option<RecordProxy.t> = "getRootField"
|
|
419
401
|
|
|
420
|
-
|
|
402
|
+
/**Plural version of `RecordSourceSelectorProxy.getRootField`.*/
|
|
421
403
|
let getPluralRootField: (t, ~fieldName: string) => option<array<option<RecordProxy.t>>>
|
|
422
404
|
|
|
423
|
-
|
|
424
|
-
"Invalidates the entire store. This means that _at the next render_, the entire store will be treated as empty, meaning Relay will refetch everything it needs to show the view it's to show."
|
|
425
|
-
)
|
|
405
|
+
/**Invalidates the entire store. This means that _at the next render_, the entire store will be treated as empty, meaning Relay will refetch everything it needs to show the view it's to show.*/
|
|
426
406
|
@send
|
|
427
407
|
external invalidateStore: t => unit = "invalidateStore"
|
|
428
408
|
}
|
|
429
409
|
|
|
430
|
-
|
|
410
|
+
/**ReadOnlyRecordSourceProxy is the store, but in read-only mode.*/
|
|
431
411
|
module ReadOnlyRecordSourceProxy: {
|
|
432
|
-
|
|
412
|
+
/**Type type representing a `ReadOnlyRecordSourceProxy`.*/
|
|
433
413
|
type t
|
|
434
414
|
|
|
435
|
-
|
|
415
|
+
/**Returns the `RecordProxy` with the provided `dataId`, if it exists.*/
|
|
436
416
|
@send
|
|
437
417
|
@return(nullable)
|
|
438
418
|
external get: (t, ~dataId: dataId) => option<RecordProxy.t> = "get"
|
|
439
419
|
|
|
440
|
-
|
|
441
|
-
"Returns the _root_ `RecordProxy`, meaning the `RecordProxy` holding your top level fields."
|
|
442
|
-
)
|
|
420
|
+
/**Returns the _root_ `RecordProxy`, meaning the `RecordProxy` holding your top level fields.*/
|
|
443
421
|
@send
|
|
444
422
|
external getRoot: t => RecordProxy.t = "getRoot"
|
|
445
423
|
}
|
|
446
424
|
|
|
447
|
-
|
|
425
|
+
/**A missing field handler, which is a way of teaching Relay more about the relations in your schema, so it can fulfill more things from the cache. Read more [in this section of the Relay docs](https://relay.dev/docs/guided-tour/reusing-cached-data/filling-in-missing-data/).
|
|
448
426
|
|
|
449
|
-
Feed a list of missing field handlers into `Environment.make` if you want to use them
|
|
427
|
+
Feed a list of missing field handlers into `Environment.make` if you want to use them.*/
|
|
450
428
|
module MissingFieldHandler: {
|
|
451
|
-
@@
|
|
429
|
+
@@warning("-30")
|
|
452
430
|
|
|
453
|
-
|
|
454
|
-
"A missing field handler, which is a way of teaching Relay more about the relations in your schema, so it can fulfill more things from the cache. Read more [in this section of the Relay docs](https://relay.dev/docs/guided-tour/reusing-cached-data/filling-in-missing-data/)."
|
|
455
|
-
)
|
|
431
|
+
/**A missing field handler, which is a way of teaching Relay more about the relations in your schema, so it can fulfill more things from the cache. Read more [in this section of the Relay docs](https://relay.dev/docs/guided-tour/reusing-cached-data/filling-in-missing-data/).*/
|
|
456
432
|
type t
|
|
457
433
|
|
|
458
434
|
type normalizationArgumentWrapped = {kind: [#ListValue | #Literal | #ObjectValue | #Variable]}
|
|
@@ -491,9 +467,7 @@ module MissingFieldHandler: {
|
|
|
491
467
|
storageKey: Js.Nullable.t<string>,
|
|
492
468
|
}
|
|
493
469
|
|
|
494
|
-
|
|
495
|
-
"Make a `MissingFieldHandler.t` for scalar fields. Give this a handler function that returns `Js.null` (to indicate that data exists but is null), `Js.undefined` (to indicate data is still missing), or a scalar value (to indicate that the value exists even though it's not in the cache, and is the value you send back)."
|
|
496
|
-
)
|
|
470
|
+
/**Make a `MissingFieldHandler.t` for scalar fields. Give this a handler function that returns `Js.null` (to indicate that data exists but is null), `Js.undefined` (to indicate data is still missing), or a scalar value (to indicate that the value exists even though it's not in the cache, and is the value you send back).*/
|
|
497
471
|
let makeScalarMissingFieldHandler: (
|
|
498
472
|
(
|
|
499
473
|
normalizationScalarField,
|
|
@@ -513,9 +487,7 @@ module MissingFieldHandler: {
|
|
|
513
487
|
selections: array<Js.Json.t>,
|
|
514
488
|
}
|
|
515
489
|
|
|
516
|
-
|
|
517
|
-
"Make a `MissingFieldHandler.t` for linked fields (other objects/records). Give this a handler function that returns `Js.null` (to indicate that the link exists but the linked record is null), `Js.undefined` (to indicate data is still missing), or a `dataId` of the record that is linked at this field."
|
|
518
|
-
)
|
|
490
|
+
/**Make a `MissingFieldHandler.t` for linked fields (other objects/records). Give this a handler function that returns `Js.null` (to indicate that the link exists but the linked record is null), `Js.undefined` (to indicate data is still missing), or a `dataId` of the record that is linked at this field.*/
|
|
519
491
|
let makeLinkedMissingFieldHandler: (
|
|
520
492
|
(
|
|
521
493
|
normalizationLinkedField,
|
|
@@ -525,9 +497,7 @@ module MissingFieldHandler: {
|
|
|
525
497
|
) => Js.Nullable.t<dataId>
|
|
526
498
|
) => t
|
|
527
499
|
|
|
528
|
-
|
|
529
|
-
"Make a `MissingFieldHandler.t` for lists of linked fields (other objects/records). Give this a handler function that returns `Js.null` (to indicate that the link exists but the linked record is null), `Js.undefined` (to indicate data is still missing), or an array of `Js.Nullable.t<dataId>` where the `dataId`'s are the linked records/objects."
|
|
530
|
-
)
|
|
500
|
+
/**Make a `MissingFieldHandler.t` for lists of linked fields (other objects/records). Give this a handler function that returns `Js.null` (to indicate that the link exists but the linked record is null), `Js.undefined` (to indicate data is still missing), or an array of `Js.Nullable.t<dataId>` where the `dataId`'s are the linked records/objects.*/
|
|
531
501
|
let makePluralLinkedMissingFieldHandler: (
|
|
532
502
|
(
|
|
533
503
|
normalizationLinkedField,
|
|
@@ -538,13 +508,9 @@ module MissingFieldHandler: {
|
|
|
538
508
|
) => t
|
|
539
509
|
}
|
|
540
510
|
|
|
541
|
-
|
|
542
|
-
"Read the Relay docs section on [ConnectionHandler](https://relay.dev/docs/en/relay-store#connectionhandler)"
|
|
543
|
-
)
|
|
511
|
+
/**Read the Relay docs section on [ConnectionHandler](https://relay.dev/docs/en/relay-store#connectionhandler)*/
|
|
544
512
|
module ConnectionHandler: {
|
|
545
|
-
|
|
546
|
-
"For a `RecordProxy`, returns the `RecordProxy` that is at the connection config provided."
|
|
547
|
-
)
|
|
513
|
+
/**For a `RecordProxy`, returns the `RecordProxy` that is at the connection config provided.*/
|
|
548
514
|
@module("relay-runtime")
|
|
549
515
|
@scope("ConnectionHandler")
|
|
550
516
|
@return(nullable)
|
|
@@ -555,7 +521,7 @@ module ConnectionHandler: {
|
|
|
555
521
|
unit,
|
|
556
522
|
) => option<RecordProxy.t> = "getConnection"
|
|
557
523
|
|
|
558
|
-
|
|
524
|
+
/**Creates an edge for a particular connection.*/
|
|
559
525
|
@module("relay-runtime")
|
|
560
526
|
@scope("ConnectionHandler")
|
|
561
527
|
external createEdge: (
|
|
@@ -565,9 +531,7 @@ module ConnectionHandler: {
|
|
|
565
531
|
~edgeType: string,
|
|
566
532
|
) => RecordProxy.t = "createEdge"
|
|
567
533
|
|
|
568
|
-
|
|
569
|
-
"Inserts an edge into a connection _before_ the provided cursor. If no cursor is provided, it inserts the edge at the start of the connection list."
|
|
570
|
-
)
|
|
534
|
+
/**Inserts an edge into a connection _before_ the provided cursor. If no cursor is provided, it inserts the edge at the start of the connection list.*/
|
|
571
535
|
@module("relay-runtime")
|
|
572
536
|
@scope("ConnectionHandler")
|
|
573
537
|
external insertEdgeBefore: (
|
|
@@ -577,9 +541,7 @@ module ConnectionHandler: {
|
|
|
577
541
|
unit,
|
|
578
542
|
) => unit = "insertEdgeBefore"
|
|
579
543
|
|
|
580
|
-
|
|
581
|
-
"Inserts an edge into a connection _after_ the provided cursor. If no cursor is provided, it inserts the edge at the end of the connection list."
|
|
582
|
-
)
|
|
544
|
+
/**Inserts an edge into a connection _after_ the provided cursor. If no cursor is provided, it inserts the edge at the end of the connection list.*/
|
|
583
545
|
@module("relay-runtime")
|
|
584
546
|
@scope("ConnectionHandler")
|
|
585
547
|
external insertEdgeAfter: (
|
|
@@ -589,24 +551,18 @@ module ConnectionHandler: {
|
|
|
589
551
|
unit,
|
|
590
552
|
) => unit = "insertEdgeAfter"
|
|
591
553
|
|
|
592
|
-
|
|
593
|
-
"Deletes any edge from the connection where the node of the edge has the provided `dataId`. Please not that this _will not_ remove the actual node from the store. Use `RecordSourceSelectorProxy.delete` for that."
|
|
594
|
-
)
|
|
554
|
+
/**Deletes any edge from the connection where the node of the edge has the provided `dataId`. Please not that this _will not_ remove the actual node from the store. Use `RecordSourceSelectorProxy.delete` for that.*/
|
|
595
555
|
@module("relay-runtime")
|
|
596
556
|
@scope("ConnectionHandler")
|
|
597
557
|
external deleteNode: (~connection: RecordProxy.t, ~nodeId: dataId) => unit = "deleteNode"
|
|
598
558
|
|
|
599
|
-
|
|
600
|
-
"Constructs a `dataId` targeting a specific connection at a specific parent. Note that the generated module for every fragment with a `@connection` will have a `<moduleName>.Utils.connectionKey` representing the connection key of that particular `@connection`, that you should use with this."
|
|
601
|
-
)
|
|
559
|
+
/**Constructs a `dataId` targeting a specific connection at a specific parent. Note that the generated module for every fragment with a `@connection` will have a `<moduleName>.Utils.connectionKey` representing the connection key of that particular `@connection`, that you should use with this.*/
|
|
602
560
|
@module("relay-runtime")
|
|
603
561
|
@scope("ConnectionHandler")
|
|
604
562
|
external getConnectionID: (dataId, string, 'filters) => dataId = "getConnectionID"
|
|
605
563
|
}
|
|
606
564
|
|
|
607
|
-
|
|
608
|
-
"The cache config provided to the network layer. Relay won't do anything in particular with these, it's up to you to use them if you want inside of your `NetworkLayer`."
|
|
609
|
-
)
|
|
565
|
+
/**The cache config provided to the network layer. Relay won't do anything in particular with these, it's up to you to use them if you want inside of your `NetworkLayer`.*/
|
|
610
566
|
type cacheConfig = {
|
|
611
567
|
force: option<bool>,
|
|
612
568
|
poll: option<int>,
|
|
@@ -614,14 +570,12 @@ type cacheConfig = {
|
|
|
614
570
|
transactionId: option<string>,
|
|
615
571
|
}
|
|
616
572
|
|
|
617
|
-
|
|
618
|
-
"A Relay observable, used throughout Relay for delivering data, in particular when dealing with multiple payloads like with subscriptions or multipart responses like `@stream` or `@defer`."
|
|
619
|
-
)
|
|
573
|
+
/**A Relay observable, used throughout Relay for delivering data, in particular when dealing with multiple payloads like with subscriptions or multipart responses like `@stream` or `@defer`.*/
|
|
620
574
|
module Observable: {
|
|
621
|
-
|
|
575
|
+
/**The type representing the observable.*/
|
|
622
576
|
type t<'response>
|
|
623
577
|
|
|
624
|
-
|
|
578
|
+
/**This sink can be used to give the observable new data.*/
|
|
625
579
|
type sink<'response> = {
|
|
626
580
|
next: (. 'response) => unit,
|
|
627
581
|
error: (. Js.Exn.t) => unit,
|
|
@@ -629,16 +583,17 @@ module Observable: {
|
|
|
629
583
|
closed: bool,
|
|
630
584
|
}
|
|
631
585
|
|
|
632
|
-
|
|
586
|
+
/**A subscription for an observable, allowing you to unsubscribe if wanted.*/
|
|
633
587
|
type subscription = {
|
|
634
588
|
unsubscribe: unit => unit,
|
|
635
589
|
closed: bool,
|
|
636
590
|
}
|
|
637
591
|
|
|
638
|
-
|
|
592
|
+
/**An observer of the observable.*/
|
|
639
593
|
type observer<'response>
|
|
640
594
|
|
|
641
|
-
|
|
595
|
+
/**Create an observer.*/
|
|
596
|
+
@obj
|
|
642
597
|
external makeObserver: (
|
|
643
598
|
~start: @uncurry subscription => unit=?,
|
|
644
599
|
~next: @uncurry 'response => unit=?,
|
|
@@ -648,31 +603,26 @@ module Observable: {
|
|
|
648
603
|
unit,
|
|
649
604
|
) => observer<'response> = ""
|
|
650
605
|
|
|
651
|
-
|
|
652
|
-
"Create a new observable, getting fed an `Observable.sink` for interacting with the observable, and optionally returning a `Observable.subscription` if you have things you want to unsubscribe from as the observable closes."
|
|
653
|
-
)
|
|
606
|
+
/**Create a new observable, getting fed an `Observable.sink` for interacting with the observable, and optionally returning a `Observable.subscription` if you have things you want to unsubscribe from as the observable closes.*/
|
|
654
607
|
@module("relay-runtime")
|
|
655
608
|
@scope("Observable")
|
|
656
609
|
external make: (sink<'t> => option<subscription>) => t<'t> = "create"
|
|
657
610
|
|
|
658
|
-
|
|
611
|
+
/**Subscribe to the `Observable.t` using an observer.*/
|
|
612
|
+
@send
|
|
659
613
|
external subscribe: (t<'t>, observer<'t>) => subscription = "subscribe"
|
|
660
614
|
|
|
661
|
-
|
|
662
|
-
"Turns an `Observable` into a promise. _Beware_ that reading the response in the resulting promise is currently _not safe_ due to some internals of how ReScript Relay works. This will be resolved in the future."
|
|
663
|
-
)
|
|
615
|
+
/**Turns an `Observable` into a promise. _Beware_ that reading the response in the resulting promise is currently _not safe_ due to some internals of how ReScript Relay works. This will be resolved in the future.*/
|
|
664
616
|
@send
|
|
665
617
|
external toPromise: t<'t> => Js.Promise.t<'t> = "toPromise"
|
|
666
618
|
}
|
|
667
619
|
|
|
668
|
-
|
|
620
|
+
/**Represents the network layer.*/
|
|
669
621
|
module Network: {
|
|
670
|
-
|
|
622
|
+
/**The type representing an instantiated `NetworkLayer`.*/
|
|
671
623
|
type t
|
|
672
624
|
|
|
673
|
-
|
|
674
|
-
"The operation fed to the `NetworkLayer` when Relay wants to make a request. Please note that if you're using persisted queries, `id` will exist but `text` won't, and vice versa when not using persisted queries."
|
|
675
|
-
)
|
|
625
|
+
/**The operation fed to the `NetworkLayer` when Relay wants to make a request. Please note that if you're using persisted queries, `id` will exist but `text` won't, and vice versa when not using persisted queries.*/
|
|
676
626
|
type operation = {
|
|
677
627
|
id: string,
|
|
678
628
|
text: string,
|
|
@@ -680,12 +630,10 @@ module Network: {
|
|
|
680
630
|
operationKind: string,
|
|
681
631
|
}
|
|
682
632
|
|
|
683
|
-
|
|
633
|
+
/**The shape of the function Relay expects for creating a subscription.*/
|
|
684
634
|
type subscribeFn = (operation, Js.Json.t, cacheConfig) => Observable.t<Js.Json.t>
|
|
685
635
|
|
|
686
|
-
|
|
687
|
-
"The shape of the function responsible for fetching data if you want to return a promise rather than an `Observable`."
|
|
688
|
-
)
|
|
636
|
+
/**The shape of the function responsible for fetching data if you want to return a promise rather than an `Observable`.*/
|
|
689
637
|
type fetchFunctionPromise = (
|
|
690
638
|
operation,
|
|
691
639
|
Js.Json.t,
|
|
@@ -693,9 +641,7 @@ module Network: {
|
|
|
693
641
|
Js.Nullable.t<uploadables>,
|
|
694
642
|
) => Js.Promise.t<Js.Json.t>
|
|
695
643
|
|
|
696
|
-
|
|
697
|
-
"The shape of the function responsible for fetching data if you want to return an `Observable`."
|
|
698
|
-
)
|
|
644
|
+
/**The shape of the function responsible for fetching data if you want to return an `Observable`.*/
|
|
699
645
|
type fetchFunctionObservable = (
|
|
700
646
|
operation,
|
|
701
647
|
Js.Json.t,
|
|
@@ -703,7 +649,7 @@ module Network: {
|
|
|
703
649
|
Js.Nullable.t<uploadables>,
|
|
704
650
|
) => Observable.t<Js.Json.t>
|
|
705
651
|
|
|
706
|
-
|
|
652
|
+
/**Create a new `NetworkLayer` using a fetch function that returns a promise.*/
|
|
707
653
|
@module("relay-runtime")
|
|
708
654
|
@scope("Network")
|
|
709
655
|
external makePromiseBased: (
|
|
@@ -712,7 +658,7 @@ module Network: {
|
|
|
712
658
|
unit,
|
|
713
659
|
) => t = "create"
|
|
714
660
|
|
|
715
|
-
|
|
661
|
+
/**Create a new `NetworkLayer` using a fetch function that returns an `Observable`.*/
|
|
716
662
|
@module("relay-runtime")
|
|
717
663
|
@scope("Network")
|
|
718
664
|
external makeObservableBased: (
|
|
@@ -722,33 +668,27 @@ module Network: {
|
|
|
722
668
|
) => t = "create"
|
|
723
669
|
}
|
|
724
670
|
|
|
725
|
-
|
|
726
|
-
"RecordSource is the source of records used by the store. Can be initiated with or without prior records; eg. hydrating the store with prior data."
|
|
727
|
-
)
|
|
671
|
+
/**RecordSource is the source of records used by the store. Can be initiated with or without prior records; eg. hydrating the store with prior data.*/
|
|
728
672
|
module RecordSource: {
|
|
729
|
-
|
|
673
|
+
/**The type representing an instantiated `RecordSource`.*/
|
|
730
674
|
type t
|
|
731
675
|
|
|
732
|
-
|
|
733
|
-
"Create a new `RecordSource`. Here's where you pass an existing `recordSourceRecords` if you have existing records you want to hydrate the store with, when doing SSR or similar."
|
|
734
|
-
)
|
|
676
|
+
/**Create a new `RecordSource`. Here's where you pass an existing `recordSourceRecords` if you have existing records you want to hydrate the store with, when doing SSR or similar.*/
|
|
735
677
|
@module("relay-runtime")
|
|
736
678
|
@new
|
|
737
679
|
external make: (~records: recordSourceRecords=?, unit) => t = "RecordSource"
|
|
738
680
|
|
|
739
|
-
|
|
740
|
-
"Serializes the `RecordSource` into `recordSourceRecords` that you can use to rehydrate another store. Typically used for SSR."
|
|
741
|
-
)
|
|
681
|
+
/**Serializes the `RecordSource` into `recordSourceRecords` that you can use to rehydrate another store. Typically used for SSR.*/
|
|
742
682
|
@send
|
|
743
683
|
external toJSON: t => recordSourceRecords = "toJSON"
|
|
744
684
|
}
|
|
745
685
|
|
|
746
|
-
|
|
686
|
+
/**The actual store module, with configuration for the store.*/
|
|
747
687
|
module Store: {
|
|
748
|
-
|
|
688
|
+
/**The type representing an instantiated `Store`.*/
|
|
749
689
|
type t
|
|
750
690
|
|
|
751
|
-
|
|
691
|
+
/**Creates a new `Store`.*/
|
|
752
692
|
let make: (
|
|
753
693
|
~source: RecordSource.t,
|
|
754
694
|
~gcReleaseBufferSize: /* `gcReleaseBufferSize` controls how many queries are allowed to be cached by default. Increase this to increase the size of the cache. */
|
|
@@ -757,57 +697,48 @@ module Store: {
|
|
|
757
697
|
unit,
|
|
758
698
|
) => t
|
|
759
699
|
|
|
760
|
-
|
|
700
|
+
/**Gets the `RecordSource` for this `Store`.*/
|
|
701
|
+
@send
|
|
761
702
|
external getSource: t => RecordSource.t = "getSource"
|
|
762
703
|
|
|
763
|
-
|
|
764
|
-
"Publishes _new_ records to this store. This is useful in particular with frameworks like Next.js where routes could preload data needed and then serialize that (using `RecordSource.toJSON`) and send it over the wire, but you already have a store instantiated client side. This will then allow you to publish those records into your existing store."
|
|
765
|
-
)
|
|
704
|
+
/**Publishes _new_ records to this store. This is useful in particular with frameworks like Next.js where routes could preload data needed and then serialize that (using `RecordSource.toJSON`) and send it over the wire, but you already have a store instantiated client side. This will then allow you to publish those records into your existing store.*/
|
|
766
705
|
@send
|
|
767
706
|
external publish: (t, RecordSource.t) => unit = "publish"
|
|
768
707
|
|
|
769
|
-
|
|
770
|
-
"Informes the store to stop its normal garbage collection processes. This prevents data being lost between calling relay's `fetchQuery` any serialization process (eg: toJSON)"
|
|
771
|
-
)
|
|
708
|
+
/**Informes the store to stop its normal garbage collection processes. This prevents data being lost between calling relay's `fetchQuery` any serialization process (eg: toJSON)*/
|
|
772
709
|
@send
|
|
773
710
|
external holdGC: t => unit = "holdGC"
|
|
774
711
|
}
|
|
775
712
|
|
|
776
|
-
|
|
713
|
+
/**Internal, do not use.*/
|
|
777
714
|
type operationDescriptor
|
|
778
715
|
|
|
779
|
-
|
|
780
|
-
"A disposable is something you can use to dispose of something when you don't use/need it anymore."
|
|
781
|
-
)
|
|
716
|
+
/**A disposable is something you can use to dispose of something when you don't use/need it anymore.*/
|
|
782
717
|
module Disposable: {
|
|
783
|
-
|
|
718
|
+
/**The type representing a `Disposable`.*/
|
|
784
719
|
type t
|
|
785
720
|
|
|
786
|
-
|
|
721
|
+
/**Dispose the `Disposable`.*/
|
|
722
|
+
@send
|
|
723
|
+
external dispose: t => unit = "dispose"
|
|
787
724
|
|
|
788
|
-
|
|
725
|
+
/**Ignore this disposable.*/ external ignore: t => unit = "%ignore"
|
|
789
726
|
}
|
|
790
727
|
|
|
791
|
-
@
|
|
792
|
-
"A required field logger, which gets called when a field annotated with the @required directive was missing from the response"
|
|
793
|
-
)
|
|
728
|
+
/**A required field logger, which gets called when a field annotated with the @required directive was missing from the response*/
|
|
794
729
|
module RequiredFieldLogger: {
|
|
795
730
|
type kind = [#"missing_field.log" | #"missing_field.throw"]
|
|
796
731
|
|
|
797
|
-
@
|
|
798
|
-
"A required field logger, which gets called when a field annotated with the @required directive was missing from the response"
|
|
799
|
-
)
|
|
732
|
+
/**A required field logger, which gets called when a field annotated with the @required directive was missing from the response*/
|
|
800
733
|
type t = (~kind: kind, ~owner: string, ~fieldPath: string) => unit
|
|
801
734
|
}
|
|
802
735
|
|
|
803
|
-
|
|
804
|
-
"Module representing the environment, which you'll need to use and pass to various functions. Takes a few configuration options like store and network layer."
|
|
805
|
-
)
|
|
736
|
+
/**Module representing the environment, which you'll need to use and pass to various functions. Takes a few configuration options like store and network layer.*/
|
|
806
737
|
module Environment: {
|
|
807
|
-
|
|
738
|
+
/**The type representing an instantiated `Environment`.*/
|
|
808
739
|
type t
|
|
809
740
|
|
|
810
|
-
|
|
741
|
+
/**Create a new `Environment`.*/
|
|
811
742
|
let make: (
|
|
812
743
|
~network: Network.t,
|
|
813
744
|
~store: Store.t,
|
|
@@ -822,91 +753,82 @@ module Environment: {
|
|
|
822
753
|
unit,
|
|
823
754
|
) => t
|
|
824
755
|
|
|
825
|
-
|
|
756
|
+
/**Get the `Store` for this `Environment`.*/
|
|
757
|
+
@send
|
|
826
758
|
external getStore: t => Store.t = "getStore"
|
|
827
759
|
|
|
828
|
-
|
|
760
|
+
/**Given an `operationDescriptor`, commits the corresponding payload.*/
|
|
761
|
+
@send
|
|
829
762
|
external commitPayload: (t, operationDescriptor, 'payload) => unit = "commitPayload"
|
|
830
763
|
|
|
831
|
-
|
|
832
|
-
You should use the generated `Query.retain` function on your queries instead of using this directly
|
|
764
|
+
/**Given an `operationDescriptor`, retains the corresponding operation so any data referenced by it isn't garbage collected.
|
|
765
|
+
You should use the generated `Query.retain` function on your queries instead of using this directly.*/
|
|
833
766
|
@send
|
|
834
767
|
external retain: (t, operationDescriptor) => Disposable.t = "retain"
|
|
835
768
|
}
|
|
836
769
|
|
|
837
|
-
|
|
770
|
+
/**fetchPolicy controls how you want Relay to resolve your data.*/
|
|
838
771
|
type fetchPolicy =
|
|
839
772
|
| StoreOnly /* Resolve only from the store */
|
|
840
773
|
| StoreOrNetwork /* Resolve from the store if all data is there, otherwise make a network request */
|
|
841
774
|
| StoreAndNetwork /* Like StoreOrNetwork, but always make a request regardless of if the data was there initially or not */
|
|
842
775
|
| NetworkOnly /* Always make a request, regardless of what's in the store */
|
|
843
776
|
|
|
844
|
-
|
|
777
|
+
/**Internal, do not use.*/
|
|
845
778
|
let mapFetchPolicy: option<fetchPolicy> => option<string>
|
|
846
779
|
|
|
847
|
-
|
|
848
|
-
"The fetch policies allowed for fetching a query outside of React's render (as in `Query.fetch`)."
|
|
849
|
-
)
|
|
780
|
+
/**The fetch policies allowed for fetching a query outside of React's render (as in `Query.fetch`).*/
|
|
850
781
|
type fetchQueryFetchPolicy =
|
|
851
782
|
| NetworkOnly
|
|
852
783
|
| StoreOrNetwork
|
|
853
784
|
|
|
854
|
-
|
|
785
|
+
/**Internal, do not use.*/
|
|
855
786
|
let mapFetchQueryFetchPolicy: option<fetchQueryFetchPolicy> => option<string>
|
|
856
787
|
|
|
857
|
-
|
|
788
|
+
/**An error from a mutation.*/
|
|
858
789
|
type mutationError = {message: string}
|
|
859
790
|
|
|
860
|
-
|
|
791
|
+
/**Context provider for the Relay environment.*/
|
|
861
792
|
module Context: {
|
|
862
|
-
|
|
793
|
+
/**Type representing the context.*/
|
|
863
794
|
type t
|
|
864
795
|
|
|
865
|
-
|
|
796
|
+
/**The expected shape of the context.*/
|
|
866
797
|
type contextShape = {"environment": Environment.t}
|
|
867
798
|
|
|
868
|
-
|
|
799
|
+
/**The actual React context coming from Relay.*/
|
|
800
|
+
@module("react-relay")
|
|
869
801
|
external context: React.Context.t<option<contextShape>> = "ReactRelayContext"
|
|
870
802
|
|
|
871
|
-
|
|
872
|
-
"The context provider you wrap your app in and pass your `Environment` for Relay to work."
|
|
873
|
-
)
|
|
803
|
+
/**The context provider you wrap your app in and pass your `Environment` for Relay to work.*/
|
|
874
804
|
module Provider: {
|
|
875
|
-
|
|
876
|
-
"The React component you wrap your app in and pass your `Environment` for Relay to work."
|
|
877
|
-
)
|
|
805
|
+
/**The React component you wrap your app in and pass your `Environment` for Relay to work.*/
|
|
878
806
|
@react.component
|
|
879
807
|
let make: (~environment: Environment.t, ~children: React.element) => React.element
|
|
880
808
|
}
|
|
881
809
|
}
|
|
882
810
|
|
|
883
|
-
|
|
884
|
-
"An exception saying that the environment could not be found in the context. Means you forgot to wrap your app in `<RescriptRelay.Context.Provider environment=RelayEnv.environment>`"
|
|
885
|
-
)
|
|
811
|
+
/**An exception saying that the environment could not be found in the context. Means you forgot to wrap your app in `<RescriptRelay.Context.Provider environment=RelayEnv.environment>`*/
|
|
886
812
|
exception EnvironmentNotFoundInContext
|
|
887
813
|
|
|
888
|
-
|
|
814
|
+
/**Hook for getting the current environment from context.*/
|
|
889
815
|
let useEnvironmentFromContext: unit => Environment.t
|
|
890
816
|
|
|
891
|
-
|
|
892
|
-
exception Mutation_failed(array<mutationError>)
|
|
817
|
+
/**An exception detailing that a mutation failed.*/ exception Mutation_failed(array<mutationError>)
|
|
893
818
|
|
|
894
|
-
|
|
819
|
+
/**A way of committing a local update to the store.*/
|
|
820
|
+
@module("relay-runtime")
|
|
895
821
|
external commitLocalUpdate: (
|
|
896
822
|
~environment: Environment.t,
|
|
897
823
|
~updater: RecordSourceSelectorProxy.t => unit,
|
|
898
824
|
) => unit = "commitLocalUpdate"
|
|
899
825
|
|
|
900
|
-
|
|
901
|
-
"Allows you to subscribe to when a record, connection, or even the store itself is invalidated, and then react to that."
|
|
902
|
-
)
|
|
826
|
+
/**Allows you to subscribe to when a record, connection, or even the store itself is invalidated, and then react to that.*/
|
|
903
827
|
@module("react-relay")
|
|
904
828
|
external useSubscribeToInvalidationState: (array<dataId>, unit => unit) => Disposable.t =
|
|
905
829
|
"useSubscribeToInvalidationState"
|
|
906
830
|
|
|
907
|
-
|
|
908
|
-
"Options valid when fetching a query outside of React's render method (like when using `Query.fetch`)."
|
|
909
|
-
)
|
|
831
|
+
/**Options valid when fetching a query outside of React's render method (like when using `Query.fetch`).*/
|
|
910
832
|
type fetchQueryOptions = {
|
|
911
833
|
networkCacheConfig: option<cacheConfig>,
|
|
912
834
|
fetchPolicy: option<string>,
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/**Tries to return a record from a nested path of linked records.*/
|
|
2
2
|
let resolveNestedRecord: (
|
|
3
3
|
~rootRecord: option<RescriptRelay.RecordProxy.t>,
|
|
4
4
|
~path: list<string>,
|
|
5
5
|
) => option<RescriptRelay.RecordProxy.t>
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
"Tries to return a record from a nested path of linked records, starting from the root. "
|
|
9
|
-
)
|
|
7
|
+
/**Tries to return a record from a nested path of linked records, starting from the root.*/
|
|
10
8
|
let resolveNestedRecordFromRoot: (
|
|
11
9
|
~store: RescriptRelay.RecordSourceSelectorProxy.t,
|
|
12
10
|
~path: list<string>,
|
|
13
11
|
) => option<RescriptRelay.RecordProxy.t>
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
/**Helpers for handling connections.*/
|
|
16
14
|
type insertAt =
|
|
17
15
|
| Start
|
|
18
16
|
| End
|