rescript-relay 0.0.0-autocodesplit-09ee6f6c

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 (47) hide show
  1. package/CHANGELOG.md +942 -0
  2. package/README.md +111 -0
  3. package/cli/cli.js +472 -0
  4. package/compiler.js +11 -0
  5. package/package.json +65 -0
  6. package/postinstall.js +189 -0
  7. package/ppx-linux +0 -0
  8. package/ppx-macos-arm64 +0 -0
  9. package/ppx-macos-latest +0 -0
  10. package/ppx-windows-latest +0 -0
  11. package/relay-compiler-linux-musl/relay +0 -0
  12. package/relay-compiler-linux-x64/relay +0 -0
  13. package/relay-compiler-macos-arm64/relay +0 -0
  14. package/relay-compiler-macos-x64/relay +0 -0
  15. package/relay-compiler-win-x64/relay.exe +0 -0
  16. package/rescript.json +19 -0
  17. package/src/ReactDOMExperimental.bs.js +23 -0
  18. package/src/ReactDOMExperimental.res +16 -0
  19. package/src/ReactExperimental.bs.js +23 -0
  20. package/src/ReactExperimental.res +21 -0
  21. package/src/ReactExperimental.resi +18 -0
  22. package/src/RescriptRelay.bs.js +329 -0
  23. package/src/RescriptRelay.res +858 -0
  24. package/src/RescriptRelay.resi +897 -0
  25. package/src/RescriptRelayUtils.bs.js +76 -0
  26. package/src/RescriptRelayUtils.res +89 -0
  27. package/src/RescriptRelayUtils.resi +36 -0
  28. package/src/RescriptRelay_Fragment.bs.js +122 -0
  29. package/src/RescriptRelay_Fragment.res +243 -0
  30. package/src/RescriptRelay_Fragment.resi +85 -0
  31. package/src/RescriptRelay_Internal.bs.js +102 -0
  32. package/src/RescriptRelay_Internal.res +71 -0
  33. package/src/RescriptRelay_Internal.resi +20 -0
  34. package/src/RescriptRelay_Mutation.bs.js +57 -0
  35. package/src/RescriptRelay_Mutation.res +144 -0
  36. package/src/RescriptRelay_Mutation.resi +52 -0
  37. package/src/RescriptRelay_Query.bs.js +101 -0
  38. package/src/RescriptRelay_Query.res +177 -0
  39. package/src/RescriptRelay_Query.resi +62 -0
  40. package/src/RescriptRelay_RelayResolvers.bs.js +13 -0
  41. package/src/RescriptRelay_RelayResolvers.res +21 -0
  42. package/src/RescriptRelay_RelayResolvers.resi +10 -0
  43. package/src/RescriptRelay_Subscriptions.bs.js +24 -0
  44. package/src/RescriptRelay_Subscriptions.res +50 -0
  45. package/src/RescriptRelay_Subscriptions.resi +14 -0
  46. package/src/utils.js +418 -0
  47. package/src/utils.mjs +418 -0
@@ -0,0 +1,102 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+ 'use strict';
3
+
4
+ var React = require("react");
5
+ var Js_dict = require("rescript/lib/js/js_dict.js");
6
+ var Caml_obj = require("rescript/lib/js/caml_obj.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
+
11
+ function internal_keepMapFieldsRaw(record, f) {
12
+ return Belt_Option.map(record, (function (obj) {
13
+ return Js_dict.fromArray(Belt_Array.keepMap(Js_dict.entries(obj), f));
14
+ }));
15
+ }
16
+
17
+ function internal_cleanObjectFromUndefinedRaw(record) {
18
+ var v = internal_keepMapFieldsRaw(record, (function (param) {
19
+ var value = param[1];
20
+ if (value !== undefined) {
21
+ return [
22
+ param[0],
23
+ Caml_option.valFromOption(value)
24
+ ];
25
+ }
26
+
27
+ }));
28
+ if (v !== undefined) {
29
+ return Caml_option.valFromOption(v);
30
+ } else {
31
+ return {};
32
+ }
33
+ }
34
+
35
+ function internal_removeUndefinedAndConvertNullsRaw(record) {
36
+ return internal_keepMapFieldsRaw(record, (function (param) {
37
+ var value = param[1];
38
+ var key = param[0];
39
+ var match = Caml_obj.equal(value, Caml_option.some(undefined));
40
+ if (value !== undefined) {
41
+ return [
42
+ key,
43
+ Caml_option.valFromOption(value)
44
+ ];
45
+ } else if (match) {
46
+ return [
47
+ key,
48
+ null
49
+ ];
50
+ } else {
51
+ return ;
52
+ }
53
+ }));
54
+ }
55
+
56
+ function internal_useConvertedValue(convert, v) {
57
+ return React.useMemo((function () {
58
+ return convert(v);
59
+ }), [v]);
60
+ }
61
+
62
+ function internal_nullableToOptionalExnHandler(x) {
63
+ if (x !== undefined) {
64
+ return (function (maybeExn) {
65
+ return x((maybeExn == null) ? undefined : Caml_option.some(maybeExn));
66
+ });
67
+ }
68
+
69
+ }
70
+
71
+ var unwrapUnion = (function unwrapUnion(union, members) {
72
+ if (union != null && members.indexOf(union.__typename) === -1) {
73
+ return Object.assign({}, union, {__typename: "__unselected"});
74
+ }
75
+
76
+ return union;
77
+ });
78
+
79
+ function wrapUnion(union) {
80
+ return union;
81
+ }
82
+
83
+ var applyCodesplitMetadata = (function applyCodesplitMetadata(node, meta) {
84
+ if (node != null && node.params != null) {
85
+ let metadata = node.params.metadata;
86
+ if (metadata == null) {
87
+ node.params.metadata = {codesplits: meta}
88
+ } else if (typeof metadata === "object") {
89
+ node.params.metadata.codesplits = meta
90
+ }
91
+ }
92
+ return node;
93
+ });
94
+
95
+ exports.internal_useConvertedValue = internal_useConvertedValue;
96
+ exports.internal_cleanObjectFromUndefinedRaw = internal_cleanObjectFromUndefinedRaw;
97
+ exports.internal_removeUndefinedAndConvertNullsRaw = internal_removeUndefinedAndConvertNullsRaw;
98
+ exports.internal_nullableToOptionalExnHandler = internal_nullableToOptionalExnHandler;
99
+ exports.unwrapUnion = unwrapUnion;
100
+ exports.wrapUnion = wrapUnion;
101
+ exports.applyCodesplitMetadata = applyCodesplitMetadata;
102
+ /* react Not a pure module */
@@ -0,0 +1,71 @@
1
+ let internal_keepMapFieldsRaw = (record, f) =>
2
+ record
3
+ ->Obj.magic
4
+ ->Belt.Option.map(obj => obj->Js.Dict.entries->Belt.Array.keepMap(f)->Js.Dict.fromArray)
5
+ ->Obj.magic
6
+
7
+ // we need to do this until we can use @obj on record types
8
+ // see https://github.com/rescript-lang/rescript-compiler/pull/5253
9
+ let internal_cleanObjectFromUndefinedRaw = record =>
10
+ switch internal_keepMapFieldsRaw(record, ((key, value)) => {
11
+ switch value {
12
+ | Some(value) => Some((key, value))
13
+ | None => None
14
+ }
15
+ }) {
16
+ | None => /* Relay expects an empty object, not undefined */ %raw(json`{}`)
17
+ | Some(v) => v
18
+ }
19
+
20
+ let internal_removeUndefinedAndConvertNullsRaw = record =>
21
+ internal_keepMapFieldsRaw(record, ((key, value)) => {
22
+ switch (value, value == Some(None)) {
23
+ | (Some(value), _) => Some((key, Js.Nullable.return(value)))
24
+ | (_, true) => Some((key, Js.Nullable.null))
25
+ | (None, _) => None
26
+ }
27
+ })
28
+
29
+ let internal_useConvertedValue = (convert, v) => React.useMemo1(() => convert(v), [v])
30
+
31
+ let internal_nullableToOptionalExnHandler = x =>
32
+ switch x {
33
+ | None => None
34
+ | Some(handler) => Some(maybeExn => maybeExn->Js.Nullable.toOption->handler)
35
+ }
36
+
37
+ @live @unboxed type rec arg = Arg(_): arg
38
+
39
+ let unwrapUnion: ('a, array<string>) => 'a = %raw(`
40
+ function unwrapUnion(union, members) {
41
+ if (union != null && members.indexOf(union.__typename) === -1) {
42
+ return Object.assign({}, union, {__typename: "__unselected"});
43
+ }
44
+
45
+ return union;
46
+ }
47
+ `)
48
+
49
+ let wrapUnion = union => union
50
+
51
+ external internal_resolverFragmentRefsToFragmentRefs: RescriptRelay.resolverFragmentRefs<
52
+ 'a,
53
+ > => RescriptRelay.fragmentRefs<'a> = "%identity"
54
+
55
+ external internal_resolverFragmentRefsToFragmentRefsPlural: RescriptRelay.resolverFragmentRefs<
56
+ 'a,
57
+ > => array<RescriptRelay.fragmentRefs<'a>> = "%identity"
58
+
59
+ let applyCodesplitMetadata: ('node, array<(string, dict<Js.Json.t> => unit)>) => 'node = %raw(`
60
+ function applyCodesplitMetadata(node, meta) {
61
+ if (node != null && node.params != null) {
62
+ let metadata = node.params.metadata;
63
+ if (metadata == null) {
64
+ node.params.metadata = {codesplits: meta}
65
+ } else if (typeof metadata === "object") {
66
+ node.params.metadata.codesplits = meta
67
+ }
68
+ }
69
+ return node;
70
+ }
71
+ `)
@@ -0,0 +1,20 @@
1
+ let internal_useConvertedValue: ('a => 'a, 'a) => 'a
2
+ let internal_cleanObjectFromUndefinedRaw: 't => 't
3
+ let internal_removeUndefinedAndConvertNullsRaw: 't => 't
4
+ let internal_nullableToOptionalExnHandler: option<option<'b> => 'a> => option<
5
+ Js.Nullable.t<'b> => 'a,
6
+ >
7
+ @live @unboxed type rec arg = Arg(_): arg
8
+
9
+ let unwrapUnion: ('a, array<string>) => 'a
10
+ let wrapUnion: 'a => 'a
11
+
12
+ external internal_resolverFragmentRefsToFragmentRefs: RescriptRelay.resolverFragmentRefs<
13
+ 'a,
14
+ > => RescriptRelay.fragmentRefs<'a> = "%identity"
15
+
16
+ external internal_resolverFragmentRefsToFragmentRefsPlural: RescriptRelay.resolverFragmentRefs<
17
+ 'a,
18
+ > => array<RescriptRelay.fragmentRefs<'a>> = "%identity"
19
+
20
+ let applyCodesplitMetadata: ('node, array<(string, dict<Js.Json.t> => unit)>) => 'node
@@ -0,0 +1,57 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+ 'use strict';
3
+
4
+ var React = require("react");
5
+ var Caml_option = require("rescript/lib/js/caml_option.js");
6
+ var ReactRelay = require("react-relay");
7
+ var RelayRuntime = require("relay-runtime");
8
+
9
+ function commitMutation(convertVariables, node, convertResponse, convertWrapRawResponse) {
10
+ return function (environment, variables, optimisticUpdater, optimisticResponse, updater, onCompleted, onError, uploadables) {
11
+ return RelayRuntime.commitMutation(environment, {
12
+ mutation: node,
13
+ variables: convertVariables(variables),
14
+ onCompleted: onCompleted !== undefined ? (function (res, err) {
15
+ onCompleted(convertResponse(res), (err == null) ? undefined : Caml_option.some(err));
16
+ }) : undefined,
17
+ onError: onError,
18
+ optimisticResponse: optimisticResponse !== undefined ? Caml_option.some(convertWrapRawResponse(Caml_option.valFromOption(optimisticResponse))) : undefined,
19
+ optimisticUpdater: optimisticUpdater,
20
+ updater: updater !== undefined ? (function (store, response) {
21
+ updater(store, convertResponse(response));
22
+ }) : undefined,
23
+ uploadables: uploadables
24
+ });
25
+ };
26
+ }
27
+
28
+ function useMutation(convertVariables, node, convertResponse, convertWrapRawResponse) {
29
+ return function () {
30
+ var match = ReactRelay.useMutation(node);
31
+ var mutate = match[0];
32
+ return [
33
+ React.useMemo((function () {
34
+ return function (variables, optimisticUpdater, optimisticResponse, updater, onCompleted, onError, uploadables) {
35
+ return mutate({
36
+ onError: onError,
37
+ onCompleted: onCompleted !== undefined ? (function (res, err) {
38
+ onCompleted(convertResponse(res), (err == null) ? undefined : Caml_option.some(err));
39
+ }) : undefined,
40
+ optimisticResponse: optimisticResponse !== undefined ? Caml_option.some(convertWrapRawResponse(Caml_option.valFromOption(optimisticResponse))) : undefined,
41
+ optimisticUpdater: optimisticUpdater,
42
+ updater: updater !== undefined ? (function (store, response) {
43
+ updater(store, convertResponse(response));
44
+ }) : undefined,
45
+ variables: convertVariables(variables),
46
+ uploadables: uploadables
47
+ });
48
+ };
49
+ }), [mutate]),
50
+ match[1]
51
+ ];
52
+ };
53
+ }
54
+
55
+ exports.commitMutation = commitMutation;
56
+ exports.useMutation = useMutation;
57
+ /* react Not a pure module */
@@ -0,0 +1,144 @@
1
+ open RescriptRelay
2
+
3
+ type updaterFn<'response> = (RecordSourceSelectorProxy.t, 'response) => unit
4
+ type optimisticUpdaterFn = RecordSourceSelectorProxy.t => unit
5
+ type useMutationConfig<'response, 'rawResponse, 'variables> = {
6
+ onError?: mutationError => unit,
7
+ onCompleted?: ('response, option<array<mutationError>>) => unit,
8
+ onUnsubscribe?: unit => unit,
9
+ optimisticResponse?: 'rawResponse,
10
+ optimisticUpdater?: optimisticUpdaterFn,
11
+ updater?: updaterFn<'response>,
12
+ variables: 'variables,
13
+ uploadables?: uploadables,
14
+ }
15
+
16
+ type commitMutationConfigRaw<'m, 'variables, 'response, 'rawResponse> = {
17
+ mutation: mutationNode<'m>,
18
+ variables: 'variables,
19
+ onCompleted?: ('response, Js.Nullable.t<array<mutationError>>) => unit,
20
+ onError?: mutationError => unit,
21
+ optimisticResponse?: 'rawResponse,
22
+ optimisticUpdater?: optimisticUpdaterFn,
23
+ updater?: updaterFn<'response>,
24
+ uploadables?: uploadables,
25
+ }
26
+
27
+ type useMutationConfigRaw<'m, 'variables, 'response, 'rawResponse> = {
28
+ onError?: mutationError => unit,
29
+ onCompleted?: ('response, Js.Nullable.t<array<mutationError>>) => unit,
30
+ onUnsubscribe?: unit => unit,
31
+ optimisticResponse?: 'rawResponse,
32
+ optimisticUpdater?: optimisticUpdaterFn,
33
+ updater?: updaterFn<'response>,
34
+ variables: 'variables,
35
+ uploadables?: uploadables,
36
+ }
37
+
38
+ @module("relay-runtime")
39
+ external commitMutation_: (
40
+ Environment.t,
41
+ commitMutationConfigRaw<'m, 'variables, 'response, 'rawResponse>,
42
+ ) => Disposable.t = "commitMutation"
43
+
44
+ @module("react-relay")
45
+ external useMutation_: 'm => (
46
+ useMutationConfigRaw<'m, 'variables, 'response, 'rawResponse> => Disposable.t,
47
+ bool,
48
+ ) = "useMutation"
49
+
50
+ let commitMutation = (
51
+ ~convertVariables: 'variables => 'variables,
52
+ ~node: 'm,
53
+ ~convertResponse: 'response => 'response,
54
+ ~convertWrapRawResponse: 'rawResponse => 'rawResponse,
55
+ ) => {
56
+ /**Commits the current mutation. Use this outside of React's \
57
+ render. If you're inside render, you should use `Mutation.use` \
58
+ instead, which is more convenient.\n\n\
59
+ ### Optimistic updates\n\
60
+ Remember to annotate your mutation with `@raw_response_type` if \
61
+ you want to do optimistic updates. That'll make Relay emit the \
62
+ required type information for covering everything needed when \
63
+ doing optimistic updates.*/
64
+ (
65
+ ~environment: Environment.t,
66
+ ~variables: 'variables,
67
+ ~optimisticUpdater=?,
68
+ ~optimisticResponse: option<'rawResponse>=?,
69
+ ~updater=?,
70
+ ~onCompleted=?,
71
+ ~onError=?,
72
+ ~uploadables=?,
73
+ ) => {
74
+ commitMutation_(
75
+ environment,
76
+ {
77
+ mutation: node,
78
+ onCompleted: ?switch onCompleted {
79
+ | Some(cb) => Some((res, err) => cb(res->convertResponse, err->Js.Nullable.toOption))
80
+ | None => None
81
+ },
82
+ ?onError,
83
+ optimisticResponse: ?switch optimisticResponse {
84
+ | Some(optimisticResponse) => Some(optimisticResponse->convertWrapRawResponse)
85
+ | None => None
86
+ },
87
+ ?optimisticUpdater,
88
+ updater: ?switch updater {
89
+ | Some(updater) => Some((store, response) => updater(store, response->convertResponse))
90
+ | None => None
91
+ },
92
+ ?uploadables,
93
+ variables: variables->convertVariables,
94
+ },
95
+ )
96
+ }
97
+ }
98
+
99
+ let useMutation = (
100
+ ~convertVariables: 'variables => 'variables,
101
+ ~node: 'm,
102
+ ~convertResponse: 'response => 'response,
103
+ ~convertWrapRawResponse: 'rawResponse => 'rawResponse,
104
+ ) => {
105
+ /**React hook for commiting this mutation.\n\n\
106
+ ### Optimistic updates\n\
107
+ Remember to annotate your mutation with `@raw_response_type` if \
108
+ you want to do optimistic updates. That'll make Relay emit the \
109
+ required type information for covering everything needed when \
110
+ doing optimistic updates.*/
111
+ () => {
112
+ let (mutate, mutating) = useMutation_(node)
113
+ (React.useMemo1(() => {
114
+ (
115
+ ~variables: 'variables,
116
+ ~optimisticUpdater=?,
117
+ ~optimisticResponse: option<'rawResponse>=?,
118
+ ~updater=?,
119
+ ~onCompleted=?,
120
+ ~onError=?,
121
+ ~uploadables=?,
122
+ ) => {
123
+ mutate({
124
+ onCompleted: ?switch onCompleted {
125
+ | Some(cb) => Some((res, err) => cb(res->convertResponse, err->Js.Nullable.toOption))
126
+ | None => None
127
+ },
128
+ ?onError,
129
+ optimisticResponse: ?switch optimisticResponse {
130
+ | Some(optimisticResponse) => Some(optimisticResponse->convertWrapRawResponse)
131
+ | None => None
132
+ },
133
+ ?optimisticUpdater,
134
+ updater: ?switch updater {
135
+ | Some(updater) => Some((store, response) => updater(store, response->convertResponse))
136
+ | None => None
137
+ },
138
+ ?uploadables,
139
+ variables: variables->convertVariables,
140
+ })
141
+ }
142
+ }, [mutate]), mutating)
143
+ }
144
+ }
@@ -0,0 +1,52 @@
1
+ /*** Internal file, do not use directly.*/
2
+
3
+ open RescriptRelay
4
+
5
+ type updaterFn<'response> = (RecordSourceSelectorProxy.t, 'response) => unit
6
+ type optimisticUpdaterFn = RecordSourceSelectorProxy.t => unit
7
+
8
+ @live
9
+ type useMutationConfig<'response, 'rawResponse, 'variables> = {
10
+ onError?: mutationError => unit,
11
+ onCompleted?: ('response, option<array<mutationError>>) => unit,
12
+ onUnsubscribe?: unit => unit,
13
+ optimisticResponse?: 'rawResponse,
14
+ optimisticUpdater?: optimisticUpdaterFn,
15
+ updater?: updaterFn<'response>,
16
+ variables: 'variables,
17
+ uploadables?: uploadables,
18
+ }
19
+
20
+ let commitMutation: (
21
+ ~convertVariables: 'variables => 'variables,
22
+ ~node: mutationNode<'a>,
23
+ ~convertResponse: 'response => 'response,
24
+ ~convertWrapRawResponse: 'rawResponse => 'rawResponse,
25
+ ) => (
26
+ ~environment: Environment.t,
27
+ ~variables: 'variables,
28
+ ~optimisticUpdater: optimisticUpdaterFn=?,
29
+ ~optimisticResponse: 'rawResponse=?,
30
+ ~updater: (RecordSourceSelectorProxy.t, 'response) => unit=?,
31
+ ~onCompleted: ('response, option<array<mutationError>>) => unit=?,
32
+ ~onError: mutationError => unit=?,
33
+ ~uploadables: uploadables=?,
34
+ ) => Disposable.t
35
+
36
+ let useMutation: (
37
+ ~convertVariables: 'variables => 'variables,
38
+ ~node: mutationNode<'node>,
39
+ ~convertResponse: 'response => 'response,
40
+ ~convertWrapRawResponse: 'rawResponse => 'rawResponse,
41
+ ) => unit => (
42
+ (
43
+ ~variables: 'variables,
44
+ ~optimisticUpdater: optimisticUpdaterFn=?,
45
+ ~optimisticResponse: 'rawResponse=?,
46
+ ~updater: (RecordSourceSelectorProxy.t, 'response) => unit=?,
47
+ ~onCompleted: ('response, option<array<mutationError>>) => unit=?,
48
+ ~onError: mutationError => unit=?,
49
+ ~uploadables: uploadables=?,
50
+ ) => Disposable.t,
51
+ bool,
52
+ )
@@ -0,0 +1,101 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+ 'use strict';
3
+
4
+ var React = require("react");
5
+ var Caml_option = require("rescript/lib/js/caml_option.js");
6
+ var Js_promise2 = require("rescript/lib/js/js_promise2.js");
7
+ var ReactRelay = require("react-relay");
8
+ var RelayRuntime = require("relay-runtime");
9
+ var RescriptRelay_Internal = require("./RescriptRelay_Internal.bs.js");
10
+
11
+ function useQuery(convertVariables, node, convertResponse) {
12
+ return function (variables, fetchPolicy, fetchKey, networkCacheConfig) {
13
+ var __x = ReactRelay.useLazyLoadQuery(node, RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(convertVariables(variables)), {
14
+ fetchKey: fetchKey,
15
+ fetchPolicy: fetchPolicy,
16
+ networkCacheConfig: networkCacheConfig
17
+ });
18
+ return RescriptRelay_Internal.internal_useConvertedValue(convertResponse, __x);
19
+ };
20
+ }
21
+
22
+ function useLoader(convertVariables, node, mkQueryRef) {
23
+ return function () {
24
+ var match = ReactRelay.useQueryLoader(node);
25
+ var loadQueryFn = match[1];
26
+ var loadQuery = React.useMemo((function () {
27
+ return function (variables, fetchPolicy, networkCacheConfig) {
28
+ loadQueryFn(convertVariables(variables), {
29
+ fetchPolicy: fetchPolicy,
30
+ networkCacheConfig: networkCacheConfig
31
+ });
32
+ };
33
+ }), [loadQueryFn]);
34
+ return [
35
+ mkQueryRef(Caml_option.nullable_to_opt(match[0])),
36
+ loadQuery,
37
+ match[2]
38
+ ];
39
+ };
40
+ }
41
+
42
+ function usePreloaded(node, convertResponse, mkQueryRef) {
43
+ return function (queryRef) {
44
+ var __x = ReactRelay.usePreloadedQuery(node, mkQueryRef(queryRef));
45
+ return RescriptRelay_Internal.internal_useConvertedValue(convertResponse, __x);
46
+ };
47
+ }
48
+
49
+ function $$fetch(node, convertResponse, convertVariables) {
50
+ return function (environment, variables, onResult, networkCacheConfig, fetchPolicy) {
51
+ ReactRelay.fetchQuery(environment, node, convertVariables(variables), {
52
+ networkCacheConfig: networkCacheConfig,
53
+ fetchPolicy: fetchPolicy
54
+ }).subscribe({
55
+ next: (function (res) {
56
+ onResult({
57
+ TAG: "Ok",
58
+ _0: convertResponse(res)
59
+ });
60
+ }),
61
+ error: (function (err) {
62
+ onResult({
63
+ TAG: "Error",
64
+ _0: err
65
+ });
66
+ })
67
+ });
68
+ };
69
+ }
70
+
71
+ function fetchPromised(node, convertResponse, convertVariables) {
72
+ return function (environment, variables, networkCacheConfig, fetchPolicy) {
73
+ return Js_promise2.then(ReactRelay.fetchQuery(environment, node, convertVariables(variables), {
74
+ networkCacheConfig: networkCacheConfig,
75
+ fetchPolicy: fetchPolicy
76
+ }).toPromise(), (function (res) {
77
+ return Promise.resolve(convertResponse(res));
78
+ }));
79
+ };
80
+ }
81
+
82
+ function retain(node, convertVariables) {
83
+ return function (environment, variables) {
84
+ return environment.retain(RelayRuntime.createOperationDescriptor(node, convertVariables(variables)));
85
+ };
86
+ }
87
+
88
+ function commitLocalPayload(node, convertVariables, convertWrapRawResponse) {
89
+ return function (environment, variables, payload) {
90
+ environment.commitPayload(RelayRuntime.createOperationDescriptor(node, convertVariables(variables)), convertWrapRawResponse(payload));
91
+ };
92
+ }
93
+
94
+ exports.useQuery = useQuery;
95
+ exports.useLoader = useLoader;
96
+ exports.usePreloaded = usePreloaded;
97
+ exports.$$fetch = $$fetch;
98
+ exports.fetchPromised = fetchPromised;
99
+ exports.retain = retain;
100
+ exports.commitLocalPayload = commitLocalPayload;
101
+ /* react Not a pure module */