rescript-relay 0.0.0-up-lsp-2731c9ea → 0.0.0-version-3-89bccc22

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 (41) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/README.md +8 -0
  3. package/package.json +13 -13
  4. package/postinstall.js +13 -3
  5. package/ppx-linux +0 -0
  6. package/ppx-macos-arm64 +0 -0
  7. package/ppx-macos-latest +0 -0
  8. package/ppx-windows-latest +0 -0
  9. package/relay-compiler-linux-musl/relay +0 -0
  10. package/relay-compiler-linux-x64/relay +0 -0
  11. package/relay-compiler-macos-arm64/relay +0 -0
  12. package/relay-compiler-macos-x64/relay +0 -0
  13. package/relay-compiler-win-x64/relay.exe +0 -0
  14. package/src/ReactDOMExperimental.bs.js +4 -0
  15. package/src/ReactDOMExperimental.res +2 -5
  16. package/src/ReactExperimental.bs.js +5 -3
  17. package/src/ReactExperimental.res +2 -2
  18. package/src/ReactExperimental.resi +2 -2
  19. package/src/RescriptRelay.bs.js +18 -49
  20. package/src/RescriptRelay.res +30 -47
  21. package/src/RescriptRelay.resi +223 -290
  22. package/src/RescriptRelayUtils.bs.js +3 -3
  23. package/src/RescriptRelayUtils.resi +3 -5
  24. package/src/RescriptRelay_Fragment.bs.js +115 -0
  25. package/src/RescriptRelay_Fragment.res +239 -0
  26. package/src/RescriptRelay_Fragment.resi +86 -0
  27. package/src/RescriptRelay_Internal.bs.js +2 -3
  28. package/src/RescriptRelay_Mutation.bs.js +57 -0
  29. package/src/RescriptRelay_Mutation.res +146 -0
  30. package/src/RescriptRelay_Mutation.resi +54 -0
  31. package/src/RescriptRelay_Query.bs.js +101 -0
  32. package/src/RescriptRelay_Query.res +185 -0
  33. package/src/RescriptRelay_Query.resi +70 -0
  34. package/src/RescriptRelay_RelayResolvers.bs.js +13 -0
  35. package/src/RescriptRelay_RelayResolvers.res +21 -0
  36. package/src/RescriptRelay_RelayResolvers.resi +10 -0
  37. package/src/RescriptRelay_Subscriptions.bs.js +24 -0
  38. package/src/RescriptRelay_Subscriptions.res +51 -0
  39. package/src/RescriptRelay_Subscriptions.resi +15 -0
  40. package/src/utils.js +38 -17
  41. package/src/utils.mjs +38 -17
package/CHANGELOG.md CHANGED
@@ -1,5 +1,86 @@
1
1
  # master
2
2
 
3
+ ## Breaking changes
4
+
5
+ - 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
6
+ - 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
7
+
8
+ # 2.0.0-alpha.1
9
+
10
+ ## Improvements
11
+
12
+ - `%relay.deferredComponent` now works with uncurried mode.
13
+
14
+ # 2.0.0-alpha.0
15
+
16
+ First alpha of the `2.x` series of releases. `2.x` focuses on compat with ReScript `v11`, including uncurried mode.
17
+
18
+ ### Uncurried mode
19
+
20
+ You can activate uncurried mode with `RescriptRelay` by setting `"uncurried": true` in your `bsconfig.json`, and then ensuring that you pass `-uncurried` to `rescript-relay/ppx` in `ppx-flags`: `"ppx-flags": [["rescript-relay/ppx", "-uncurried"]]`.
21
+
22
+ ## Upgrade versions
23
+
24
+ - `rescript` to `>=11.0.0-beta.0`
25
+ - `@rescript/react` to `>=0.12.0-alpha.2`
26
+
27
+ ## Improvements
28
+
29
+ - Leverage variant's new `string` representation + `@as()` to get rid of `mapFetchPolicy`. This was internal so it should not affect you as an end user.
30
+
31
+ # 1.2.0
32
+
33
+ This release mainly makes preparations under the hood for the upcoming `2.0` (ReScript v11 + uncurried mode support) and `3.0` (lots of changes, full uncurried mode only).
34
+
35
+ ## Breaking changes
36
+
37
+ - A trailing unit `()` arg is no longer needed in `Query.usePreloaded()`. What was previously `Query.usePreloaded(~queryRef, ())` is now just `Query.usePreloaded(~queryRef)`.
38
+
39
+ ## Improvements
40
+
41
+ - Add `@live` annotations to generated JSXv4 dynamic import compat modules, so they don't show up in dead code analysis (which they shouldn't).
42
+ - Preparations under the hood for ReScript v11 + uncurried mode.
43
+
44
+ # 1.1.1
45
+
46
+ - Fix M1 binary to include new JSXv4 dynamic import compat changes.
47
+
48
+ # 1.1.0
49
+
50
+ Notable changes:
51
+
52
+ - _JSX v4 is now required_
53
+ - Relay and @rescript/react upgraded
54
+ - M1 support for the PPX (should speed up builds for anyone on an M1)
55
+
56
+ ## Upgrade versions
57
+
58
+ - `react-relay` and `relay-runtime` to `>=15.0.0`
59
+ - `@rescript/react` to `>=0.11.0`
60
+
61
+ ## Breaking changes
62
+
63
+ - The signature for missing field handlers has changed. Previously you got an open type `{..}` as record, now instead you get a proper `RecordProxy.t` from the store. Check out [the changelog for Relay 15](https://github.com/facebook/relay/releases/tag/v15.0.0).
64
+ - ReScript `>=10.1` and JSX v4 is now required.
65
+ - Work around issue with JSX v4 and `%relay.deferredComponent`. You now need to annotate any component you want to use with `%relay.deferredComponent` with `@relay.deferredComponent`. https://github.com/zth/rescript-relay/pull/439
66
+
67
+ ## Improvements
68
+
69
+ - Experimental support for allowing `null` in operation variables. Add `@rescriptRelayNullableVariables` to your operation (query, mutation, subscription) and you'll be allowed to pass `Js.null` (via the `Js.Null` module) to your server. https://github.com/zth/rescript-relay/pull/426
70
+ - :tada: M1 support for the PPX! This should speed up builds some. https://github.com/zth/rescript-relay/pull/435
71
+
72
+ ## Bug Fixes
73
+
74
+ - Fix issue with conversion of custom scalars, where custom scalars represented as arrays would get converted "internally" although they should've really just been left alone. https://github.com/zth/rescript-relay/pull/433
75
+
76
+ # 1.0.5
77
+
78
+ ## Bug Fixes
79
+
80
+ - Fix fairly large performance issue with runtime conversion. This should give a large speedup in certain cases.
81
+
82
+ # 1.0.4
83
+
3
84
  ## Improvements
4
85
 
5
86
  - Improved autocomplete for fragments etc (pulled from upstream Relay compiler). https://github.com/facebook/relay/pull/4134
package/README.md CHANGED
@@ -98,6 +98,14 @@ let make = () => {
98
98
 
99
99
  ```
100
100
 
101
+ ## Note about versioning
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:
104
+
105
+ - 1.x will receive critical bug fixes etc, but new features won't be added
106
+ - 2.x will soon ship, and it'll 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 will also soon ship, and that'll fully embrace uncurried mode (no curried mode available), and add a bunch of new stuff + change existing APIs to make them better and more ergonomic
108
+
101
109
  ## Examples
102
110
 
103
111
  - A general example showcasing most available features: https://github.com/zth/rescript-relay/tree/master/example
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rescript-relay",
3
- "version": "0.0.0-up-lsp-2731c9ea",
3
+ "version": "0.0.0-version-3-89bccc22",
4
4
  "main": "src/RescriptRelay.res",
5
5
  "license": "MIT",
6
6
  "author": "Gabriel Nordeborn",
@@ -39,31 +39,31 @@
39
39
  "test:ci": "jest --ci --runInBand"
40
40
  },
41
41
  "devDependencies": {
42
- "rescript": "^10.0.0",
43
- "@rescript/react": "0.10.3",
42
+ "@glennsl/rescript-fetch": "^0.2.0",
43
+ "@rescript/react": "0.12.0-alpha.2",
44
44
  "@testing-library/jest-dom": "^5.16.3",
45
45
  "@testing-library/react": "^13.0.0-alpha.6",
46
- "bs-fetch": "^0.5.0",
47
46
  "graphql-query-test-mock": "^0.12.1",
48
47
  "jest": "^27.2.4",
49
48
  "nock": "^11.7.0",
50
49
  "node-fetch": "^2.6.0",
51
- "react": "18.0.0",
52
- "react-dom": "18.0.0",
53
- "react-relay": "14.1.0",
54
- "relay-runtime": "14.1.0"
50
+ "react": "18.2.0",
51
+ "react-dom": "18.2.0",
52
+ "react-relay": "15.0.0",
53
+ "relay-runtime": "15.0.0",
54
+ "rescript": "^11.0.0-beta.2"
55
55
  },
56
56
  "peerDependencies": {
57
- "@rescript/react": "*",
58
- "react-relay": ">=11.0.0",
57
+ "@rescript/react": "^0.12.0-alpha.2 || next",
58
+ "react-relay": ">=15.0.0",
59
59
  "relay-runtime": "*",
60
- "rescript": ">=9.1.2"
60
+ "rescript": "^11.0.0-alpha.0 || next"
61
61
  },
62
62
  "dependencies": {
63
63
  "detect-libc": "^2.0.1"
64
64
  },
65
65
  "resolutions": {
66
- "react": "18.0.0",
67
- "react-dom": "18.0.0"
66
+ "react": "18.2.0",
67
+ "react-dom": "18.2.0"
68
68
  }
69
69
  }
package/postinstall.js CHANGED
@@ -40,7 +40,7 @@ function ppxArch() {
40
40
  * Use Rosetta for ARM on macOS
41
41
  */
42
42
  if (platform === "darwin" && process.arch === "arm64") {
43
- return "x64";
43
+ return "arm64";
44
44
  }
45
45
 
46
46
  /**
@@ -132,6 +132,7 @@ function copyPlatformBinaries(platform) {
132
132
  }
133
133
 
134
134
  function removeInitialBinaries() {
135
+ fs.unlinkSync(path.join(__dirname, "ppx-macos-arm64"));
135
136
  fs.unlinkSync(path.join(__dirname, "ppx-macos-latest"));
136
137
  fs.unlinkSync(path.join(__dirname, "ppx-windows-latest"));
137
138
  fs.unlinkSync(path.join(__dirname, "ppx-linux"));
@@ -151,6 +152,10 @@ function removeInitialBinaries() {
151
152
  recursive: true,
152
153
  force: true,
153
154
  });
155
+ fs.rmSync(path.join(__dirname, "relay-compiler-win-x64"), {
156
+ recursive: true,
157
+ force: true,
158
+ });
154
159
  }
155
160
 
156
161
  switch (platform) {
@@ -165,9 +170,14 @@ switch (platform) {
165
170
  case "linux":
166
171
  copyPlatformBinaries(platform);
167
172
  break;
168
- case "darwin":
169
- copyPlatformBinaries("macos-latest");
173
+ case "darwin": {
174
+ if (ppxArch() === "arm64") {
175
+ copyPlatformBinaries("macos-arm64");
176
+ } else {
177
+ copyPlatformBinaries("macos-latest");
178
+ }
170
179
  break;
180
+ }
171
181
  default:
172
182
  console.warn("error: no release built for the " + platform + " platform");
173
183
  process.exit(1);
package/ppx-linux CHANGED
Binary file
Binary file
package/ppx-macos-latest CHANGED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,6 +1,7 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
  'use strict';
3
3
 
4
+ var ReactDOM = require("@rescript/react/src/ReactDOM.bs.js");
4
5
  var Client = require("react-dom/client");
5
6
 
6
7
  function renderConcurrentRootAtElementWithId(content, id) {
@@ -15,5 +16,8 @@ function renderConcurrentRootAtElementWithId(content, id) {
15
16
  Client.createRoot(element).render(content);
16
17
  }
17
18
 
19
+ var Root = ReactDOM.Client.Root;
20
+
21
+ exports.Root = Root;
18
22
  exports.renderConcurrentRootAtElementWithId = renderConcurrentRootAtElementWithId;
19
23
  /* react-dom/client Not a pure module */
@@ -1,7 +1,4 @@
1
- include ReactDOM.Experimental
2
-
3
- @module("react-dom/client")
4
- external createRoot: Dom.element => root = "createRoot"
1
+ include ReactDOM.Client
5
2
 
6
3
  @val @return(nullable)
7
4
  external getElementById: string => option<Dom.element> = "document.getElementById"
@@ -15,5 +12,5 @@ let renderConcurrentRootAtElementWithId: (React.element, string) => unit = (cont
15
12
  id ++ " found in the HTML.",
16
13
  ),
17
14
  )
18
- | Some(element) => createRoot(element)->render(content)
15
+ | Some(element) => createRoot(element)->Root.render(content)
19
16
  }
@@ -3,13 +3,15 @@
3
3
 
4
4
  var React = require("react");
5
5
 
6
- function useTransition(param) {
6
+ function useTransition() {
7
7
  var match = React.useTransition();
8
8
  var startTransition = match[1];
9
9
  return [
10
10
  match[0],
11
- React.useCallback((function (cb) {
12
- startTransition(cb, undefined);
11
+ React.useMemo((function () {
12
+ return function (cb) {
13
+ startTransition(cb, undefined);
14
+ };
13
15
  }), [startTransition])
14
16
  ];
15
17
  }
@@ -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.useCallback1(cb => startTransition(. cb, None), [startTransition]))
12
+ (isPending, React.useMemo1(() => cb => startTransition(cb, None), [startTransition]))
13
13
  }
14
14
 
15
15
  module SuspenseList = {
@@ -4,10 +4,10 @@ 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
- let useTransition: unit => (bool, React.callback<unit => unit, unit>)
10
+ let useTransition: unit => (bool, (unit => unit) => unit)
11
11
 
12
12
  module SuspenseList: {
13
13
  @module("react") @react.component
@@ -1,7 +1,6 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
  'use strict';
3
3
 
4
- var Curry = require("rescript/lib/js/curry.js");
5
4
  var React = require("react");
6
5
  var Utils = require("./utils");
7
6
  var Belt_Array = require("rescript/lib/js/belt_Array.js");
@@ -50,22 +49,22 @@ function unwrapNormalizationArgument(wrapped) {
50
49
  var match = wrapped.kind;
51
50
  if (match === "Literal") {
52
51
  return {
53
- TAG: /* Literal */1,
52
+ TAG: "Literal",
54
53
  _0: wrapped
55
54
  };
56
55
  } else if (match === "ListValue") {
57
56
  return {
58
- TAG: /* ListValue */0,
57
+ TAG: "ListValue",
59
58
  _0: wrapped
60
59
  };
61
60
  } else if (match === "ObjectValue") {
62
61
  return {
63
- TAG: /* ObjectValue */2,
62
+ TAG: "ObjectValue",
64
63
  _0: wrapped
65
64
  };
66
65
  } else {
67
66
  return {
68
- TAG: /* Variable */3,
67
+ TAG: "Variable",
69
68
  _0: wrapped
70
69
  };
71
70
  }
@@ -102,7 +101,7 @@ var MissingFieldHandler = {
102
101
  var nodeInterfaceMissingFieldHandler = makeLinkedMissingFieldHandler(function (field, record, args, _store) {
103
102
  var match = field.name;
104
103
  var match$1 = args.id;
105
- if ((record == null) || !(match === "node" && record.__typename === RelayRuntime.ROOT_TYPE && !(match$1 == null))) {
104
+ if ((record == null) || !(match === "node" && record.getType() === RelayRuntime.ROOT_TYPE && !(match$1 == null))) {
106
105
  return ;
107
106
  } else {
108
107
  return Caml_option.some(match$1);
@@ -130,8 +129,10 @@ var Store = {
130
129
  make: make
131
130
  };
132
131
 
133
- function toJs(f, arg) {
134
- Curry._3(f, arg.kind, arg.owner, arg.fieldPath);
132
+ function toJs(f) {
133
+ return function (arg) {
134
+ f(arg.kind, arg.owner, arg.fieldPath);
135
+ };
135
136
  }
136
137
 
137
138
  function make$1(network, store, getDataID, treatMissingFieldsAsNull, missingFieldHandlers, requiredFieldLogger, isServer, param) {
@@ -160,15 +161,13 @@ var Environment = {
160
161
  make: make$1
161
162
  };
162
163
 
163
- function RescriptRelay$Context$Provider(Props) {
164
- var environment = Props.environment;
165
- var children = Props.children;
164
+ function RescriptRelay$Context$Provider(props) {
166
165
  var provider = ReactRelay.ReactRelayContext.Provider;
167
166
  return React.createElement(provider, {
168
167
  value: {
169
- environment: environment
168
+ environment: props.environment
170
169
  },
171
- children: children
170
+ children: props.children
172
171
  });
173
172
  }
174
173
 
@@ -182,7 +181,7 @@ var Context = {
182
181
 
183
182
  var EnvironmentNotFoundInContext = /* @__PURE__ */Caml_exceptions.create("RescriptRelay.EnvironmentNotFoundInContext");
184
183
 
185
- function useEnvironmentFromContext(param) {
184
+ function useEnvironmentFromContext() {
186
185
  var context = React.useContext(ReactRelay.ReactRelayContext);
187
186
  if (context !== undefined) {
188
187
  return Caml_option.valFromOption(context).environment;
@@ -193,39 +192,11 @@ function useEnvironmentFromContext(param) {
193
192
  };
194
193
  }
195
194
 
196
- function mapFetchPolicy(x) {
197
- if (x === undefined) {
198
- return ;
199
- }
200
- switch (x) {
201
- case /* StoreOnly */0 :
202
- return "store-only";
203
- case /* StoreOrNetwork */1 :
204
- return "store-or-network";
205
- case /* StoreAndNetwork */2 :
206
- return "store-and-network";
207
- case /* NetworkOnly */3 :
208
- return "network-only";
209
-
210
- }
211
- }
212
-
213
- function mapFetchQueryFetchPolicy(x) {
214
- if (x !== undefined) {
215
- if (x) {
216
- return "store-or-network";
217
- } else {
218
- return "network-only";
219
- }
220
- }
221
-
222
- }
223
-
224
195
  function MakeLoadQuery(C) {
225
196
  var load = function (environment, variables, fetchPolicy, fetchKey, networkCacheConfig, param) {
226
- return ReactRelay.loadQuery(environment, C.query, Curry._1(C.convertVariables, variables), {
197
+ return ReactRelay.loadQuery(environment, C.query, C.convertVariables(variables), {
227
198
  fetchKey: fetchKey,
228
- fetchPolicy: mapFetchPolicy(fetchPolicy),
199
+ fetchPolicy: fetchPolicy,
229
200
  networkCacheConfig: networkCacheConfig
230
201
  });
231
202
  };
@@ -237,9 +208,9 @@ function MakeLoadQuery(C) {
237
208
  var o = queryRefToObservable(token);
238
209
  if (o !== undefined) {
239
210
  Caml_option.valFromOption(o).subscribe({
240
- complete: (function (param) {
211
+ complete: (function () {
241
212
  resolve({
242
- TAG: /* Ok */0,
213
+ TAG: "Ok",
243
214
  _0: undefined
244
215
  });
245
216
  })
@@ -247,7 +218,7 @@ function MakeLoadQuery(C) {
247
218
  return ;
248
219
  } else {
249
220
  return resolve({
250
- TAG: /* Error */1,
221
+ TAG: "Error",
251
222
  _0: undefined
252
223
  });
253
224
  }
@@ -277,8 +248,6 @@ exports.Store = Store;
277
248
  exports.Disposable = Disposable;
278
249
  exports.RequiredFieldLogger = RequiredFieldLogger;
279
250
  exports.Environment = Environment;
280
- exports.mapFetchPolicy = mapFetchPolicy;
281
- exports.mapFetchQueryFetchPolicy = mapFetchQueryFetchPolicy;
282
251
  exports.Context = Context;
283
252
  exports.EnvironmentNotFoundInContext = EnvironmentNotFoundInContext;
284
253
  exports.useEnvironmentFromContext = useEnvironmentFromContext;
@@ -330,7 +330,7 @@ module ReadOnlyRecordSourceProxy = {
330
330
  }
331
331
 
332
332
  module MissingFieldHandler = {
333
- @@ocaml.warning("-30")
333
+ @@warning("-30")
334
334
  type t
335
335
 
336
336
  type normalizationArgumentWrapped = {kind: [#ListValue | #Literal | #ObjectValue | #Variable]}
@@ -412,7 +412,7 @@ let nodeInterfaceMissingFieldHandler = MissingFieldHandler.makeLinkedMissingFiel
412
412
  _store,
413
413
  ) =>
414
414
  switch (Js.Nullable.toOption(record), field["name"], Js.Nullable.toOption(args["id"])) {
415
- | (Some(record), "node", argsId) if record["__typename"] == storeRootType => argsId
415
+ | (Some(record), "node", argsId) if record->RecordProxy.getType == storeRootType => argsId
416
416
  | _ => None
417
417
  }
418
418
  )
@@ -482,9 +482,9 @@ module Observable = {
482
482
  }
483
483
 
484
484
  type sink<'response> = {
485
- next: (. 'response) => unit,
486
- error: (. Js.Exn.t) => unit,
487
- complete: (. unit) => unit,
485
+ next: 'response => unit,
486
+ error: Js.Exn.t => unit,
487
+ complete: unit => unit,
488
488
  closed: bool,
489
489
  }
490
490
 
@@ -492,11 +492,11 @@ module Observable = {
492
492
 
493
493
  @obj
494
494
  external makeObserver: (
495
- ~start: @uncurry subscription => unit=?,
496
- ~next: @uncurry 'response => unit=?,
497
- ~error: @uncurry Js.Exn.t => unit=?,
498
- ~complete: @uncurry unit => unit=?,
499
- ~unsubscribe: @uncurry subscription => unit=?,
495
+ ~start: subscription => unit=?,
496
+ ~next: 'response => unit=?,
497
+ ~error: Js.Exn.t => unit=?,
498
+ ~complete: unit => unit=?,
499
+ ~unsubscribe: subscription => unit=?,
500
500
  unit,
501
501
  ) => observer<'response> = ""
502
502
 
@@ -507,6 +507,8 @@ module Observable = {
507
507
  external subscribe: (t<'response>, observer<'response>) => subscription = "subscribe"
508
508
 
509
509
  @send external toPromise: t<'t> => Js.Promise.t<'t> = "toPromise"
510
+
511
+ external ignoreSubscription: subscription => unit = "%ignore"
510
512
  }
511
513
 
512
514
  module Network = {
@@ -574,8 +576,8 @@ module Store = {
574
576
  make(
575
577
  source,
576
578
  {
577
- gcReleaseBufferSize: gcReleaseBufferSize,
578
- queryCacheExpirationTime: queryCacheExpirationTime,
579
+ gcReleaseBufferSize,
580
+ queryCacheExpirationTime,
579
581
  },
580
582
  )
581
583
 
@@ -593,7 +595,7 @@ module RequiredFieldLogger = {
593
595
 
594
596
  type t = (~kind: kind, ~owner: string, ~fieldPath: string) => unit
595
597
 
596
- let toJs: t => js = (f, arg) =>
598
+ let toJs: t => js = f => arg =>
597
599
  f(~kind=arg["kind"], ~owner=arg["owner"], ~fieldPath=arg["fieldPath"])
598
600
  }
599
601
 
@@ -662,10 +664,7 @@ module Context = {
662
664
  @react.component
663
665
  let make = (~environment: Environment.t, ~children) => {
664
666
  let provider = React.Context.provider(context)
665
- React.createElement(
666
- provider,
667
- {"value": Some({"environment": environment}), "children": children},
668
- )
667
+ React.createElement(provider, {value: Some({"environment": environment}), children})
669
668
  }
670
669
  }
671
670
  }
@@ -682,39 +681,23 @@ let useEnvironmentFromContext = () => {
682
681
  }
683
682
 
684
683
  type fetchPolicy =
685
- | StoreOnly
686
- | StoreOrNetwork
687
- | StoreAndNetwork
688
- | NetworkOnly
689
-
690
- let mapFetchPolicy = x =>
691
- switch x {
692
- | Some(StoreOnly) => Some("store-only")
693
- | Some(StoreOrNetwork) => Some("store-or-network")
694
- | Some(StoreAndNetwork) => Some("store-and-network")
695
- | Some(NetworkOnly) => Some("network-only")
696
- | None => None
697
- }
684
+ | @as("store-only") StoreOnly
685
+ | @as("store-or-network") StoreOrNetwork
686
+ | @as("store-and-network") StoreAndNetwork
687
+ | @as("network-only") NetworkOnly
698
688
 
699
689
  type fetchQueryFetchPolicy =
700
- | NetworkOnly
701
- | StoreOrNetwork
702
-
703
- let mapFetchQueryFetchPolicy = x =>
704
- switch x {
705
- | Some(StoreOrNetwork) => Some("store-or-network")
706
- | Some(NetworkOnly) => Some("network-only")
707
- | None => None
708
- }
690
+ | @as("network-only") NetworkOnly
691
+ | @as("store-or-network") StoreOrNetwork
709
692
 
710
693
  type fetchQueryOptions = {
711
- networkCacheConfig: option<cacheConfig>,
712
- fetchPolicy: option<string>,
694
+ networkCacheConfig?: cacheConfig,
695
+ fetchPolicy?: fetchPolicy,
713
696
  }
714
697
 
715
698
  type loadQueryConfig = {
716
699
  fetchKey: option<string>,
717
- fetchPolicy: option<string>,
700
+ fetchPolicy: option<fetchPolicy>,
718
701
  networkCacheConfig: option<cacheConfig>,
719
702
  }
720
703
 
@@ -752,9 +735,9 @@ module MakeLoadQuery = (C: MakeLoadQueryConfig) => {
752
735
  C.query,
753
736
  variables->C.convertVariables,
754
737
  {
755
- fetchKey: fetchKey,
756
- fetchPolicy: fetchPolicy->mapFetchPolicy,
757
- networkCacheConfig: networkCacheConfig,
738
+ fetchKey,
739
+ fetchPolicy,
740
+ networkCacheConfig,
758
741
  },
759
742
  )
760
743
 
@@ -769,10 +752,10 @@ module MakeLoadQuery = (C: MakeLoadQueryConfig) => {
769
752
  let queryRefToPromise = token => {
770
753
  Js.Promise.make((~resolve, ~reject as _) => {
771
754
  switch token->queryRefToObservable {
772
- | None => resolve(. Error())
755
+ | None => resolve(Error())
773
756
  | Some(o) =>
774
757
  open Observable
775
- let _: subscription = o->subscribe(makeObserver(~complete=() => resolve(. Ok()), ()))
758
+ let _: subscription = o->subscribe(makeObserver(~complete=() => resolve(Ok()), ()))
776
759
  }
777
760
  })
778
761
  }