rescript-relay 1.0.4 → 1.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.
- package/CHANGELOG.md +34 -0
- package/package.json +11 -11
- package/postinstall.js +9 -3
- package/ppx-linux +0 -0
- package/ppx-macos-arm64 +0 -0
- package/ppx-macos-latest +0 -0
- package/ppx-windows-latest +0 -0
- package/relay-compiler-linux-musl/relay +0 -0
- package/relay-compiler-linux-x64/relay +0 -0
- package/relay-compiler-macos-arm64/relay +0 -0
- package/relay-compiler-macos-x64/relay +0 -0
- package/relay-compiler-win-x64/relay.exe +0 -0
- package/src/ReactDOMExperimental.bs.js +4 -0
- package/src/ReactDOMExperimental.res +2 -5
- package/src/RescriptRelay.bs.js +4 -6
- package/src/RescriptRelay.res +6 -9
- package/src/RescriptRelay.resi +2 -2
- package/src/utils.js +38 -0
- package/src/utils.mjs +38 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# master
|
|
2
2
|
|
|
3
|
+
# 1.1.0
|
|
4
|
+
|
|
5
|
+
Notable changes:
|
|
6
|
+
|
|
7
|
+
- _JSX v4 is now required_
|
|
8
|
+
- Relay and @rescript/react upgraded
|
|
9
|
+
- M1 support for the PPX (should speed up builds for anyone on an M1)
|
|
10
|
+
|
|
11
|
+
## Upgrade versions
|
|
12
|
+
|
|
13
|
+
- `react-relay` and `relay-runtime` to `>=15.0.0`
|
|
14
|
+
- `@rescript/react` to `>=0.11.0`
|
|
15
|
+
|
|
16
|
+
## Breaking changes
|
|
17
|
+
|
|
18
|
+
- 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).
|
|
19
|
+
- ReScript `>=10.1` and JSX v4 is now required.
|
|
20
|
+
- 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
|
|
21
|
+
|
|
22
|
+
## Improvements
|
|
23
|
+
|
|
24
|
+
- 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
|
|
25
|
+
- :tada: M1 support for the PPX! This should speed up builds some. https://github.com/zth/rescript-relay/pull/435
|
|
26
|
+
|
|
27
|
+
## Bug Fixes
|
|
28
|
+
|
|
29
|
+
- 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
|
|
30
|
+
|
|
31
|
+
# 1.0.5
|
|
32
|
+
|
|
33
|
+
## Bug Fixes
|
|
34
|
+
|
|
35
|
+
- Fix fairly large performance issue with runtime conversion. This should give a large speedup in certain cases.
|
|
36
|
+
|
|
3
37
|
# 1.0.4
|
|
4
38
|
|
|
5
39
|
## Improvements
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rescript-relay",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"main": "src/RescriptRelay.res",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Gabriel Nordeborn",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"test:ci": "jest --ci --runInBand"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"rescript": "^10.
|
|
43
|
-
"@rescript/react": "0.
|
|
42
|
+
"rescript": "^10.1.3",
|
|
43
|
+
"@rescript/react": "0.11.0",
|
|
44
44
|
"@testing-library/jest-dom": "^5.16.3",
|
|
45
45
|
"@testing-library/react": "^13.0.0-alpha.6",
|
|
46
46
|
"bs-fetch": "^0.5.0",
|
|
@@ -48,22 +48,22 @@
|
|
|
48
48
|
"jest": "^27.2.4",
|
|
49
49
|
"nock": "^11.7.0",
|
|
50
50
|
"node-fetch": "^2.6.0",
|
|
51
|
-
"react": "18.
|
|
52
|
-
"react-dom": "18.
|
|
53
|
-
"react-relay": "
|
|
54
|
-
"relay-runtime": "
|
|
51
|
+
"react": "18.2.0",
|
|
52
|
+
"react-dom": "18.2.0",
|
|
53
|
+
"react-relay": "15.0.0",
|
|
54
|
+
"relay-runtime": "15.0.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"@rescript/react": "*",
|
|
58
|
-
"react-relay": ">=
|
|
58
|
+
"react-relay": ">=15.0.0",
|
|
59
59
|
"relay-runtime": "*",
|
|
60
|
-
"rescript": ">=
|
|
60
|
+
"rescript": ">=10.1.0"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"detect-libc": "^2.0.1"
|
|
64
64
|
},
|
|
65
65
|
"resolutions": {
|
|
66
|
-
"react": "18.
|
|
67
|
-
"react-dom": "18.
|
|
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 "
|
|
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"));
|
|
@@ -165,9 +166,14 @@ switch (platform) {
|
|
|
165
166
|
case "linux":
|
|
166
167
|
copyPlatformBinaries(platform);
|
|
167
168
|
break;
|
|
168
|
-
case "darwin":
|
|
169
|
-
|
|
169
|
+
case "darwin": {
|
|
170
|
+
if (ppxArch() === "arm64") {
|
|
171
|
+
copyPlatformBinaries("macos-arm64");
|
|
172
|
+
} else {
|
|
173
|
+
copyPlatformBinaries("macos-latest");
|
|
174
|
+
}
|
|
170
175
|
break;
|
|
176
|
+
}
|
|
171
177
|
default:
|
|
172
178
|
console.warn("error: no release built for the " + platform + " platform");
|
|
173
179
|
process.exit(1);
|
package/ppx-linux
CHANGED
|
Binary file
|
package/ppx-macos-arm64
ADDED
|
Binary file
|
package/ppx-macos-latest
CHANGED
|
Binary file
|
package/ppx-windows-latest
CHANGED
|
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.
|
|
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
|
}
|
package/src/RescriptRelay.bs.js
CHANGED
|
@@ -102,7 +102,7 @@ var MissingFieldHandler = {
|
|
|
102
102
|
var nodeInterfaceMissingFieldHandler = makeLinkedMissingFieldHandler(function (field, record, args, _store) {
|
|
103
103
|
var match = field.name;
|
|
104
104
|
var match$1 = args.id;
|
|
105
|
-
if ((record == null) || !(match === "node" && record.
|
|
105
|
+
if ((record == null) || !(match === "node" && record.getType() === RelayRuntime.ROOT_TYPE && !(match$1 == null))) {
|
|
106
106
|
return ;
|
|
107
107
|
} else {
|
|
108
108
|
return Caml_option.some(match$1);
|
|
@@ -160,15 +160,13 @@ var Environment = {
|
|
|
160
160
|
make: make$1
|
|
161
161
|
};
|
|
162
162
|
|
|
163
|
-
function RescriptRelay$Context$Provider(
|
|
164
|
-
var environment = Props.environment;
|
|
165
|
-
var children = Props.children;
|
|
163
|
+
function RescriptRelay$Context$Provider(props) {
|
|
166
164
|
var provider = ReactRelay.ReactRelayContext.Provider;
|
|
167
165
|
return React.createElement(provider, {
|
|
168
166
|
value: {
|
|
169
|
-
environment: environment
|
|
167
|
+
environment: props.environment
|
|
170
168
|
},
|
|
171
|
-
children: children
|
|
169
|
+
children: props.children
|
|
172
170
|
});
|
|
173
171
|
}
|
|
174
172
|
|
package/src/RescriptRelay.res
CHANGED
|
@@ -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
|
|
415
|
+
| (Some(record), "node", argsId) if record->RecordProxy.getType == storeRootType => argsId
|
|
416
416
|
| _ => None
|
|
417
417
|
}
|
|
418
418
|
)
|
|
@@ -574,8 +574,8 @@ module Store = {
|
|
|
574
574
|
make(
|
|
575
575
|
source,
|
|
576
576
|
{
|
|
577
|
-
gcReleaseBufferSize
|
|
578
|
-
queryCacheExpirationTime
|
|
577
|
+
gcReleaseBufferSize,
|
|
578
|
+
queryCacheExpirationTime,
|
|
579
579
|
},
|
|
580
580
|
)
|
|
581
581
|
|
|
@@ -662,10 +662,7 @@ module Context = {
|
|
|
662
662
|
@react.component
|
|
663
663
|
let make = (~environment: Environment.t, ~children) => {
|
|
664
664
|
let provider = React.Context.provider(context)
|
|
665
|
-
React.createElement(
|
|
666
|
-
provider,
|
|
667
|
-
{"value": Some({"environment": environment}), "children": children},
|
|
668
|
-
)
|
|
665
|
+
React.createElement(provider, {value: Some({"environment": environment}), children})
|
|
669
666
|
}
|
|
670
667
|
}
|
|
671
668
|
}
|
|
@@ -752,9 +749,9 @@ module MakeLoadQuery = (C: MakeLoadQueryConfig) => {
|
|
|
752
749
|
C.query,
|
|
753
750
|
variables->C.convertVariables,
|
|
754
751
|
{
|
|
755
|
-
fetchKey
|
|
752
|
+
fetchKey,
|
|
756
753
|
fetchPolicy: fetchPolicy->mapFetchPolicy,
|
|
757
|
-
networkCacheConfig
|
|
754
|
+
networkCacheConfig,
|
|
758
755
|
},
|
|
759
756
|
)
|
|
760
757
|
|
package/src/RescriptRelay.resi
CHANGED
|
@@ -519,7 +519,7 @@ module MissingFieldHandler: {
|
|
|
519
519
|
let makeLinkedMissingFieldHandler: (
|
|
520
520
|
(
|
|
521
521
|
normalizationLinkedField,
|
|
522
|
-
Js.Nullable.t<
|
|
522
|
+
Js.Nullable.t<RecordProxy.t>,
|
|
523
523
|
'args,
|
|
524
524
|
ReadOnlyRecordSourceProxy.t,
|
|
525
525
|
) => Js.Nullable.t<dataId>
|
|
@@ -531,7 +531,7 @@ module MissingFieldHandler: {
|
|
|
531
531
|
let makePluralLinkedMissingFieldHandler: (
|
|
532
532
|
(
|
|
533
533
|
normalizationLinkedField,
|
|
534
|
-
Js.Nullable.t<
|
|
534
|
+
Js.Nullable.t<RecordProxy.t>,
|
|
535
535
|
'args,
|
|
536
536
|
ReadOnlyRecordSourceProxy.t,
|
|
537
537
|
) => Js.Nullable.t<array<Js.Nullable.t<dataId>>>
|
package/src/utils.js
CHANGED
|
@@ -49,8 +49,20 @@ function traverse(
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
for (var key in currentObj) {
|
|
52
|
+
// Internal ReScript polymorphic variant representation, ignore.
|
|
52
53
|
if (key === "VAL" || key === "NAME") continue;
|
|
53
54
|
|
|
55
|
+
// Ensure we don't move into internal properties coming from Relay, with the
|
|
56
|
+
// exception of the few names allowed to start with double underscores
|
|
57
|
+
// ("__typename" and "__id"), and any Relay provided variables.
|
|
58
|
+
if (
|
|
59
|
+
key.startsWith("__") &&
|
|
60
|
+
key !== "__typename" &&
|
|
61
|
+
key !== "__id" &&
|
|
62
|
+
!key.startsWith("__relay_internal")
|
|
63
|
+
)
|
|
64
|
+
continue;
|
|
65
|
+
|
|
54
66
|
var isUnion = false;
|
|
55
67
|
var originalValue = currentObj[key];
|
|
56
68
|
|
|
@@ -75,9 +87,24 @@ function traverse(
|
|
|
75
87
|
var shouldConvertEnum =
|
|
76
88
|
typeof instructions["e"] === "string" && !!converters[instructions["e"]];
|
|
77
89
|
|
|
90
|
+
// This is true for non-arrays that are to be converted
|
|
78
91
|
var shouldConvertCustomField =
|
|
79
92
|
typeof instructions["c"] === "string" && !!converters[instructions["c"]];
|
|
80
93
|
|
|
94
|
+
// This is true for arrays that are to be converted. This and the above
|
|
95
|
+
// won't be true at the same time.
|
|
96
|
+
var shouldConvertCustomFieldArray =
|
|
97
|
+
typeof instructions["ca"] === "string" &&
|
|
98
|
+
!!converters[instructions["ca"]];
|
|
99
|
+
|
|
100
|
+
// Special case when this is a custom field that's an array. Ensures we
|
|
101
|
+
// don't accidentally move into the array when we're not supposed to.
|
|
102
|
+
if (shouldConvertCustomFieldArray && Array.isArray(currentObj[key])) {
|
|
103
|
+
newObj = getNewObj(newObj, currentObj);
|
|
104
|
+
newObj[key] = currentObj[key].map(converters[instructions["ca"]]);
|
|
105
|
+
return newObj;
|
|
106
|
+
}
|
|
107
|
+
|
|
81
108
|
var shouldBlockTraversal = typeof instructions["b"] === "string";
|
|
82
109
|
var allowGoingIntoArray = shouldBlockTraversal
|
|
83
110
|
? instructions["b"] === "a"
|
|
@@ -96,6 +123,15 @@ function traverse(
|
|
|
96
123
|
/**
|
|
97
124
|
* Handle arrays
|
|
98
125
|
*/
|
|
126
|
+
|
|
127
|
+
// Special case when this is a custom field that's an array. Ensures we
|
|
128
|
+
// don't accidentally move into the array when we're not supposed to.
|
|
129
|
+
if (shouldConvertCustomField && Array.isArray(currentObj[key])) {
|
|
130
|
+
newObj = getNewObj(newObj, currentObj);
|
|
131
|
+
newObj[key] = converters[instructions["c"]](originalValue);
|
|
132
|
+
return newObj;
|
|
133
|
+
}
|
|
134
|
+
|
|
99
135
|
if (Array.isArray(currentObj[key])) {
|
|
100
136
|
newObj = getNewObj(newObj, currentObj);
|
|
101
137
|
newObj[key] = currentObj[key].map(function (v) {
|
|
@@ -206,6 +242,8 @@ function traverse(
|
|
|
206
242
|
if (shouldConvertCustomField) {
|
|
207
243
|
newObj = getNewObj(newObj, currentObj);
|
|
208
244
|
newObj[key] = converters[instructions["c"]](v);
|
|
245
|
+
// Ensure that the custom scalar value itself isn't traversed more.
|
|
246
|
+
continue;
|
|
209
247
|
}
|
|
210
248
|
|
|
211
249
|
if (shouldConvertUnion && v != null && typeof v === "object") {
|
package/src/utils.mjs
CHANGED
|
@@ -49,8 +49,20 @@ function traverse(
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
for (var key in currentObj) {
|
|
52
|
+
// Internal ReScript polymorphic variant representation, ignore.
|
|
52
53
|
if (key === "VAL" || key === "NAME") continue;
|
|
53
54
|
|
|
55
|
+
// Ensure we don't move into internal properties coming from Relay, with the
|
|
56
|
+
// exception of the few names allowed to start with double underscores
|
|
57
|
+
// ("__typename" and "__id"), and any Relay provided variables.
|
|
58
|
+
if (
|
|
59
|
+
key.startsWith("__") &&
|
|
60
|
+
key !== "__typename" &&
|
|
61
|
+
key !== "__id" &&
|
|
62
|
+
!key.startsWith("__relay_internal")
|
|
63
|
+
)
|
|
64
|
+
continue;
|
|
65
|
+
|
|
54
66
|
var isUnion = false;
|
|
55
67
|
var originalValue = currentObj[key];
|
|
56
68
|
|
|
@@ -75,9 +87,24 @@ function traverse(
|
|
|
75
87
|
var shouldConvertEnum =
|
|
76
88
|
typeof instructions["e"] === "string" && !!converters[instructions["e"]];
|
|
77
89
|
|
|
90
|
+
// This is true for non-arrays that are to be converted
|
|
78
91
|
var shouldConvertCustomField =
|
|
79
92
|
typeof instructions["c"] === "string" && !!converters[instructions["c"]];
|
|
80
93
|
|
|
94
|
+
// This is true for arrays that are to be converted. This and the above
|
|
95
|
+
// won't be true at the same time.
|
|
96
|
+
var shouldConvertCustomFieldArray =
|
|
97
|
+
typeof instructions["ca"] === "string" &&
|
|
98
|
+
!!converters[instructions["ca"]];
|
|
99
|
+
|
|
100
|
+
// Special case when this is a custom field that's an array. Ensures we
|
|
101
|
+
// don't accidentally move into the array when we're not supposed to.
|
|
102
|
+
if (shouldConvertCustomFieldArray && Array.isArray(currentObj[key])) {
|
|
103
|
+
newObj = getNewObj(newObj, currentObj);
|
|
104
|
+
newObj[key] = currentObj[key].map(converters[instructions["ca"]]);
|
|
105
|
+
return newObj;
|
|
106
|
+
}
|
|
107
|
+
|
|
81
108
|
var shouldBlockTraversal = typeof instructions["b"] === "string";
|
|
82
109
|
var allowGoingIntoArray = shouldBlockTraversal
|
|
83
110
|
? instructions["b"] === "a"
|
|
@@ -96,6 +123,15 @@ function traverse(
|
|
|
96
123
|
/**
|
|
97
124
|
* Handle arrays
|
|
98
125
|
*/
|
|
126
|
+
|
|
127
|
+
// Special case when this is a custom field that's an array. Ensures we
|
|
128
|
+
// don't accidentally move into the array when we're not supposed to.
|
|
129
|
+
if (shouldConvertCustomField && Array.isArray(currentObj[key])) {
|
|
130
|
+
newObj = getNewObj(newObj, currentObj);
|
|
131
|
+
newObj[key] = converters[instructions["c"]](originalValue);
|
|
132
|
+
return newObj;
|
|
133
|
+
}
|
|
134
|
+
|
|
99
135
|
if (Array.isArray(currentObj[key])) {
|
|
100
136
|
newObj = getNewObj(newObj, currentObj);
|
|
101
137
|
newObj[key] = currentObj[key].map(function (v) {
|
|
@@ -206,6 +242,8 @@ function traverse(
|
|
|
206
242
|
if (shouldConvertCustomField) {
|
|
207
243
|
newObj = getNewObj(newObj, currentObj);
|
|
208
244
|
newObj[key] = converters[instructions["c"]](v);
|
|
245
|
+
// Ensure that the custom scalar value itself isn't traversed more.
|
|
246
|
+
continue;
|
|
209
247
|
}
|
|
210
248
|
|
|
211
249
|
if (shouldConvertUnion && v != null && typeof v === "object") {
|