rescript-relay 0.0.0-unwind-ppx-8e367f1d → 0.0.0-version-3-fe1b653c

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,8 +1,45 @@
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
+
3
39
  ## Improvements
4
40
 
5
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.
6
43
 
7
44
  # 1.1.1
8
45
 
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-unwind-ppx-8e367f1d",
3
+ "version": "0.0.0-version-3-fe1b653c",
4
4
  "main": "src/RescriptRelay.res",
5
5
  "license": "MIT",
6
6
  "author": "Gabriel Nordeborn",
@@ -39,11 +39,10 @@
39
39
  "test:ci": "jest --ci --runInBand"
40
40
  },
41
41
  "devDependencies": {
42
- "rescript": "^11.0.0-beta.1",
42
+ "@glennsl/rescript-fetch": "^0.2.0",
43
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",
@@ -51,13 +50,14 @@
51
50
  "react": "18.2.0",
52
51
  "react-dom": "18.2.0",
53
52
  "react-relay": "15.0.0",
54
- "relay-runtime": "15.0.0"
53
+ "relay-runtime": "15.0.0",
54
+ "rescript": "^11.0.0-beta.2"
55
55
  },
56
56
  "peerDependencies": {
57
- "@rescript/react": "*",
57
+ "@rescript/react": "^0.12.0-alpha.2 || next",
58
58
  "react-relay": ">=15.0.0",
59
59
  "relay-runtime": "*",
60
- "rescript": ">=10.1.0"
60
+ "rescript": "^11.0.0-alpha.0 || next"
61
61
  },
62
62
  "dependencies": {
63
63
  "detect-libc": "^2.0.1"
package/postinstall.js CHANGED
@@ -152,6 +152,10 @@ function removeInitialBinaries() {
152
152
  recursive: true,
153
153
  force: true,
154
154
  });
155
+ fs.rmSync(path.join(__dirname, "relay-compiler-win-x64"), {
156
+ recursive: true,
157
+ force: true,
158
+ });
155
159
  }
156
160
 
157
161
  switch (platform) {
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
@@ -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)
@@ -192,39 +192,11 @@ function useEnvironmentFromContext() {
192
192
  };
193
193
  }
194
194
 
195
- function mapFetchPolicy(x) {
196
- if (x === undefined) {
197
- return ;
198
- }
199
- switch (x) {
200
- case "StoreOnly" :
201
- return "store-only";
202
- case "StoreOrNetwork" :
203
- return "store-or-network";
204
- case "StoreAndNetwork" :
205
- return "store-and-network";
206
- case "NetworkOnly" :
207
- return "network-only";
208
-
209
- }
210
- }
211
-
212
- function mapFetchQueryFetchPolicy(x) {
213
- if (x !== undefined) {
214
- if (x === "NetworkOnly") {
215
- return "network-only";
216
- } else {
217
- return "store-or-network";
218
- }
219
- }
220
-
221
- }
222
-
223
195
  function MakeLoadQuery(C) {
224
196
  var load = function (environment, variables, fetchPolicy, fetchKey, networkCacheConfig, param) {
225
197
  return ReactRelay.loadQuery(environment, C.query, C.convertVariables(variables), {
226
198
  fetchKey: fetchKey,
227
- fetchPolicy: mapFetchPolicy(fetchPolicy),
199
+ fetchPolicy: fetchPolicy,
228
200
  networkCacheConfig: networkCacheConfig
229
201
  });
230
202
  };
@@ -276,8 +248,6 @@ exports.Store = Store;
276
248
  exports.Disposable = Disposable;
277
249
  exports.RequiredFieldLogger = RequiredFieldLogger;
278
250
  exports.Environment = Environment;
279
- exports.mapFetchPolicy = mapFetchPolicy;
280
- exports.mapFetchQueryFetchPolicy = mapFetchQueryFetchPolicy;
281
251
  exports.Context = Context;
282
252
  exports.EnvironmentNotFoundInContext = EnvironmentNotFoundInContext;
283
253
  exports.useEnvironmentFromContext = useEnvironmentFromContext;
@@ -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
 
@@ -681,39 +681,23 @@ let useEnvironmentFromContext = () => {
681
681
  }
682
682
 
683
683
  type fetchPolicy =
684
- | StoreOnly
685
- | StoreOrNetwork
686
- | StoreAndNetwork
687
- | NetworkOnly
688
-
689
- let mapFetchPolicy = x =>
690
- switch x {
691
- | Some(StoreOnly) => Some("store-only")
692
- | Some(StoreOrNetwork) => Some("store-or-network")
693
- | Some(StoreAndNetwork) => Some("store-and-network")
694
- | Some(NetworkOnly) => Some("network-only")
695
- | None => None
696
- }
684
+ | @as("store-only") StoreOnly
685
+ | @as("store-or-network") StoreOrNetwork
686
+ | @as("store-and-network") StoreAndNetwork
687
+ | @as("network-only") NetworkOnly
697
688
 
698
689
  type fetchQueryFetchPolicy =
699
- | NetworkOnly
700
- | StoreOrNetwork
701
-
702
- let mapFetchQueryFetchPolicy = x =>
703
- switch x {
704
- | Some(StoreOrNetwork) => Some("store-or-network")
705
- | Some(NetworkOnly) => Some("network-only")
706
- | None => None
707
- }
690
+ | @as("network-only") NetworkOnly
691
+ | @as("store-or-network") StoreOrNetwork
708
692
 
709
693
  type fetchQueryOptions = {
710
- networkCacheConfig: option<cacheConfig>,
711
- fetchPolicy: option<string>,
694
+ networkCacheConfig?: cacheConfig,
695
+ fetchPolicy?: fetchPolicy,
712
696
  }
713
697
 
714
698
  type loadQueryConfig = {
715
699
  fetchKey: option<string>,
716
- fetchPolicy: option<string>,
700
+ fetchPolicy: option<fetchPolicy>,
717
701
  networkCacheConfig: option<cacheConfig>,
718
702
  }
719
703
 
@@ -752,7 +736,7 @@ module MakeLoadQuery = (C: MakeLoadQueryConfig) => {
752
736
  variables->C.convertVariables,
753
737
  {
754
738
  fetchKey,
755
- fetchPolicy: fetchPolicy->mapFetchPolicy,
739
+ fetchPolicy,
756
740
  networkCacheConfig,
757
741
  },
758
742
  )
@@ -768,10 +752,10 @@ module MakeLoadQuery = (C: MakeLoadQueryConfig) => {
768
752
  let queryRefToPromise = token => {
769
753
  Js.Promise.make((~resolve, ~reject as _) => {
770
754
  switch token->queryRefToObservable {
771
- | None => resolve(. Error())
755
+ | None => resolve(Error())
772
756
  | Some(o) =>
773
757
  open Observable
774
- let _: subscription = o->subscribe(makeObserver(~complete=() => resolve(. Ok()), ()))
758
+ let _: subscription = o->subscribe(makeObserver(~complete=() => resolve(Ok()), ()))
775
759
  }
776
760
  })
777
761
  }
@@ -132,7 +132,7 @@ module RecordProxy: {
132
132
  @send
133
133
  external copyFieldsFrom: (t, ~sourceRecord: t) => unit = "copyFieldsFrom"
134
134
 
135
- /**Gets the \`dataId\` for a particular record.*/
135
+ /**Gets the `dataId` for a particular record.*/
136
136
  @send
137
137
  external getDataId: t => dataId = "getDataID"
138
138
 
@@ -595,10 +595,10 @@ module Observable: {
595
595
  /**Create an observer.*/
596
596
  @obj
597
597
  external makeObserver: (
598
- ~start: @uncurry subscription => unit=?,
599
- ~next: @uncurry 'response => unit=?,
600
- ~error: @uncurry Js.Exn.t => unit=?,
601
- ~complete: @uncurry unit => unit=?,
598
+ ~start: subscription => unit=?,
599
+ ~next: 'response => unit=?,
600
+ ~error: Js.Exn.t => unit=?,
601
+ ~complete: unit => unit=?,
602
602
  ~unsubscribe: subscription => unit=?,
603
603
  unit,
604
604
  ) => observer<'response> = ""
@@ -771,21 +771,27 @@ You should use the generated `Query.retain` function on your queries instead of
771
771
 
772
772
  /**fetchPolicy controls how you want Relay to resolve your data.*/
773
773
  type fetchPolicy =
774
- | StoreOnly /* Resolve only from the store */
775
- | StoreOrNetwork /* Resolve from the store if all data is there, otherwise make a network request */
776
- | StoreAndNetwork /* Like StoreOrNetwork, but always make a request regardless of if the data was there initially or not */
777
- | NetworkOnly /* Always make a request, regardless of what's in the store */
778
-
779
- /**Internal, do not use.*/
780
- let mapFetchPolicy: option<fetchPolicy> => option<string>
774
+ | /** will only reuse locally cached data, and will never send a network request to fetch the query. In this case, the responsibility of fetching the query falls to the caller, but this policy could also be used to read and operate on data that is entirely local. */
775
+ @as("store-only")
776
+ StoreOnly
777
+ | /** (default) will reuse locally cached data, and will only send a network request if any data for the query is missing or stale. If the query is fully cached, a network request will not be made.*/
778
+ @as("store-or-network")
779
+ StoreOrNetwork
780
+ | /** will reuse locally cached data and will always send a network request, regardless of whether any data was missing or stale in the store. */
781
+ @as("store-and-network")
782
+ StoreAndNetwork
783
+ | /** will not reuse locally cached data, and will always send a network request to fetch the query, ignoring any data that might be locally cached and whether it's missing or stale. */
784
+ @as("network-only")
785
+ NetworkOnly
781
786
 
782
787
  /**The fetch policies allowed for fetching a query outside of React's render (as in `Query.fetch`).*/
783
788
  type fetchQueryFetchPolicy =
784
- | NetworkOnly
785
- | StoreOrNetwork
786
-
787
- /**Internal, do not use.*/
788
- let mapFetchQueryFetchPolicy: option<fetchQueryFetchPolicy> => option<string>
789
+ | /** will not reuse locally cached data, and will always send a network request to fetch the query, ignoring any data that might be locally cached and whether it's missing or stale. */
790
+ @as("network-only")
791
+ NetworkOnly
792
+ | /** (default) will reuse locally cached data, and will only send a network request if any data for the query is missing or stale. If the query is fully cached, a network request will not be made.*/
793
+ @as("store-or-network")
794
+ StoreOrNetwork
789
795
 
790
796
  /**An error from a mutation.*/
791
797
  type mutationError = {message: string}
@@ -835,8 +841,8 @@ external useSubscribeToInvalidationState: (array<dataId>, unit => unit) => Dispo
835
841
 
836
842
  /**Options valid when fetching a query outside of React's render method (like when using `Query.fetch`).*/
837
843
  type fetchQueryOptions = {
838
- networkCacheConfig: option<cacheConfig>,
839
- fetchPolicy: option<string>,
844
+ networkCacheConfig?: cacheConfig,
845
+ fetchPolicy?: fetchPolicy,
840
846
  }
841
847
 
842
848
  module type MakeLoadQueryConfig = {
@@ -4,7 +4,6 @@
4
4
  var React = require("react");
5
5
  var Caml_option = require("rescript/lib/js/caml_option.js");
6
6
  var ReactRelay = require("react-relay");
7
- var RescriptRelay = require("./RescriptRelay.bs.js");
8
7
  var RescriptRelay_Internal = require("./RescriptRelay_Internal.bs.js");
9
8
 
10
9
  function useFragment(node, convertFragment, fRef) {
@@ -28,7 +27,7 @@ function readInlineData(node, convertFragment, fRef) {
28
27
 
29
28
  function internal_makeRefetchableFnOpts(fetchPolicy, onComplete, param) {
30
29
  return {
31
- fetchPolicy: RescriptRelay.mapFetchPolicy(fetchPolicy),
30
+ fetchPolicy: fetchPolicy,
32
31
  onComplete: RescriptRelay_Internal.internal_nullableToOptionalExnHandler(onComplete)
33
32
  };
34
33
  }
@@ -53,12 +53,12 @@ let readInlineData = (~node, ~convertFragment: 'fragment => 'fragment, ~fRef) =>
53
53
  }
54
54
 
55
55
  type refetchableFnOpts = {
56
- fetchPolicy?: string,
56
+ fetchPolicy?: fetchPolicy,
57
57
  onComplete?: Js.Nullable.t<Js.Exn.t> => unit,
58
58
  }
59
59
 
60
60
  let internal_makeRefetchableFnOpts = (~fetchPolicy=?, ~onComplete=?, ()) => {
61
- fetchPolicy: ?fetchPolicy->mapFetchPolicy,
61
+ ?fetchPolicy,
62
62
  onComplete: ?onComplete->RescriptRelay_Internal.internal_nullableToOptionalExnHandler,
63
63
  }
64
64
 
@@ -12,7 +12,7 @@ function commitMutation(convertVariables, node, convertResponse, convertWrapRawR
12
12
  mutation: node,
13
13
  variables: convertVariables(variables),
14
14
  onCompleted: onCompleted !== undefined ? (function (res, err) {
15
- onCompleted(convertResponse(res), err);
15
+ onCompleted(convertResponse(res), (err == null) ? undefined : Caml_option.some(err));
16
16
  }) : undefined,
17
17
  onError: onError,
18
18
  optimisticResponse: optimisticResponse !== undefined ? Caml_option.some(convertWrapRawResponse(Caml_option.valFromOption(optimisticResponse))) : undefined,
@@ -35,7 +35,7 @@ function useMutation(convertVariables, node, convertResponse, convertWrapRawResp
35
35
  return mutate({
36
36
  onError: onError,
37
37
  onCompleted: onCompleted !== undefined ? (function (res, err) {
38
- onCompleted(convertResponse(res), err);
38
+ onCompleted(convertResponse(res), (err == null) ? undefined : Caml_option.some(err));
39
39
  }) : undefined,
40
40
  optimisticResponse: optimisticResponse !== undefined ? Caml_option.some(convertWrapRawResponse(Caml_option.valFromOption(optimisticResponse))) : undefined,
41
41
  optimisticUpdater: optimisticUpdater,
@@ -17,7 +17,7 @@ type commitMutationConfigRaw<'m, 'variables, 'response, 'rawResponse> = {
17
17
  mutation: mutationNode<'m>,
18
18
  variables: 'variables,
19
19
  onCompleted?: ('response, Js.Nullable.t<array<mutationError>>) => unit,
20
- onError?: Js.Nullable.t<mutationError> => unit,
20
+ onError?: mutationError => unit,
21
21
  optimisticResponse?: 'rawResponse,
22
22
  optimisticUpdater?: optimisticUpdaterFn,
23
23
  updater?: updaterFn<'response>,
@@ -25,7 +25,7 @@ type commitMutationConfigRaw<'m, 'variables, 'response, 'rawResponse> = {
25
25
  }
26
26
 
27
27
  type useMutationConfigRaw<'m, 'variables, 'response, 'rawResponse> = {
28
- onError?: Js.Nullable.t<mutationError> => unit,
28
+ onError?: mutationError => unit,
29
29
  onCompleted?: ('response, Js.Nullable.t<array<mutationError>>) => unit,
30
30
  onUnsubscribe?: unit => unit,
31
31
  optimisticResponse?: 'rawResponse,
@@ -77,7 +77,7 @@ let commitMutation = (
77
77
  {
78
78
  mutation: node,
79
79
  onCompleted: ?switch onCompleted {
80
- | Some(cb) => Some((res, err) => cb(res->convertResponse, err))
80
+ | Some(cb) => Some((res, err) => cb(res->convertResponse, err->Js.Nullable.toOption))
81
81
  | None => None
82
82
  },
83
83
  ?onError,
@@ -124,7 +124,7 @@ let useMutation = (
124
124
  ) => {
125
125
  mutate({
126
126
  onCompleted: ?switch onCompleted {
127
- | Some(cb) => Some((res, err) => cb(res->convertResponse, err))
127
+ | Some(cb) => Some((res, err) => cb(res->convertResponse, err->Js.Nullable.toOption))
128
128
  | None => None
129
129
  },
130
130
  ?onError,
@@ -28,8 +28,8 @@ let commitMutation: (
28
28
  ~optimisticUpdater: optimisticUpdaterFn=?,
29
29
  ~optimisticResponse: 'rawResponse=?,
30
30
  ~updater: (RecordSourceSelectorProxy.t, 'response) => unit=?,
31
- ~onCompleted: ('response, Js.Nullable.t<array<mutationError>>) => unit=?,
32
- ~onError: Js.Nullable.t<mutationError> => unit=?,
31
+ ~onCompleted: ('response, option<array<mutationError>>) => unit=?,
32
+ ~onError: mutationError => unit=?,
33
33
  ~uploadables: uploadables=?,
34
34
  unit,
35
35
  ) => Disposable.t
@@ -45,8 +45,8 @@ let useMutation: (
45
45
  ~optimisticUpdater: optimisticUpdaterFn=?,
46
46
  ~optimisticResponse: 'rawResponse=?,
47
47
  ~updater: (RecordSourceSelectorProxy.t, 'response) => unit=?,
48
- ~onCompleted: ('response, Js.Nullable.t<array<mutationError>>) => unit=?,
49
- ~onError: Js.Nullable.t<mutationError> => unit=?,
48
+ ~onCompleted: ('response, option<array<mutationError>>) => unit=?,
49
+ ~onError: mutationError => unit=?,
50
50
  ~uploadables: uploadables=?,
51
51
  unit,
52
52
  ) => Disposable.t,
@@ -5,7 +5,6 @@ var React = require("react");
5
5
  var Caml_option = require("rescript/lib/js/caml_option.js");
6
6
  var Js_promise2 = require("rescript/lib/js/js_promise2.js");
7
7
  var ReactRelay = require("react-relay");
8
- var RescriptRelay = require("./RescriptRelay.bs.js");
9
8
  var RelayRuntime = require("relay-runtime");
10
9
  var RescriptRelay_Internal = require("./RescriptRelay_Internal.bs.js");
11
10
 
@@ -13,7 +12,7 @@ function useQuery(convertVariables, node, convertResponse) {
13
12
  return function (variables, fetchPolicy, fetchKey, networkCacheConfig, param) {
14
13
  var __x = ReactRelay.useLazyLoadQuery(node, RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(convertVariables(variables)), {
15
14
  fetchKey: fetchKey,
16
- fetchPolicy: RescriptRelay.mapFetchPolicy(fetchPolicy),
15
+ fetchPolicy: fetchPolicy,
17
16
  networkCacheConfig: networkCacheConfig
18
17
  });
19
18
  return RescriptRelay_Internal.internal_useConvertedValue(convertResponse, __x);
@@ -27,7 +26,7 @@ function useLoader(convertVariables, node, mkQueryRef) {
27
26
  var loadQuery = React.useMemo((function () {
28
27
  return function (variables, fetchPolicy, networkCacheConfig, param) {
29
28
  loadQueryFn(convertVariables(variables), {
30
- fetchPolicy: RescriptRelay.mapFetchPolicy(fetchPolicy),
29
+ fetchPolicy: fetchPolicy,
31
30
  networkCacheConfig: networkCacheConfig
32
31
  });
33
32
  };
@@ -51,7 +50,7 @@ function $$fetch(node, convertResponse, convertVariables) {
51
50
  return function (environment, variables, onResult, networkCacheConfig, fetchPolicy, param) {
52
51
  ReactRelay.fetchQuery(environment, node, convertVariables(variables), {
53
52
  networkCacheConfig: networkCacheConfig,
54
- fetchPolicy: RescriptRelay.mapFetchPolicy(fetchPolicy)
53
+ fetchPolicy: fetchPolicy
55
54
  }).subscribe({
56
55
  next: (function (res) {
57
56
  onResult({
@@ -73,7 +72,7 @@ function fetchPromised(node, convertResponse, convertVariables) {
73
72
  return function (environment, variables, networkCacheConfig, fetchPolicy, param) {
74
73
  return Js_promise2.then(ReactRelay.fetchQuery(environment, node, convertVariables(variables), {
75
74
  networkCacheConfig: networkCacheConfig,
76
- fetchPolicy: RescriptRelay.mapFetchPolicy(fetchPolicy)
75
+ fetchPolicy: fetchPolicy
77
76
  }).toPromise(), (function (res) {
78
77
  return Promise.resolve(convertResponse(res));
79
78
  }));
@@ -2,7 +2,7 @@ open RescriptRelay
2
2
 
3
3
  type useQueryConfig = {
4
4
  fetchKey?: string,
5
- fetchPolicy?: string,
5
+ fetchPolicy?: fetchPolicy,
6
6
  networkCacheConfig?: cacheConfig,
7
7
  }
8
8
 
@@ -28,7 +28,7 @@ let useQuery = (
28
28
  RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(variables->convertVariables),
29
29
  {
30
30
  ?fetchKey,
31
- fetchPolicy: ?fetchPolicy->mapFetchPolicy,
31
+ ?fetchPolicy,
32
32
  ?networkCacheConfig,
33
33
  },
34
34
  )->(RescriptRelay_Internal.internal_useConvertedValue(convertResponse, _))
@@ -36,7 +36,7 @@ let useQuery = (
36
36
  }
37
37
 
38
38
  type useQueryLoaderOptions = {
39
- fetchPolicy?: string,
39
+ fetchPolicy?: fetchPolicy,
40
40
  networkCacheConfig?: cacheConfig,
41
41
  }
42
42
 
@@ -56,10 +56,7 @@ let useLoader = (
56
56
  let (nullableQueryRef, loadQueryFn, disposableFn) = useQueryLoader(node)
57
57
  let loadQuery = React.useMemo1(
58
58
  () => (~variables, ~fetchPolicy=?, ~networkCacheConfig=?, ()) =>
59
- loadQueryFn(
60
- variables->convertVariables,
61
- {fetchPolicy: ?fetchPolicy->mapFetchPolicy, ?networkCacheConfig},
62
- ),
59
+ loadQueryFn(variables->convertVariables, {?fetchPolicy, ?networkCacheConfig}),
63
60
  [loadQueryFn],
64
61
  )
65
62
  (nullableQueryRef->Js.Nullable.toOption->mkQueryRef, loadQuery, disposableFn)
@@ -117,7 +114,7 @@ let fetch = (
117
114
  environment,
118
115
  node,
119
116
  variables->convertVariables,
120
- Some({networkCacheConfig, fetchPolicy: fetchPolicy->mapFetchPolicy}),
117
+ Some({?networkCacheConfig, ?fetchPolicy}),
121
118
  )
122
119
  ->subscribe(
123
120
  makeObserver(
@@ -147,7 +144,7 @@ let fetchPromised = (
147
144
  environment,
148
145
  node,
149
146
  variables->convertVariables,
150
- Some({networkCacheConfig, fetchPolicy: fetchPolicy->mapFetchPolicy}),
147
+ Some({?networkCacheConfig, ?fetchPolicy}),
151
148
  )
152
149
  ->Observable.toPromise
153
150
  ->Js.Promise2.then(res => res->convertResponse->Js.Promise2.resolve)
package/src/utils.js CHANGED
@@ -118,8 +118,6 @@ function traverse(
118
118
  var shouldConvertUnion =
119
119
  typeof instructions["u"] === "string" && !!converters[instructions["u"]];
120
120
 
121
- var isTopLevelNodeField = typeof instructions["tnf"] === "string";
122
-
123
121
  /**
124
122
  * Handle arrays
125
123
  */
@@ -219,21 +217,6 @@ function traverse(
219
217
  continue;
220
218
  }
221
219
 
222
- if (isTopLevelNodeField) {
223
- // If this is a top level node field we should try and convert, ensure
224
- // it conforms to the desired shape (has the correct typename). If not,
225
- // null it and return right away.
226
- if (
227
- v == null ||
228
- !v.hasOwnProperty("__typename") ||
229
- v.__typename !== instructions["tnf"]
230
- ) {
231
- newObj = getNewObj(newObj, currentObj);
232
- newObj[key] = nullableValue;
233
- return newObj;
234
- }
235
- }
236
-
237
220
  if (shouldConvertEnum) {
238
221
  newObj = getNewObj(newObj, currentObj);
239
222
  newObj[key] = converters[instructions["e"]](v);
package/src/utils.mjs CHANGED
@@ -118,8 +118,6 @@ function traverse(
118
118
  var shouldConvertUnion =
119
119
  typeof instructions["u"] === "string" && !!converters[instructions["u"]];
120
120
 
121
- var isTopLevelNodeField = typeof instructions["tnf"] === "string";
122
-
123
121
  /**
124
122
  * Handle arrays
125
123
  */
@@ -219,21 +217,6 @@ function traverse(
219
217
  continue;
220
218
  }
221
219
 
222
- if (isTopLevelNodeField) {
223
- // If this is a top level node field we should try and convert, ensure
224
- // it conforms to the desired shape (has the correct typename). If not,
225
- // null it and return right away.
226
- if (
227
- v == null ||
228
- !v.hasOwnProperty("__typename") ||
229
- v.__typename !== instructions["tnf"]
230
- ) {
231
- newObj = getNewObj(newObj, currentObj);
232
- newObj[key] = nullableValue;
233
- return newObj;
234
- }
235
- }
236
-
237
220
  if (shouldConvertEnum) {
238
221
  newObj = getNewObj(newObj, currentObj);
239
222
  newObj[key] = converters[instructions["e"]](v);