rescript-relay 3.0.0-rc.7 → 3.0.0-rc.8

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
@@ -6,6 +6,12 @@
6
6
 
7
7
  # Unreleased
8
8
 
9
+ # 3.0.0-rc.8
10
+
11
+ - Initial implementation of more advanced Relay resolvers. More to come. https://github.com/zth/rescript-relay/pull/515
12
+ - BREAKING: Relay resolvers using fragments should now be exported with a function name that matches the field name for the resolver, and not `default` like before.
13
+ - BREAKING: Client extension enums are now (correctly) not emitted with a `FutureAddedValue` case.
14
+
9
15
  # 3.0.0-rc.7
10
16
 
11
17
  - Fix for not deleting removed artifacts.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rescript-relay",
3
- "version": "3.0.0-rc.7",
3
+ "version": "3.0.0-rc.8",
4
4
  "main": "src/RescriptRelay.res",
5
5
  "license": "MIT",
6
6
  "author": "Gabriel Nordeborn",
package/ppx-linux CHANGED
Binary file
package/ppx-macos-arm64 CHANGED
Binary file
package/ppx-macos-latest CHANGED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -8,6 +8,10 @@ var Caml_option = require("rescript/lib/js/caml_option.js");
8
8
  var ReactRelay = require("react-relay");
9
9
  var RelayRuntime = require("relay-runtime");
10
10
  var Caml_exceptions = require("rescript/lib/js/caml_exceptions.js");
11
+ var LiveResolverStore = require("relay-runtime/lib/store/experimental-live-resolvers/LiveResolverStore");
12
+ var LiveResolverStore$1 = require("relay-runtime/lib/store/experimental-live-resolvers/LiveResolverStore").default;
13
+
14
+ var SuspenseSentinel = {};
11
15
 
12
16
  function convertObj(prim0, prim1, prim2, prim3) {
13
17
  return Utils.traverser(prim0, prim1, prim2, prim3);
@@ -124,8 +128,24 @@ function make(source, gcReleaseBufferSize, queryCacheExpirationTime) {
124
128
  });
125
129
  }
126
130
 
131
+ function makeLiveStore(source, gcReleaseBufferSize, queryCacheExpirationTime) {
132
+ return new LiveResolverStore$1(source, {
133
+ gcReleaseBufferSize: gcReleaseBufferSize,
134
+ queryCacheExpirationTime: queryCacheExpirationTime
135
+ });
136
+ }
137
+
138
+ function _makeLiveStoreCjs(source, gcReleaseBufferSize, queryCacheExpirationTime) {
139
+ return new LiveResolverStore(source, {
140
+ gcReleaseBufferSize: gcReleaseBufferSize,
141
+ queryCacheExpirationTime: queryCacheExpirationTime
142
+ });
143
+ }
144
+
127
145
  var Store = {
128
- make: make
146
+ make: make,
147
+ makeLiveStore: makeLiveStore,
148
+ _makeLiveStoreCjs: _makeLiveStoreCjs
129
149
  };
130
150
 
131
151
  var RelayFieldLogger = {};
@@ -218,6 +238,7 @@ function MakeLoadQuery(C) {
218
238
 
219
239
  var Mutation_failed = /* @__PURE__ */Caml_exceptions.create("RescriptRelay.Mutation_failed");
220
240
 
241
+ exports.SuspenseSentinel = SuspenseSentinel;
221
242
  exports.convertObj = convertObj;
222
243
  exports.RecordProxy = RecordProxy;
223
244
  exports.RecordSourceSelectorProxy = RecordSourceSelectorProxy;
@@ -12,15 +12,33 @@ type fragmentRefs<'fragments>
12
12
  type updatableFragmentRefs<'fragments>
13
13
 
14
14
  type dataId
15
+ type dataIdObject = {id: dataId}
15
16
  type recordSourceRecords = Js.Json.t
16
17
  type uploadables
17
18
 
19
+ module SuspenseSentinel = {
20
+ type t
21
+
22
+ @module("relay-runtime") external suspend: t => 'any = "suspenseSentinel"
23
+ }
24
+
25
+ type liveStateCallback = unit => unit
26
+ type liveStateUnsubscribeCallback = unit => unit
27
+
28
+ type liveState<'value> = {
29
+ read: SuspenseSentinel.t => 'value,
30
+ subscribe: liveStateCallback => liveStateUnsubscribeCallback,
31
+ }
32
+
18
33
  external dataIdToString: dataId => string = "%identity"
19
34
  external makeDataId: string => dataId = "%identity"
20
35
  external makeArguments: {..} => arguments = "%identity"
21
36
  external makeUploadables: Js.Dict.t<'file> => uploadables = "%identity"
22
37
  external unwrapUploadables: uploadables => Js.Dict.t<'file> = "%identity"
23
38
 
39
+ @module("relay-runtime/experimental")
40
+ external resolverDataInjector: ('a, 'b, 'c, 'd) => 'return = "resolverDataInjector"
41
+
24
42
  @module("relay-runtime")
25
43
  external generateClientID: (~dataId: dataId, ~storageKey: string, ~index: int=?) => dataId =
26
44
  "generateClientID"
@@ -267,6 +285,9 @@ module RecordProxy = {
267
285
  module RecordSourceSelectorProxy = {
268
286
  type t
269
287
 
288
+ @send
289
+ external batchLiveStateUpdates: (t, unit => unit) => unit = "batchLiveStateUpdates"
290
+
270
291
  @send
271
292
  external create: (t, ~dataId: dataId, ~typeName: string) => RecordProxy.t = "create"
272
293
 
@@ -535,6 +556,13 @@ module Store = {
535
556
  queryCacheExpirationTime: option<int>,
536
557
  }
537
558
 
559
+ @module @new
560
+ external makeLiveStoreCjs: (RecordSource.t, storeConfig) => t =
561
+ "relay-runtime/lib/store/experimental-live-resolvers/LiveResolverStore"
562
+
563
+ @module("relay-runtime/lib/store/experimental-live-resolvers/LiveResolverStore") @new
564
+ external makeLiveStore: (RecordSource.t, storeConfig) => t = "default"
565
+
538
566
  @module("relay-runtime") @new
539
567
  external make: (RecordSource.t, storeConfig) => t = "Store"
540
568
 
@@ -547,6 +575,24 @@ module Store = {
547
575
  },
548
576
  )
549
577
 
578
+ let makeLiveStore = (~source, ~gcReleaseBufferSize=?, ~queryCacheExpirationTime=?) =>
579
+ makeLiveStore(
580
+ source,
581
+ {
582
+ gcReleaseBufferSize,
583
+ queryCacheExpirationTime,
584
+ },
585
+ )
586
+
587
+ let _makeLiveStoreCjs = (~source, ~gcReleaseBufferSize=?, ~queryCacheExpirationTime=?) =>
588
+ makeLiveStoreCjs(
589
+ source,
590
+ {
591
+ gcReleaseBufferSize,
592
+ queryCacheExpirationTime,
593
+ },
594
+ )
595
+
550
596
  @send external getSource: t => RecordSource.t = "getSource"
551
597
  @send external publish: (t, RecordSource.t) => unit = "publish"
552
598
  @send external holdGC: t => unit = "holdGC"
@@ -36,6 +36,25 @@ type updatableFragmentRefs<'fragments>
36
36
  /**The type of the id Relay uses to identify records in its store.*/
37
37
  type dataId
38
38
 
39
+ type dataIdObject = {id: dataId}
40
+
41
+ module SuspenseSentinel: {
42
+ type t
43
+
44
+ @module("relay-runtime") external suspend: t => 'any = "suspenseSentinel"
45
+ }
46
+
47
+ type liveStateCallback = unit => unit
48
+ type liveStateUnsubscribeCallback = unit => unit
49
+
50
+ type liveState<'value> = {
51
+ read: SuspenseSentinel.t => 'value,
52
+ subscribe: liveStateCallback => liveStateUnsubscribeCallback,
53
+ }
54
+
55
+ @module("relay-runtime/experimental")
56
+ external resolverDataInjector: ('a, 'b, 'c, 'd) => 'return = "resolverDataInjector"
57
+
39
58
  /**Turns a `dataId` into a `string`.*/
40
59
  external dataIdToString: dataId => string = "%identity"
41
60
 
@@ -346,6 +365,9 @@ module RecordSourceSelectorProxy: {
346
365
  /**Type type representing a `RecordSourceSelectorProxy`.*/
347
366
  type t
348
367
 
368
+ @send
369
+ external batchLiveStateUpdates: (t, unit => unit) => unit = "batchLiveStateUpdates"
370
+
349
371
  /**Creates a new `RecordProxy`.*/
350
372
  @send
351
373
  external create: (t, ~dataId: dataId, ~typeName: string) => RecordProxy.t = "create"
@@ -662,6 +684,21 @@ module Store: {
662
684
  ) => /* `queryCacheExpirationTime` sets a TTL (time to live) for all queries. If that time passes, the data is considered stale and is evicted from the store. Default is no TTL. */
663
685
  t
664
686
 
687
+ /**Creates a new `LiveStore`.*/
688
+ let makeLiveStore: (
689
+ ~source: RecordSource.t,
690
+ ~gcReleaseBufferSize: /* `gcReleaseBufferSize` controls how many queries are allowed to be cached by default. Increase this to increase the size of the cache. */
691
+ int=?,
692
+ ~queryCacheExpirationTime: int=?,
693
+ ) => /* `queryCacheExpirationTime` sets a TTL (time to live) for all queries. If that time passes, the data is considered stale and is evicted from the store. Default is no TTL. */
694
+ t
695
+
696
+ let _makeLiveStoreCjs: (
697
+ ~source: RecordSource.t,
698
+ ~gcReleaseBufferSize: int=?,
699
+ ~queryCacheExpirationTime: int=?,
700
+ ) => t
701
+
665
702
  /**Gets the `RecordSource` for this `Store`.*/
666
703
  @send
667
704
  external getSource: t => RecordSource.t = "getSource"