rescript-relay 3.1.0 → 3.3.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/CHANGELOG.md CHANGED
@@ -1,7 +1,24 @@
1
1
  # master
2
2
 
3
+ # 3.3.0
4
+
5
+ - Add support for top level `@catch` on fragments on unions.
6
+ - Add parameter `excludedIds: array<dataId>` to `invalidateRecordsByIds` to allow excluding a list of connection IDs from invalidation.
7
+ - **BREAKING:** `operation.text` and `operation.id` are now nullable, which better reflects what values they can actually have in runtime.
8
+ - fix bug where custom scalars would error when set to null in refetch variables.
9
+
10
+ # 3.2.0
11
+
12
+ - Add support for the new Relay `@catch` directive. https://github.com/zth/rescript-relay/pull/549
13
+ - Add support for `usePrefetchableForwardPagination`. https://github.com/zth/rescript-relay/pull/551
14
+ - Remove `useBlockingPagination` since it's being removed from Relay.
15
+
3
16
  # 3.1.0
4
17
 
18
+ This brings the Relay version to `18.2.0`.
19
+
20
+ If you have enabled the feature flags in `relay.config.js` for aliased fragments or Relay resolvers you'll need to remove them from the config file as they are now on by default, and not removing them will cause the compiler to fail with a non super helpful error message.
21
+
5
22
  - **Upgrade versions**: `react-relay` and `relay-runtime` to `18.2.0`.
6
23
  - Add support for `Fragment.waitForFragmentData`, a new API in Relay 18.2 that lets you wait for fragment data outside of React.
7
24
  - Experimental: Add a "non React" mode to the PPX, which makes sure only APIs that don't rely on React directly are exposed. This is intended to be a way to simplify using RescriptRelay without React. Activate by passing `-non-react` to the PPX, like `"ppx-flags": [["rescript-relay/ppx", "-non-react"]]`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rescript-relay",
3
- "version": "3.1.0",
3
+ "version": "3.3.0",
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
@@ -13,6 +13,32 @@ var Caml_exceptions = require("rescript/lib/js/caml_exceptions.js");
13
13
  var LiveResolverStore = require("relay-runtime/lib/store/live-resolvers/LiveResolverStore").default;
14
14
  var LiveResolverStore$1 = require("relay-runtime/lib/store/live-resolvers/LiveResolverStore");
15
15
 
16
+ function toOption(t) {
17
+ if (t.ok === true) {
18
+ return Caml_option.some(t.value);
19
+ }
20
+
21
+ }
22
+
23
+ function toResult(t) {
24
+ if (t.ok === true) {
25
+ return {
26
+ TAG: "Ok",
27
+ _0: t.value
28
+ };
29
+ } else {
30
+ return {
31
+ TAG: "Error",
32
+ _0: t.errors
33
+ };
34
+ }
35
+ }
36
+
37
+ var CatchResult = {
38
+ toOption: toOption,
39
+ toResult: toResult
40
+ };
41
+
16
42
  var SuspenseSentinel = {};
17
43
 
18
44
  function convertObj(prim0, prim1, prim2, prim3) {
@@ -257,12 +283,16 @@ function findAllConnectionIds(environment, connectionKey, parentId) {
257
283
  return ids;
258
284
  }
259
285
 
260
- function invalidateAllOfConnection(environment, connectionKey, parentId) {
286
+ function invalidateAllOfConnection(environment, connectionKey, parentId, excludedIdsOpt) {
287
+ var excludedIds = excludedIdsOpt !== undefined ? excludedIdsOpt : [];
261
288
  RelayRuntime.commitLocalUpdate(environment, (function (store) {
262
289
  findAllConnectionIds(environment, connectionKey, parentId).forEach(function (dataId) {
263
- Belt_Option.forEach(Caml_option.nullable_to_opt(store.get(dataId)), (function (r) {
264
- r.invalidateRecord();
265
- }));
290
+ if (!excludedIds.includes(dataId)) {
291
+ return Belt_Option.forEach(Caml_option.nullable_to_opt(store.get(dataId)), (function (r) {
292
+ r.invalidateRecord();
293
+ }));
294
+ }
295
+
266
296
  });
267
297
  }));
268
298
  }
@@ -345,6 +375,7 @@ function MakeLoadQuery(C) {
345
375
 
346
376
  var Mutation_failed = /* @__PURE__ */Caml_exceptions.create("RescriptRelay.Mutation_failed");
347
377
 
378
+ exports.CatchResult = CatchResult;
348
379
  exports.SuspenseSentinel = SuspenseSentinel;
349
380
  exports.convertObj = convertObj;
350
381
  exports.RecordProxy = RecordProxy;
@@ -17,6 +17,25 @@ type dataIdObject = {id: dataId}
17
17
  type recordSourceRecords = Js.Json.t
18
18
  type uploadables
19
19
 
20
+ module CatchResult = {
21
+ type catchError = Js.Json.t
22
+
23
+ @tag("ok")
24
+ type t<'value> = | @as(true) Ok({value: 'value}) | @as(false) Error({errors: array<catchError>})
25
+
26
+ let toOption = (t: t<'value>) =>
27
+ switch t {
28
+ | Ok({value}) => Some(value)
29
+ | Error(_) => None
30
+ }
31
+
32
+ let toResult = (t: t<'value>): result<'value, array<catchError>> =>
33
+ switch t {
34
+ | Ok({value}) => Ok(value)
35
+ | Error({errors}) => Error(errors)
36
+ }
37
+ }
38
+
20
39
  module SuspenseSentinel = {
21
40
  type t
22
41
 
@@ -515,8 +534,8 @@ module Network = {
515
534
  type operationMetadata = {codesplits?: array<codesplitsMetadata>}
516
535
 
517
536
  type operation = {
518
- id: string,
519
- text: string,
537
+ id: Js.Nullable.t<string>,
538
+ text: Js.Nullable.t<string>,
520
539
  name: string,
521
540
  operationKind: string,
522
541
  metadata: Js.Nullable.t<operationMetadata>,
@@ -777,14 +796,21 @@ module Environment = {
777
796
  ids
778
797
  }
779
798
 
780
- let invalidateAllOfConnection = (environment: t, ~connectionKey: string, ~parentId: dataId) => {
799
+ let invalidateAllOfConnection = (
800
+ environment: t,
801
+ ~connectionKey: string,
802
+ ~parentId: dataId,
803
+ ~excludedIds=[],
804
+ ) => {
781
805
  environment->commitLocalUpdate(~updater=store => {
782
806
  environment
783
807
  ->findAllConnectionIds(~connectionKey, ~parentId)
784
808
  ->Js.Array2.forEach(dataId => {
785
- store
786
- ->RecordSourceSelectorProxy.get(~dataId)
787
- ->Belt.Option.forEach(r => r->RecordProxy.invalidateRecord)
809
+ if !(excludedIds->Js.Array2.includes(dataId)) {
810
+ store
811
+ ->RecordSourceSelectorProxy.get(~dataId)
812
+ ->Belt.Option.forEach(r => r->RecordProxy.invalidateRecord)
813
+ }
788
814
  })
789
815
  })
790
816
  }