rescript-relay 1.0.5 → 1.1.1
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 +28 -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 +7 -10
- package/src/RescriptRelay.resi +189 -267
- package/src/RescriptRelayUtils.resi +3 -5
- package/src/utils.js +26 -0
- package/src/utils.mjs +26 -0
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/**Tries to return a record from a nested path of linked records.*/
|
|
2
2
|
let resolveNestedRecord: (
|
|
3
3
|
~rootRecord: option<RescriptRelay.RecordProxy.t>,
|
|
4
4
|
~path: list<string>,
|
|
5
5
|
) => option<RescriptRelay.RecordProxy.t>
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
"Tries to return a record from a nested path of linked records, starting from the root. "
|
|
9
|
-
)
|
|
7
|
+
/**Tries to return a record from a nested path of linked records, starting from the root.*/
|
|
10
8
|
let resolveNestedRecordFromRoot: (
|
|
11
9
|
~store: RescriptRelay.RecordSourceSelectorProxy.t,
|
|
12
10
|
~path: list<string>,
|
|
13
11
|
) => option<RescriptRelay.RecordProxy.t>
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
/**Helpers for handling connections.*/
|
|
16
14
|
type insertAt =
|
|
17
15
|
| Start
|
|
18
16
|
| End
|
package/src/utils.js
CHANGED
|
@@ -87,9 +87,24 @@ function traverse(
|
|
|
87
87
|
var shouldConvertEnum =
|
|
88
88
|
typeof instructions["e"] === "string" && !!converters[instructions["e"]];
|
|
89
89
|
|
|
90
|
+
// This is true for non-arrays that are to be converted
|
|
90
91
|
var shouldConvertCustomField =
|
|
91
92
|
typeof instructions["c"] === "string" && !!converters[instructions["c"]];
|
|
92
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
|
+
|
|
93
108
|
var shouldBlockTraversal = typeof instructions["b"] === "string";
|
|
94
109
|
var allowGoingIntoArray = shouldBlockTraversal
|
|
95
110
|
? instructions["b"] === "a"
|
|
@@ -108,6 +123,15 @@ function traverse(
|
|
|
108
123
|
/**
|
|
109
124
|
* Handle arrays
|
|
110
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
|
+
|
|
111
135
|
if (Array.isArray(currentObj[key])) {
|
|
112
136
|
newObj = getNewObj(newObj, currentObj);
|
|
113
137
|
newObj[key] = currentObj[key].map(function (v) {
|
|
@@ -218,6 +242,8 @@ function traverse(
|
|
|
218
242
|
if (shouldConvertCustomField) {
|
|
219
243
|
newObj = getNewObj(newObj, currentObj);
|
|
220
244
|
newObj[key] = converters[instructions["c"]](v);
|
|
245
|
+
// Ensure that the custom scalar value itself isn't traversed more.
|
|
246
|
+
continue;
|
|
221
247
|
}
|
|
222
248
|
|
|
223
249
|
if (shouldConvertUnion && v != null && typeof v === "object") {
|
package/src/utils.mjs
CHANGED
|
@@ -87,9 +87,24 @@ function traverse(
|
|
|
87
87
|
var shouldConvertEnum =
|
|
88
88
|
typeof instructions["e"] === "string" && !!converters[instructions["e"]];
|
|
89
89
|
|
|
90
|
+
// This is true for non-arrays that are to be converted
|
|
90
91
|
var shouldConvertCustomField =
|
|
91
92
|
typeof instructions["c"] === "string" && !!converters[instructions["c"]];
|
|
92
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
|
+
|
|
93
108
|
var shouldBlockTraversal = typeof instructions["b"] === "string";
|
|
94
109
|
var allowGoingIntoArray = shouldBlockTraversal
|
|
95
110
|
? instructions["b"] === "a"
|
|
@@ -108,6 +123,15 @@ function traverse(
|
|
|
108
123
|
/**
|
|
109
124
|
* Handle arrays
|
|
110
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
|
+
|
|
111
135
|
if (Array.isArray(currentObj[key])) {
|
|
112
136
|
newObj = getNewObj(newObj, currentObj);
|
|
113
137
|
newObj[key] = currentObj[key].map(function (v) {
|
|
@@ -218,6 +242,8 @@ function traverse(
|
|
|
218
242
|
if (shouldConvertCustomField) {
|
|
219
243
|
newObj = getNewObj(newObj, currentObj);
|
|
220
244
|
newObj[key] = converters[instructions["c"]](v);
|
|
245
|
+
// Ensure that the custom scalar value itself isn't traversed more.
|
|
246
|
+
continue;
|
|
221
247
|
}
|
|
222
248
|
|
|
223
249
|
if (shouldConvertUnion && v != null && typeof v === "object") {
|