rescript-relay 3.5.1 → 4.1.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +14 -4
  3. package/package.json +20 -7
  4. package/ppx-linux +0 -0
  5. package/ppx-macos-arm64 +0 -0
  6. package/ppx-macos-latest +0 -0
  7. package/ppx-windows-latest +0 -0
  8. package/relay-compiler-linux-musl/relay +0 -0
  9. package/relay-compiler-linux-x64/relay +0 -0
  10. package/relay-compiler-macos-arm64/relay +0 -0
  11. package/relay-compiler-macos-x64/relay +0 -0
  12. package/relay-compiler-win-x64/relay.exe +0 -0
  13. package/src/RescriptRelay.bs.js +110 -194
  14. package/src/RescriptRelay.res +60 -152
  15. package/src/RescriptRelay.resi +86 -201
  16. package/src/RescriptRelayReact.bs.js +75 -0
  17. package/src/RescriptRelayReact.res +94 -0
  18. package/src/RescriptRelayUtils.bs.js +44 -47
  19. package/src/RescriptRelayUtils.res +3 -3
  20. package/src/RescriptRelay_Fragment.bs.js +56 -81
  21. package/src/RescriptRelay_Fragment.res +60 -52
  22. package/src/RescriptRelay_Fragment.resi +5 -5
  23. package/src/RescriptRelay_FragmentNonReact.bs.js +23 -0
  24. package/src/RescriptRelay_FragmentNonReact.res +29 -0
  25. package/src/RescriptRelay_Internal.bs.js +38 -47
  26. package/src/RescriptRelay_Internal.res +5 -5
  27. package/src/RescriptRelay_Internal.resi +2 -4
  28. package/src/RescriptRelay_Mutation.bs.js +28 -42
  29. package/src/RescriptRelay_Mutation.res +4 -4
  30. package/src/RescriptRelay_MutationNonReact.bs.js +40 -0
  31. package/src/RescriptRelay_MutationNonReact.res +56 -0
  32. package/src/RescriptRelay_Query.bs.js +43 -64
  33. package/src/RescriptRelay_Query.res +16 -13
  34. package/src/RescriptRelay_Query.resi +1 -1
  35. package/src/RescriptRelay_QueryNonReact.bs.js +45 -0
  36. package/src/RescriptRelay_QueryNonReact.res +108 -0
  37. package/src/RescriptRelay_RelayResolvers.bs.js +2 -4
  38. package/src/RescriptRelay_Subscriptions.bs.js +9 -15
  39. package/src/RescriptRelay_Subscriptions.res +1 -1
  40. package/src/RescriptRelay_Subscriptions.resi +1 -1
  41. package/src/ReactDOMExperimental.bs.js +0 -23
  42. package/src/ReactDOMExperimental.res +0 -16
package/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # master
2
2
 
3
+ # 4.1.0
4
+
5
+ - Add support for `autoExhaustiveTypes` config and a `@nonExhaustive` directive to control automatic exhaustive checks for unions/interfaces.
6
+
7
+ - Add React-free mode support and split React APIs into `RescriptRelayReact`.
8
+
9
+ - New compiler config: `rescriptRelayMode: "Default" | "NonReact"` (defaults to `"Default"`).
10
+ - PPX `-non-react`
11
+ - Mark `@rescript/react` and `react-relay` as optional peer deps so non‑React usage does not require them.
12
+
13
+ - BREAKING: Move all React-specific APIs out of `RescriptRelay` into `RescriptRelayReact`.
14
+
15
+ - `RescriptRelay.Context.Provider` -> `RescriptRelayReact.Context.Provider`
16
+ - `RescriptRelay.useEnvironmentFromContext` -> `RescriptRelayReact.useEnvironmentFromContext`
17
+ - `RescriptRelay.useSubscribeToInvalidationState` -> `RescriptRelayReact.useSubscribeToInvalidationState`
18
+
19
+ Migration:
20
+
21
+ - Update imports/usages in app code to reference `RescriptRelayReact` for the APIs listed above.
22
+ - For non‑React usage, set `rescriptRelayMode: "NonReact"` in `relay.config.js` and pass `-non-react` to the PPX.
23
+
24
+ # 4.0.0
25
+
26
+ - Support `@exhaustive` on interfaces as well.
27
+ - Remove `ReactDOMExperimental` module, since everything needed is in the official RescriptReact bindings now.
28
+ - Move fully to ReScript v12. From `4.x`, only v12 is supported.
29
+
3
30
  # 3.5.1
4
31
 
5
32
  - Build Linux PPX binary in Debian 11 (bullseye) container to improve compatibility with older glibc versions. The binary now requires glibc 2.31 instead of 2.39, supporting Amazon Linux 2023 (Vercel), Ubuntu 20.04+, Debian 11+, and RHEL 9+.
package/README.md CHANGED
@@ -69,7 +69,7 @@ let make = (~user) => {
69
69
  <div>
70
70
  <p>
71
71
  {React.string(
72
- userData.firstName ++ (" has " ++ (userData.friendCount->string_of_int ++ " friends.")),
72
+ userData.firstName ++ (" has " ++ (userData.friendCount->Int.toString ++ " friends.")),
73
73
  )}
74
74
  </p>
75
75
  </div>
@@ -100,11 +100,21 @@ let make = () => {
100
100
 
101
101
  ## Note about versioning
102
102
 
103
- There's plenty of work ongoing to bring RescriptRelay to full ReScript v11 support, including uncurried mode. Here's the versioning scheme that'll be followed going forward:
103
+ RescriptRelay has moved through a few major lines with different ReScript baselines. Use the compatibility guide below to pick the right versions:
104
+
105
+ ### Compatibility
106
+
107
+ | RescriptRelay | Required ReScript |
108
+ | ------------- | ----------------- |
109
+ | 4.x and newer | v12.x (or newer) |
110
+ | 3.x and below | v11.x (or older) |
111
+
112
+ Additional context on historical focus areas:
104
113
 
105
114
  - 1.x will receive critical bug fixes etc, but new features won't be added
106
- - 2.x will focus on compatibility with ReScript v11, and uncurried mode (uncurried mode will be optional). This is intended to make the transition to v11+ smooth
107
- - 3.x is fully embracing uncurried mode (no curried mode available), and adds a bunch of new stuff + change existing APIs to make them better and more ergonomic
115
+ - 2.x focuses on compatibility with ReScript v11, and uncurried mode (uncurried mode can be optional). This is intended to make the transition to v11+ smooth
116
+ - 3.x fully embraces uncurried mode (no curried mode available), and adds a bunch of new stuff + changes existing APIs to make them better and more ergonomic
117
+ - 4.x focuses exclusively on ReScript v12+.
108
118
 
109
119
  ## Examples
110
120
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rescript-relay",
3
- "version": "3.5.1",
3
+ "version": "4.1.0",
4
4
  "main": "src/RescriptRelay.res",
5
5
  "license": "MIT",
6
6
  "author": "Gabriel Nordeborn",
@@ -33,31 +33,44 @@
33
33
  },
34
34
  "scripts": {
35
35
  "build": "rescript",
36
- "build:test": "./build-compiler-dev.sh && ./rescript-relay-compiler",
36
+ "build:test": "./build-compiler-dev.sh && ./rescript-relay-compiler && ENABLE_PERSISTING=true ./rescript-relay-compiler && rm ./__tests_preloaded__/__generated__/RelaySchemaAssets_graphql.res",
37
37
  "postinstall": "node postinstall.js",
38
- "test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest",
39
- "test:ci": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --ci --runInBand"
38
+ "test": "jest",
39
+ "test:ci": "jest --ci --runInBand"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@glennsl/rescript-fetch": "^0.2.0",
43
- "@rescript/react": "0.12.2",
43
+ "@rescript/react": "0.14.0",
44
44
  "@testing-library/jest-dom": "^5.16.3",
45
45
  "@testing-library/react": "^13.0.0-alpha.6",
46
46
  "graphql-query-test-mock": "^0.12.1",
47
47
  "jest": "^27.2.4",
48
+ "@babel/core": "^7.24.0",
49
+ "@babel/preset-env": "^7.24.0",
50
+ "@babel/plugin-syntax-dynamic-import": "^7.8.3",
51
+ "babel-jest": "^27.2.4",
52
+ "babel-plugin-dynamic-import-node": "^2.3.3",
48
53
  "nock": "^11.7.0",
49
54
  "node-fetch": "^2.6.0",
50
55
  "react": "18.2.0",
51
56
  "react-dom": "18.2.0",
52
57
  "react-relay": "20.1.1",
53
58
  "relay-runtime": "20.1.1",
54
- "rescript": "11.1.1"
59
+ "rescript": "12.0.0"
55
60
  },
56
61
  "peerDependencies": {
57
62
  "@rescript/react": ">=0.13.0",
58
63
  "react-relay": "20.1.1",
59
64
  "relay-runtime": "20.1.1",
60
- "rescript": "^11.0.0"
65
+ "rescript": "^12.0.0-0"
66
+ },
67
+ "peerDependenciesMeta": {
68
+ "@rescript/react": {
69
+ "optional": true
70
+ },
71
+ "react-relay": {
72
+ "optional": true
73
+ }
61
74
  },
62
75
  "dependencies": {
63
76
  "detect-libc": "^2.0.1"
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
@@ -1,45 +1,40 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
  'use strict';
3
3
 
4
- var React = require("react");
5
- var Utils = require("./utils");
6
- var Js_dict = require("rescript/lib/js/js_dict.js");
7
- var Belt_Array = require("rescript/lib/js/belt_Array.js");
8
- var Belt_Option = require("rescript/lib/js/belt_Option.js");
9
- var Caml_option = require("rescript/lib/js/caml_option.js");
10
- var ReactRelay = require("react-relay");
11
- var RelayRuntime = require("relay-runtime");
12
- var Caml_exceptions = require("rescript/lib/js/caml_exceptions.js");
13
- var LiveResolverStore = require("relay-runtime/lib/store/live-resolvers/LiveResolverStore").default;
14
- var LiveResolverStore$1 = require("relay-runtime/lib/store/live-resolvers/LiveResolverStore");
4
+ let Utils = require("./utils");
5
+ let Stdlib_Option = require("@rescript/runtime/lib/js/Stdlib_Option.js");
6
+ let RelayRuntime = require("relay-runtime");
7
+ let Primitive_option = require("@rescript/runtime/lib/js/Primitive_option.js");
8
+ let Primitive_exceptions = require("@rescript/runtime/lib/js/Primitive_exceptions.js");
9
+ let LiveResolverStore = require("relay-runtime/lib/store/live-resolvers/LiveResolverStore");
10
+ let LiveResolverStore$1 = require("relay-runtime/lib/store/live-resolvers/LiveResolverStore").default;
15
11
 
16
12
  function toOption(t) {
17
13
  if (t.ok === true) {
18
- return Caml_option.some(t.value);
14
+ return Primitive_option.some(t.value);
19
15
  }
20
-
21
16
  }
22
17
 
23
18
  function toResult(t) {
24
19
  if (t.ok === true) {
25
20
  return {
26
- TAG: "Ok",
27
- _0: t.value
28
- };
21
+ TAG: "Ok",
22
+ _0: t.value
23
+ };
29
24
  } else {
30
25
  return {
31
- TAG: "Error",
32
- _0: t.errors
33
- };
26
+ TAG: "Error",
27
+ _0: t.errors
28
+ };
34
29
  }
35
30
  }
36
31
 
37
- var CatchResult = {
32
+ let CatchResult = {
38
33
  toOption: toOption,
39
34
  toResult: toResult
40
35
  };
41
36
 
42
- var SuspenseSentinel = {};
37
+ let SuspenseSentinel = {};
43
38
 
44
39
  function convertObj(prim0, prim1, prim2, prim3) {
45
40
  return Utils.traverser(prim0, prim1, prim2, prim3);
@@ -47,114 +42,111 @@ function convertObj(prim0, prim1, prim2, prim3) {
47
42
 
48
43
  function optArrayOfNullableToOptArrayOfOpt(x) {
49
44
  if (x !== undefined) {
50
- return Belt_Array.map(x, (function (prim) {
51
- if (prim == null) {
52
- return ;
53
- } else {
54
- return Caml_option.some(prim);
55
- }
56
- }));
45
+ return x.map(prim => {
46
+ if (prim == null) {
47
+ return;
48
+ } else {
49
+ return Primitive_option.some(prim);
50
+ }
51
+ });
57
52
  }
58
-
59
53
  }
60
54
 
61
55
  function getLinkedRecords(t, name, $$arguments) {
62
- return optArrayOfNullableToOptArrayOfOpt(Caml_option.nullable_to_opt(t.getLinkedRecords(name, $$arguments)));
56
+ return optArrayOfNullableToOptArrayOfOpt(Primitive_option.fromNullable(t.getLinkedRecords(name, $$arguments)));
63
57
  }
64
58
 
65
- var RecordProxy = {
59
+ let RecordProxy = {
66
60
  getLinkedRecords: getLinkedRecords
67
61
  };
68
62
 
69
63
  function getPluralRootField(t, fieldName) {
70
- return optArrayOfNullableToOptArrayOfOpt(Caml_option.nullable_to_opt(t.getPluralRootField(fieldName)));
64
+ return optArrayOfNullableToOptArrayOfOpt(Primitive_option.fromNullable(t.getPluralRootField(fieldName)));
71
65
  }
72
66
 
73
67
  function invalidateRecordsByIds(store, recordIds) {
74
- recordIds.forEach(function (dataId) {
75
- Belt_Option.forEach(Caml_option.nullable_to_opt(store.get(dataId)), (function (r) {
76
- r.invalidateRecord();
77
- }));
78
- });
68
+ recordIds.forEach(dataId => Stdlib_Option.forEach(Primitive_option.fromNullable(store.get(dataId)), r => {
69
+ r.invalidateRecord();
70
+ }));
79
71
  }
80
72
 
81
- var RecordSourceSelectorProxy = {
73
+ let RecordSourceSelectorProxy = {
82
74
  getPluralRootField: getPluralRootField,
83
75
  invalidateRecordsByIds: invalidateRecordsByIds
84
76
  };
85
77
 
86
- var ReadOnlyRecordSourceProxy = {};
78
+ let ReadOnlyRecordSourceProxy = {};
87
79
 
88
80
  function unwrapNormalizationArgument(wrapped) {
89
- var match = wrapped.kind;
81
+ let match = wrapped.kind;
90
82
  if (match === "Literal") {
91
83
  return {
92
- TAG: "Literal",
93
- _0: wrapped
94
- };
84
+ TAG: "Literal",
85
+ _0: wrapped
86
+ };
95
87
  } else if (match === "ListValue") {
96
88
  return {
97
- TAG: "ListValue",
98
- _0: wrapped
99
- };
89
+ TAG: "ListValue",
90
+ _0: wrapped
91
+ };
100
92
  } else if (match === "ObjectValue") {
101
93
  return {
102
- TAG: "ObjectValue",
103
- _0: wrapped
104
- };
94
+ TAG: "ObjectValue",
95
+ _0: wrapped
96
+ };
105
97
  } else {
106
98
  return {
107
- TAG: "Variable",
108
- _0: wrapped
109
- };
99
+ TAG: "Variable",
100
+ _0: wrapped
101
+ };
110
102
  }
111
103
  }
112
104
 
113
105
  function makeScalarMissingFieldHandler(handle) {
114
106
  return {
115
- kind: "scalar",
116
- handle: handle
117
- };
107
+ kind: "scalar",
108
+ handle: handle
109
+ };
118
110
  }
119
111
 
120
112
  function makeLinkedMissingFieldHandler(handle) {
121
113
  return {
122
- kind: "linked",
123
- handle: handle
124
- };
114
+ kind: "linked",
115
+ handle: handle
116
+ };
125
117
  }
126
118
 
127
119
  function makePluralLinkedMissingFieldHandler(handle) {
128
120
  return {
129
- kind: "pluralLinked",
130
- handle: handle
131
- };
121
+ kind: "pluralLinked",
122
+ handle: handle
123
+ };
132
124
  }
133
125
 
134
- var MissingFieldHandler = {
126
+ let MissingFieldHandler = {
135
127
  unwrapNormalizationArgument: unwrapNormalizationArgument,
136
128
  makeScalarMissingFieldHandler: makeScalarMissingFieldHandler,
137
129
  makeLinkedMissingFieldHandler: makeLinkedMissingFieldHandler,
138
130
  makePluralLinkedMissingFieldHandler: makePluralLinkedMissingFieldHandler
139
131
  };
140
132
 
141
- var nodeInterfaceMissingFieldHandler = makeLinkedMissingFieldHandler(function (field, record, args, _store) {
142
- var match = field.name;
143
- var match$1 = args.id;
144
- if ((record == null) || !(match === "node" && record.getType() === RelayRuntime.ROOT_TYPE && !(match$1 == null))) {
145
- return ;
146
- } else {
147
- return Caml_option.some(match$1);
148
- }
149
- });
133
+ let nodeInterfaceMissingFieldHandler = makeLinkedMissingFieldHandler((field, record, args, _store) => {
134
+ let match = field.name;
135
+ let match$1 = args.id;
136
+ if ((record == null) || match !== "node" || record.getType() !== RelayRuntime.ROOT_TYPE || (match$1 == null)) {
137
+ return;
138
+ } else {
139
+ return Primitive_option.some(match$1);
140
+ }
141
+ });
150
142
 
151
- var ConnectionHandler = {};
143
+ let ConnectionHandler = {};
152
144
 
153
- var Disposable = {};
145
+ let Disposable = {};
154
146
 
155
- var Observable = {};
147
+ let Observable = {};
156
148
 
157
- var preloadResources = (function preloadResources(operation, variables, response) {
149
+ let preloadResources = (function preloadResources(operation, variables, response) {
158
150
  let metadata = operation.metadata;
159
151
  if (metadata == null) return;
160
152
  let codesplits = metadata.codesplits;
@@ -221,159 +213,87 @@ var preloadResources = (function preloadResources(operation, variables, response
221
213
  }
222
214
  });
223
215
 
224
- var Network = {
216
+ let Network = {
225
217
  preloadResources: preloadResources
226
218
  };
227
219
 
228
- var RecordSource = {};
220
+ let RecordSource = {};
229
221
 
230
222
  function make(source, gcReleaseBufferSize, queryCacheExpirationTime) {
231
223
  return new RelayRuntime.Store(source, {
232
- gcReleaseBufferSize: gcReleaseBufferSize,
233
- queryCacheExpirationTime: queryCacheExpirationTime
234
- });
224
+ gcReleaseBufferSize: gcReleaseBufferSize,
225
+ queryCacheExpirationTime: queryCacheExpirationTime
226
+ });
235
227
  }
236
228
 
237
229
  function makeLiveStore(source, gcReleaseBufferSize, queryCacheExpirationTime) {
238
- return new LiveResolverStore(source, {
239
- gcReleaseBufferSize: gcReleaseBufferSize,
240
- queryCacheExpirationTime: queryCacheExpirationTime
241
- });
230
+ return new LiveResolverStore$1(source, {
231
+ gcReleaseBufferSize: gcReleaseBufferSize,
232
+ queryCacheExpirationTime: queryCacheExpirationTime
233
+ });
242
234
  }
243
235
 
244
236
  function _makeLiveStoreCjs(source, gcReleaseBufferSize, queryCacheExpirationTime) {
245
- return new LiveResolverStore$1(source, {
246
- gcReleaseBufferSize: gcReleaseBufferSize,
247
- queryCacheExpirationTime: queryCacheExpirationTime
248
- });
237
+ return new LiveResolverStore(source, {
238
+ gcReleaseBufferSize: gcReleaseBufferSize,
239
+ queryCacheExpirationTime: queryCacheExpirationTime
240
+ });
249
241
  }
250
242
 
251
- var Store = {
243
+ let Store = {
252
244
  make: make,
253
245
  makeLiveStore: makeLiveStore,
254
246
  _makeLiveStoreCjs: _makeLiveStoreCjs
255
247
  };
256
248
 
257
- var RelayFieldLogger = {};
249
+ let RelayFieldLogger = {};
258
250
 
259
251
  function make$1(network, store, getDataID, treatMissingFieldsAsNull, missingFieldHandlers, relayFieldLogger, isServer) {
260
252
  return new RelayRuntime.Environment({
261
- network: network,
262
- store: store,
263
- getDataID: getDataID,
264
- treatMissingFieldsAsNull: treatMissingFieldsAsNull,
265
- missingFieldHandlers: missingFieldHandlers !== undefined ? Belt_Array.concat(missingFieldHandlers, [nodeInterfaceMissingFieldHandler]) : [nodeInterfaceMissingFieldHandler],
266
- relayFieldLogger: relayFieldLogger,
267
- isServer: isServer
268
- });
253
+ network: network,
254
+ store: store,
255
+ getDataID: getDataID,
256
+ treatMissingFieldsAsNull: treatMissingFieldsAsNull,
257
+ missingFieldHandlers: missingFieldHandlers !== undefined ? missingFieldHandlers.concat([nodeInterfaceMissingFieldHandler]) : [nodeInterfaceMissingFieldHandler],
258
+ relayFieldLogger: relayFieldLogger,
259
+ isServer: isServer
260
+ });
269
261
  }
270
262
 
271
263
  function findAllConnectionIds(environment, connectionKey, parentId) {
272
- var ids = [];
273
- var value = environment.getStore().getSource()._records.get(parentId);
264
+ let ids = [];
265
+ let value = environment.getStore().getSource()._records.get(parentId);
274
266
  if (value !== undefined) {
275
- Js_dict.entries(value).forEach(function (param) {
276
- if (param[0].startsWith("__" + connectionKey + "_connection")) {
277
- ids.push(param[1].__ref);
278
- return ;
279
- }
280
-
281
- });
267
+ Object.entries(value).forEach(param => {
268
+ if (param[0].startsWith("__" + connectionKey + "_connection")) {
269
+ ids.push(param[1].__ref);
270
+ return;
271
+ }
272
+ });
282
273
  }
283
274
  return ids;
284
275
  }
285
276
 
286
277
  function invalidateAllOfConnection(environment, connectionKey, parentId, excludedIdsOpt) {
287
- var excludedIds = excludedIdsOpt !== undefined ? excludedIdsOpt : [];
288
- RelayRuntime.commitLocalUpdate(environment, (function (store) {
289
- findAllConnectionIds(environment, connectionKey, parentId).forEach(function (dataId) {
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
-
296
- });
297
- }));
278
+ let excludedIds = excludedIdsOpt !== undefined ? excludedIdsOpt : [];
279
+ RelayRuntime.commitLocalUpdate(environment, store => {
280
+ findAllConnectionIds(environment, connectionKey, parentId).forEach(dataId => {
281
+ if (!excludedIds.includes(dataId)) {
282
+ return Stdlib_Option.forEach(Primitive_option.fromNullable(store.get(dataId)), r => {
283
+ r.invalidateRecord();
284
+ });
285
+ }
286
+ });
287
+ });
298
288
  }
299
289
 
300
- var Environment = {
290
+ let Environment = {
301
291
  make: make$1,
302
292
  findAllConnectionIds: findAllConnectionIds,
303
293
  invalidateAllOfConnection: invalidateAllOfConnection
304
294
  };
305
295
 
306
- function RescriptRelay$Context$Provider(props) {
307
- var provider = ReactRelay.ReactRelayContext.Provider;
308
- return React.createElement(provider, {
309
- value: {
310
- environment: props.environment
311
- },
312
- children: props.children
313
- });
314
- }
315
-
316
- var Provider = {
317
- make: RescriptRelay$Context$Provider
318
- };
319
-
320
- var Context = {
321
- Provider: Provider
322
- };
323
-
324
- var EnvironmentNotFoundInContext = /* @__PURE__ */Caml_exceptions.create("RescriptRelay.EnvironmentNotFoundInContext");
325
-
326
- function useEnvironmentFromContext() {
327
- var context = React.useContext(ReactRelay.ReactRelayContext);
328
- if (context !== undefined) {
329
- return Caml_option.valFromOption(context).environment;
330
- }
331
- throw {
332
- RE_EXN_ID: EnvironmentNotFoundInContext,
333
- Error: new Error()
334
- };
335
- }
336
-
337
- function MakeLoadQuery(C) {
338
- var load = function (environment, variables, fetchPolicy, fetchKey, networkCacheConfig) {
339
- return ReactRelay.loadQuery(environment, C.query, C.convertVariables(variables), {
340
- fetchKey: fetchKey,
341
- fetchPolicy: fetchPolicy,
342
- networkCacheConfig: networkCacheConfig
343
- });
344
- };
345
- var queryRefToObservable = function (token) {
346
- return Caml_option.nullable_to_opt(token.source);
347
- };
348
- var queryRefToPromise = function (token) {
349
- return new Promise((function (resolve, param) {
350
- var o = queryRefToObservable(token);
351
- if (o !== undefined) {
352
- Caml_option.valFromOption(o).subscribe({
353
- complete: (function () {
354
- resolve({
355
- TAG: "Ok",
356
- _0: undefined
357
- });
358
- })
359
- });
360
- return ;
361
- } else {
362
- return resolve({
363
- TAG: "Error",
364
- _0: undefined
365
- });
366
- }
367
- }));
368
- };
369
- return {
370
- load: load,
371
- queryRefToObservable: queryRefToObservable,
372
- queryRefToPromise: queryRefToPromise
373
- };
374
- }
375
-
376
- var Mutation_failed = /* @__PURE__ */Caml_exceptions.create("RescriptRelay.Mutation_failed");
296
+ let Mutation_failed = /* @__PURE__ */Primitive_exceptions.create("RescriptRelay.Mutation_failed");
377
297
 
378
298
  exports.CatchResult = CatchResult;
379
299
  exports.SuspenseSentinel = SuspenseSentinel;
@@ -390,9 +310,5 @@ exports.Store = Store;
390
310
  exports.Disposable = Disposable;
391
311
  exports.RelayFieldLogger = RelayFieldLogger;
392
312
  exports.Environment = Environment;
393
- exports.Context = Context;
394
- exports.EnvironmentNotFoundInContext = EnvironmentNotFoundInContext;
395
- exports.useEnvironmentFromContext = useEnvironmentFromContext;
396
313
  exports.Mutation_failed = Mutation_failed;
397
- exports.MakeLoadQuery = MakeLoadQuery;
398
314
  /* nodeInterfaceMissingFieldHandler Not a pure module */