rescript-relay 2.0.0 → 3.0.0-alpha.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/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # master
2
2
 
3
+ # **Version 3**
4
+
5
+ # 3.0.0-alpha.1
6
+
7
+ Below is a series of releases for version 3 of RescriptRelay, which contain a large amount of breaking changes. The releases are cut up with a few breaking changes for each, to make them slightly less hard to migrate to. You're encouraged to start from the bottom and work your way up through the versions.
8
+
9
+ Dedicated tooling for migrating is coming, as well as docs.
10
+
11
+ # 0.0.0-version-3-8b552902
12
+
13
+ ## Breaking changes
14
+
15
+ - Unions are now represented as regular variants. Commit showing how this is migrated to in the tests: https://github.com/zth/rescript-relay/commit/3b5df51b80a0e1222b376fcfc730bb5dd0de099a
16
+
17
+ # 0.0.0-version-3-3504d777
18
+
19
+ ## Breaking changes
20
+
21
+ - All trailing unit arguments are removed. Commit showing how this is migrated to in the tests: https://github.com/zth/rescript-relay/commit/2a16791268afb29d106362d0cf17915f69d5b4ff
22
+
23
+ # 0.0.0-version-3-aeebeaab
24
+
25
+ ## Breaking changes
26
+
27
+ - Object maker functions are removed, and leverage optional fields for all variables/input objects. Also a large change, tooling upcoming. Commit showing how this is migrated to in the tests: https://github.com/zth/rescript-relay/commit/fd6b07a1b26620c91e5de61f930235c35517da6a
28
+
29
+ # 0.0.0-version-3-89bccc22
30
+
31
+ ## Breaking changes
32
+
33
+ - Remove "top level node field" transform. Previously, a single selection on the top level `node` field (like `node(id: $id) { ... on User { id, name }}`) would skip the union mechanism and automatically collapse the generated types to `option<user>`. This has now changed and the top level node field behaves just like any union. Commit showing how this is migrated to in the tests: https://github.com/zth/rescript-relay/commit/9ce73196794dbc6eba435414fcff708e7c53df78
34
+ - Enums are now (unboxed) regular variants rather than polyvariants. This is a large change, but we're going to provide some tools for easing the transition. Commit showing how this is migrated to in the tests: https://github.com/zth/rescript-relay/commit/9da425a3e65ce3e9403168af421522028424a4f0
35
+
3
36
  # 2.0.0
4
37
 
5
38
  RescriptRelay `2.0.0` is here! This isn't a large release really, but it's a major release just because it relies on functionality from ReScript `v11`. Meaning the lower bound of the required ReScript version is `>=11.0.0-beta.2`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rescript-relay",
3
- "version": "2.0.0",
3
+ "version": "3.0.0-alpha.1",
4
4
  "main": "src/RescriptRelay.res",
5
5
  "license": "MIT",
6
6
  "author": "Gabriel Nordeborn",
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -4,12 +4,12 @@ external useDeferredValue: 'value => 'value = "useDeferredValue"
4
4
  @module("react")
5
5
  external useTransitionWithOptions: unit => (
6
6
  bool,
7
- (. unit => unit, option<{"name": option<string>}>) => unit,
7
+ (unit => unit, option<{"name": option<string>}>) => unit,
8
8
  ) = "useTransition"
9
9
 
10
10
  let useTransition = () => {
11
11
  let (isPending, startTransition) = useTransitionWithOptions()
12
- (isPending, React.useMemo1(() => cb => startTransition(. cb, None), [startTransition]))
12
+ (isPending, React.useMemo1(() => cb => startTransition(cb, None), [startTransition]))
13
13
  }
14
14
 
15
15
  module SuspenseList = {
@@ -4,7 +4,7 @@ external useDeferredValue: 'value => 'value = "useDeferredValue"
4
4
  @module("react")
5
5
  external useTransitionWithOptions: unit => (
6
6
  bool,
7
- (. unit => unit, option<{"name": option<string>}>) => unit,
7
+ (unit => unit, option<{"name": option<string>}>) => unit,
8
8
  ) = "useTransition"
9
9
 
10
10
  let useTransition: unit => (bool, (unit => unit) => unit)
@@ -27,7 +27,7 @@ function optArrayOfNullableToOptArrayOfOpt(x) {
27
27
 
28
28
  }
29
29
 
30
- function getLinkedRecords(t, name, $$arguments, param) {
30
+ function getLinkedRecords(t, name, $$arguments) {
31
31
  return optArrayOfNullableToOptArrayOfOpt(Caml_option.nullable_to_opt(t.getLinkedRecords(name, $$arguments)));
32
32
  }
33
33
 
@@ -118,7 +118,7 @@ var Network = {};
118
118
 
119
119
  var RecordSource = {};
120
120
 
121
- function make(source, gcReleaseBufferSize, queryCacheExpirationTime, param) {
121
+ function make(source, gcReleaseBufferSize, queryCacheExpirationTime) {
122
122
  return new RelayRuntime.Store(source, {
123
123
  gcReleaseBufferSize: gcReleaseBufferSize,
124
124
  queryCacheExpirationTime: queryCacheExpirationTime
@@ -135,26 +135,16 @@ function toJs(f) {
135
135
  };
136
136
  }
137
137
 
138
- function make$1(network, store, getDataID, treatMissingFieldsAsNull, missingFieldHandlers, requiredFieldLogger, isServer, param) {
139
- var tmp = {
140
- network: network,
141
- store: store,
142
- missingFieldHandlers: missingFieldHandlers !== undefined ? Belt_Array.concat(missingFieldHandlers, [nodeInterfaceMissingFieldHandler]) : [nodeInterfaceMissingFieldHandler]
143
- };
144
- if (getDataID !== undefined) {
145
- tmp.getDataID = Caml_option.valFromOption(getDataID);
146
- }
147
- if (treatMissingFieldsAsNull !== undefined) {
148
- tmp.treatMissingFieldsAsNull = Caml_option.valFromOption(treatMissingFieldsAsNull);
149
- }
150
- var tmp$1 = Belt_Option.map(requiredFieldLogger, toJs);
151
- if (tmp$1 !== undefined) {
152
- tmp.requiredFieldLogger = Caml_option.valFromOption(tmp$1);
153
- }
154
- if (isServer !== undefined) {
155
- tmp.isServer = Caml_option.valFromOption(isServer);
156
- }
157
- return new RelayRuntime.Environment(tmp);
138
+ function make$1(network, store, getDataID, treatMissingFieldsAsNull, missingFieldHandlers, requiredFieldLogger, isServer) {
139
+ return new RelayRuntime.Environment({
140
+ network: network,
141
+ store: store,
142
+ getDataID: getDataID,
143
+ treatMissingFieldsAsNull: treatMissingFieldsAsNull,
144
+ missingFieldHandlers: missingFieldHandlers !== undefined ? Belt_Array.concat(missingFieldHandlers, [nodeInterfaceMissingFieldHandler]) : [nodeInterfaceMissingFieldHandler],
145
+ requiredFieldLogger: Belt_Option.map(requiredFieldLogger, toJs),
146
+ isServer: isServer
147
+ });
158
148
  }
159
149
 
160
150
  var Environment = {
@@ -193,7 +183,7 @@ function useEnvironmentFromContext() {
193
183
  }
194
184
 
195
185
  function MakeLoadQuery(C) {
196
- var load = function (environment, variables, fetchPolicy, fetchKey, networkCacheConfig, param) {
186
+ var load = function (environment, variables, fetchPolicy, fetchKey, networkCacheConfig) {
197
187
  return ReactRelay.loadQuery(environment, C.query, C.convertVariables(variables), {
198
188
  fetchKey: fetchKey,
199
189
  fetchPolicy: fetchPolicy,
@@ -21,7 +21,7 @@ external makeUploadables: Js.Dict.t<'file> => uploadables = "%identity"
21
21
  external unwrapUploadables: uploadables => Js.Dict.t<'file> = "%identity"
22
22
 
23
23
  @module("relay-runtime")
24
- external generateClientID: (~dataId: dataId, ~storageKey: string, ~index: int=?, unit) => dataId =
24
+ external generateClientID: (~dataId: dataId, ~storageKey: string, ~index: int=?) => dataId =
25
25
  "generateClientID"
26
26
 
27
27
  @module("relay-runtime")
@@ -93,14 +93,14 @@ module RecordProxy = {
93
93
  @send external getDataId: t => dataId = "getDataID"
94
94
 
95
95
  @send @return(nullable)
96
- external getLinkedRecord: (t, ~name: string, ~arguments: arguments=?, unit) => option<t> =
96
+ external getLinkedRecord: (t, ~name: string, ~arguments: arguments=?) => option<t> =
97
97
  "getLinkedRecord"
98
98
 
99
99
  @send @return(nullable)
100
100
  external getLinkedRecords: (t, string, option<arguments>) => option<array<Js.Nullable.t<t>>> =
101
101
  "getLinkedRecords"
102
102
 
103
- let getLinkedRecords = (t, ~name, ~arguments=?, ()): option<array<option<t>>> =>
103
+ let getLinkedRecords = (t, ~name, ~arguments=?): option<array<option<t>>> =>
104
104
  getLinkedRecords(t, name, arguments)->optArrayOfNullableToOptArrayOfOpt
105
105
 
106
106
  @send
@@ -109,13 +109,12 @@ module RecordProxy = {
109
109
  ~name: string,
110
110
  ~typeName: string,
111
111
  ~arguments: arguments=?,
112
- unit,
113
112
  ) => t = "getOrCreateLinkedRecord"
114
113
 
115
114
  @send external getType: t => string = "getType"
116
115
 
117
116
  @send @return(nullable)
118
- external getValueString: (t, ~name: string, ~arguments: arguments=?, unit) => option<string> =
117
+ external getValueString: (t, ~name: string, ~arguments: arguments=?) => option<string> =
119
118
  "getValue"
120
119
 
121
120
  @send @return(nullable)
@@ -123,47 +122,40 @@ module RecordProxy = {
123
122
  t,
124
123
  ~name: string,
125
124
  ~arguments: arguments=?,
126
- unit,
127
125
  ) => option<array<option<string>>> = "getValue"
128
126
 
129
127
  @send @return(nullable)
130
- external getValueInt: (t, ~name: string, ~arguments: arguments=?, unit) => option<int> =
131
- "getValue"
128
+ external getValueInt: (t, ~name: string, ~arguments: arguments=?) => option<int> = "getValue"
132
129
 
133
130
  @send @return(nullable)
134
131
  external getValueIntArray: (
135
132
  t,
136
133
  ~name: string,
137
134
  ~arguments: arguments=?,
138
- unit,
139
135
  ) => option<array<option<int>>> = "getValue"
140
136
 
141
137
  @send @return(nullable)
142
- external getValueFloat: (t, ~name: string, ~arguments: arguments=?, unit) => option<float> =
143
- "getValue"
138
+ external getValueFloat: (t, ~name: string, ~arguments: arguments=?) => option<float> = "getValue"
144
139
 
145
140
  @send @return(nullable)
146
141
  external getValueFloatArray: (
147
142
  t,
148
143
  ~name: string,
149
144
  ~arguments: arguments=?,
150
- unit,
151
145
  ) => option<array<option<float>>> = "getValue"
152
146
 
153
147
  @send @return(nullable)
154
- external getValueBool: (t, ~name: string, ~arguments: arguments=?, unit) => option<bool> =
155
- "getValue"
148
+ external getValueBool: (t, ~name: string, ~arguments: arguments=?) => option<bool> = "getValue"
156
149
 
157
150
  @send @return(nullable)
158
151
  external getValueBoolArray: (
159
152
  t,
160
153
  ~name: string,
161
154
  ~arguments: arguments=?,
162
- unit,
163
155
  ) => option<array<option<bool>>> = "getValue"
164
156
 
165
157
  @send
166
- external setLinkedRecord: (t, ~record: t, ~name: string, ~arguments: arguments=?, unit) => t =
158
+ external setLinkedRecord: (t, ~record: t, ~name: string, ~arguments: arguments=?) => t =
167
159
  "setLinkedRecord"
168
160
 
169
161
  // `setLinkedRecord` can't be used for "deleting" linked record fields.
@@ -176,7 +168,6 @@ module RecordProxy = {
176
168
  @as(json`undefined`) _,
177
169
  ~name: string,
178
170
  ~arguments: arguments=?,
179
- unit,
180
171
  ) => t = "setValue"
181
172
 
182
173
  @send
@@ -185,7 +176,6 @@ module RecordProxy = {
185
176
  @as(json`null`) _,
186
177
  ~name: string,
187
178
  ~arguments: arguments=?,
188
- unit,
189
179
  ) => t = "setValue"
190
180
 
191
181
  @send
@@ -194,7 +184,6 @@ module RecordProxy = {
194
184
  ~records: array<option<t>>,
195
185
  ~name: string,
196
186
  ~arguments: arguments=?,
197
- unit,
198
187
  ) => t = "setLinkedRecords"
199
188
 
200
189
  // `setLinkedRecords` can't be used for "deleting" linked records.
@@ -207,7 +196,6 @@ module RecordProxy = {
207
196
  @as(json`undefined`) _,
208
197
  ~name: string,
209
198
  ~arguments: arguments=?,
210
- unit,
211
199
  ) => t = "setValue"
212
200
 
213
201
  @send
@@ -216,7 +204,6 @@ module RecordProxy = {
216
204
  @as(json`null`) _,
217
205
  ~name: string,
218
206
  ~arguments: arguments=?,
219
- unit,
220
207
  ) => t = "setValue"
221
208
 
222
209
  @send
@@ -225,20 +212,14 @@ module RecordProxy = {
225
212
  @as(json`undefined`) _,
226
213
  ~name: string,
227
214
  ~arguments: arguments=?,
228
- unit,
229
215
  ) => t = "setValue"
230
216
 
231
217
  @send
232
- external setValueToNull: (
233
- t,
234
- @as(json`null`) _,
235
- ~name: string,
236
- ~arguments: arguments=?,
237
- unit,
238
- ) => t = "setValue"
218
+ external setValueToNull: (t, @as(json`null`) _, ~name: string, ~arguments: arguments=?) => t =
219
+ "setValue"
239
220
 
240
221
  @send
241
- external setValueString: (t, ~value: string, ~name: string, ~arguments: arguments=?, unit) => t =
222
+ external setValueString: (t, ~value: string, ~name: string, ~arguments: arguments=?) => t =
242
223
  "setValue"
243
224
 
244
225
  @send
@@ -247,24 +228,17 @@ module RecordProxy = {
247
228
  ~value: array<string>,
248
229
  ~name: string,
249
230
  ~arguments: arguments=?,
250
- unit,
251
231
  ) => t = "setValue"
252
232
 
253
233
  @send
254
- external setValueInt: (t, ~value: int, ~name: string, ~arguments: arguments=?, unit) => t =
255
- "setValue"
234
+ external setValueInt: (t, ~value: int, ~name: string, ~arguments: arguments=?) => t = "setValue"
256
235
 
257
236
  @send
258
- external setValueIntArray: (
259
- t,
260
- ~value: array<int>,
261
- ~name: string,
262
- ~arguments: arguments=?,
263
- unit,
264
- ) => t = "setValue"
237
+ external setValueIntArray: (t, ~value: array<int>, ~name: string, ~arguments: arguments=?) => t =
238
+ "setValue"
265
239
 
266
240
  @send
267
- external setValueFloat: (t, ~value: float, ~name: string, ~arguments: arguments=?, unit) => t =
241
+ external setValueFloat: (t, ~value: float, ~name: string, ~arguments: arguments=?) => t =
268
242
  "setValue"
269
243
 
270
244
  @send
@@ -273,12 +247,10 @@ module RecordProxy = {
273
247
  ~value: array<float>,
274
248
  ~name: string,
275
249
  ~arguments: arguments=?,
276
- unit,
277
250
  ) => t = "setValue"
278
251
 
279
252
  @send
280
- external setValueBool: (t, ~value: bool, ~name: string, ~arguments: arguments=?, unit) => t =
281
- "setValue"
253
+ external setValueBool: (t, ~value: bool, ~name: string, ~arguments: arguments=?) => t = "setValue"
282
254
 
283
255
  @send
284
256
  external setValueBoolArray: (
@@ -286,7 +258,6 @@ module RecordProxy = {
286
258
  ~value: array<bool>,
287
259
  ~name: string,
288
260
  ~arguments: arguments=?,
289
- unit,
290
261
  ) => t = "setValue"
291
262
 
292
263
  @send external invalidateRecord: t => unit = "invalidateRecord"
@@ -423,7 +394,6 @@ module ConnectionHandler = {
423
394
  ~record: RecordProxy.t,
424
395
  ~key: string,
425
396
  ~filters: arguments=?,
426
- unit,
427
397
  ) => option<RecordProxy.t> = "getConnection"
428
398
 
429
399
  @module("relay-runtime") @scope("ConnectionHandler")
@@ -439,7 +409,6 @@ module ConnectionHandler = {
439
409
  ~connection: RecordProxy.t,
440
410
  ~newEdge: RecordProxy.t,
441
411
  ~cursor: string=?,
442
- unit,
443
412
  ) => unit = "insertEdgeBefore"
444
413
 
445
414
  @module("relay-runtime") @scope("ConnectionHandler")
@@ -447,7 +416,6 @@ module ConnectionHandler = {
447
416
  ~connection: RecordProxy.t,
448
417
  ~newEdge: RecordProxy.t,
449
418
  ~cursor: string=?,
450
- unit,
451
419
  ) => unit = "insertEdgeAfter"
452
420
 
453
421
  @module("relay-runtime") @scope("ConnectionHandler")
@@ -497,7 +465,6 @@ module Observable = {
497
465
  ~error: Js.Exn.t => unit=?,
498
466
  ~complete: unit => unit=?,
499
467
  ~unsubscribe: subscription => unit=?,
500
- unit,
501
468
  ) => observer<'response> = ""
502
469
 
503
470
  @module("relay-runtime") @scope("Observable")
@@ -541,14 +508,12 @@ module Network = {
541
508
  external makePromiseBased: (
542
509
  ~fetchFunction: fetchFunctionPromise,
543
510
  ~subscriptionFunction: subscribeFn=?,
544
- unit,
545
511
  ) => t = "create"
546
512
 
547
513
  @module("relay-runtime") @scope("Network")
548
514
  external makeObservableBased: (
549
515
  ~observableFunction: fetchFunctionObservable,
550
516
  ~subscriptionFunction: subscribeFn=?,
551
- unit,
552
517
  ) => t = "create"
553
518
  }
554
519
 
@@ -556,7 +521,7 @@ module RecordSource = {
556
521
  type t
557
522
 
558
523
  @module("relay-runtime") @new
559
- external make: (~records: recordSourceRecords=?, unit) => t = "RecordSource"
524
+ external make: (~records: recordSourceRecords=?) => t = "RecordSource"
560
525
 
561
526
  @send external toJSON: t => recordSourceRecords = "toJSON"
562
527
  }
@@ -572,7 +537,7 @@ module Store = {
572
537
  @module("relay-runtime") @new
573
538
  external make: (RecordSource.t, storeConfig) => t = "Store"
574
539
 
575
- let make = (~source, ~gcReleaseBufferSize=?, ~queryCacheExpirationTime=?, ()) =>
540
+ let make = (~source, ~gcReleaseBufferSize=?, ~queryCacheExpirationTime=?) =>
576
541
  make(
577
542
  source,
578
543
  {
@@ -602,19 +567,14 @@ module RequiredFieldLogger = {
602
567
  module Environment = {
603
568
  type t
604
569
 
605
- @deriving(abstract)
606
570
  type environmentConfig<'a> = {
607
571
  network: Network.t,
608
572
  store: Store.t,
609
- @optional
610
- getDataID: (~nodeObj: 'a, ~typeName: string) => string,
611
- @optional
612
- treatMissingFieldsAsNull: bool,
573
+ getDataID?: (~nodeObj: 'a, ~typeName: string) => string,
574
+ treatMissingFieldsAsNull?: bool,
613
575
  missingFieldHandlers: array<MissingFieldHandler.t>,
614
- @optional
615
- requiredFieldLogger: RequiredFieldLogger.js,
616
- @optional
617
- isServer: bool,
576
+ requiredFieldLogger?: RequiredFieldLogger.js,
577
+ isServer?: bool,
618
578
  }
619
579
 
620
580
  @module("relay-runtime") @new
@@ -628,23 +588,19 @@ module Environment = {
628
588
  ~missingFieldHandlers=?,
629
589
  ~requiredFieldLogger=?,
630
590
  ~isServer=?,
631
- (),
632
591
  ) =>
633
- make(
634
- environmentConfig(
635
- ~network,
636
- ~store,
637
- ~getDataID?,
638
- ~treatMissingFieldsAsNull?,
639
- ~missingFieldHandlers=switch missingFieldHandlers {
640
- | Some(handlers) => handlers->Belt.Array.concat([nodeInterfaceMissingFieldHandler])
641
- | None => [nodeInterfaceMissingFieldHandler]
642
- },
643
- ~requiredFieldLogger=?requiredFieldLogger->Belt.Option.map(RequiredFieldLogger.toJs),
644
- ~isServer?,
645
- (),
646
- ),
647
- )
592
+ make({
593
+ network,
594
+ store,
595
+ ?getDataID,
596
+ ?treatMissingFieldsAsNull,
597
+ missingFieldHandlers: switch missingFieldHandlers {
598
+ | Some(handlers) => handlers->Belt.Array.concat([nodeInterfaceMissingFieldHandler])
599
+ | None => [nodeInterfaceMissingFieldHandler]
600
+ },
601
+ requiredFieldLogger: ?requiredFieldLogger->Belt.Option.map(RequiredFieldLogger.toJs),
602
+ ?isServer,
603
+ })
648
604
 
649
605
  @send external getStore: t => Store.t = "getStore"
650
606
  @send
@@ -721,14 +677,12 @@ module MakeLoadQuery = (C: MakeLoadQueryConfig) => {
721
677
  ~fetchPolicy: fetchPolicy=?,
722
678
  ~fetchKey: string=?,
723
679
  ~networkCacheConfig: cacheConfig=?,
724
- unit,
725
680
  ) => C.loadedQueryRef = (
726
681
  ~environment,
727
682
  ~variables,
728
683
  ~fetchPolicy=?,
729
684
  ~fetchKey=?,
730
685
  ~networkCacheConfig=?,
731
- (),
732
686
  ) =>
733
687
  loadQuery(
734
688
  environment,
@@ -755,7 +709,7 @@ module MakeLoadQuery = (C: MakeLoadQueryConfig) => {
755
709
  | None => resolve(Error())
756
710
  | Some(o) =>
757
711
  open Observable
758
- let _: subscription = o->subscribe(makeObserver(~complete=() => resolve(Ok()), ()))
712
+ let _: subscription = o->subscribe(makeObserver(~complete=() => resolve(Ok())))
759
713
  }
760
714
  })
761
715
  }