rescript-relay 1.0.0-beta.15 → 1.0.0-beta.16
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 +6 -1
- package/package.json +3 -3
- package/postinstall.js +4 -0
- package/ppx-darwin +0 -0
- package/ppx-linux +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/src/utils.js +80 -42
- package/src/utils.mjs +80 -42
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# master
|
|
2
2
|
|
|
3
|
-
# 1.0.0-beta.
|
|
3
|
+
# 1.0.0-beta.16
|
|
4
4
|
|
|
5
5
|
_[Here's a commit showing a project being upgraded to this version](https://github.com/zth/rescript-relay/commit/5831c2f1f0f13eedc1cb60468c32fd32b2dc01d3)_
|
|
6
6
|
|
|
@@ -48,6 +48,11 @@ You can go ahead and remove these packages, that are no longer needed, as the co
|
|
|
48
48
|
|
|
49
49
|
### unreleased
|
|
50
50
|
|
|
51
|
+
### beta.16
|
|
52
|
+
|
|
53
|
+
- Fix bug that caused issues when using unions in optimistic responses and `commitLocalPayload`.
|
|
54
|
+
- Add support for experimental [Relay Resolvers](https://relay.dev/docs/next/guides/relay-resolvers). Undocumented so far, but looking at the [test](https://github.com/zth/rescript-relay/blob/master/packages/rescript-relay/__tests__/Test_relayResolvers.res) and [definition file](https://github.com/zth/rescript-relay/blob/master/packages/rescript-relay/__tests__/TestRelayUserResolver.res) should give you a hint of how it works.
|
|
55
|
+
|
|
51
56
|
### beta.15
|
|
52
57
|
|
|
53
58
|
- Fixes for input objects.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rescript-relay",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.16",
|
|
4
4
|
"main": "src/RescriptRelay.res",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Gabriel Nordeborn",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"node-fetch": "^2.6.0",
|
|
50
50
|
"react": "^18.0.0-rc.0",
|
|
51
51
|
"react-dom": "^18.0.0-rc.0",
|
|
52
|
-
"react-relay": "13.
|
|
53
|
-
"relay-runtime": "13.
|
|
52
|
+
"react-relay": "13.2.0",
|
|
53
|
+
"relay-runtime": "13.2.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@rescript/react": "*",
|
package/postinstall.js
CHANGED
package/ppx-darwin
CHANGED
|
Binary file
|
package/ppx-linux
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/utils.js
CHANGED
|
@@ -10,6 +10,19 @@ function makeNewPath(currentPath, newKeys) {
|
|
|
10
10
|
return [].concat(currentPath, newKeys);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
function getTypename(v) {
|
|
14
|
+
if (v != null && typeof v === "object") {
|
|
15
|
+
if (v.__typename) {
|
|
16
|
+
return v.__typename;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// `v.VAL` relies on internal implementation details in ReScript.
|
|
20
|
+
if (v.VAL != null && typeof v.VAL === "object") {
|
|
21
|
+
return v.VAL.__typename;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
13
26
|
/**
|
|
14
27
|
* Runs on each object in the tree and follows the provided instructions
|
|
15
28
|
* to apply transforms etc.
|
|
@@ -36,6 +49,8 @@ function traverse(
|
|
|
36
49
|
}
|
|
37
50
|
|
|
38
51
|
for (var key in currentObj) {
|
|
52
|
+
if (key === "VAL" || key === "NAME") continue;
|
|
53
|
+
|
|
39
54
|
var isUnion = false;
|
|
40
55
|
var originalValue = currentObj[key];
|
|
41
56
|
|
|
@@ -96,30 +111,41 @@ function traverse(
|
|
|
96
111
|
return converters[instructions["c"]](v);
|
|
97
112
|
}
|
|
98
113
|
|
|
99
|
-
if (
|
|
100
|
-
|
|
101
|
-
typeof v === "object" &&
|
|
102
|
-
typeof v.__typename === "string"
|
|
103
|
-
) {
|
|
104
|
-
isUnion = true;
|
|
114
|
+
if (shouldConvertUnion && v != null && typeof v === "object") {
|
|
115
|
+
var typename = getTypename(v);
|
|
105
116
|
|
|
106
|
-
|
|
117
|
+
if (typename != null) {
|
|
118
|
+
isUnion = true;
|
|
119
|
+
var unionObj = v;
|
|
107
120
|
|
|
108
|
-
|
|
109
|
-
(
|
|
121
|
+
// Means we're wrapping, and this will be a ReScript value.
|
|
122
|
+
if (nullableValue === null) {
|
|
123
|
+
// Convert it back to a flat JS value
|
|
124
|
+
unionObj = converters[instructions["u"]](v);
|
|
125
|
+
}
|
|
110
126
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
instructionMap,
|
|
116
|
-
converters,
|
|
117
|
-
nullableValue,
|
|
118
|
-
instructionPaths,
|
|
119
|
-
unionRootHasFragment
|
|
120
|
-
);
|
|
127
|
+
var newPath = makeNewPath(currentPath, [key, typename]);
|
|
128
|
+
|
|
129
|
+
var unionRootHasFragment =
|
|
130
|
+
(instructionMap[getPathName(newPath)] || {}).f === "";
|
|
121
131
|
|
|
122
|
-
|
|
132
|
+
var traversedValue = traverse(
|
|
133
|
+
fullInstructionMap,
|
|
134
|
+
newPath,
|
|
135
|
+
unionObj,
|
|
136
|
+
instructionMap,
|
|
137
|
+
converters,
|
|
138
|
+
nullableValue,
|
|
139
|
+
instructionPaths,
|
|
140
|
+
unionRootHasFragment
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
// Undefined means we're going from JS to ReScript, in which case we
|
|
144
|
+
// need to run the conversion here rather than earlier.
|
|
145
|
+
return nullableValue === undefined
|
|
146
|
+
? converters[instructions["u"]](traversedValue)
|
|
147
|
+
: traversedValue;
|
|
148
|
+
}
|
|
123
149
|
}
|
|
124
150
|
|
|
125
151
|
if (shouldAddFragmentFn && typeof v === "object") {
|
|
@@ -168,32 +194,44 @@ function traverse(
|
|
|
168
194
|
newObj[key] = converters[instructions["c"]](v);
|
|
169
195
|
}
|
|
170
196
|
|
|
171
|
-
if (
|
|
172
|
-
|
|
173
|
-
v != null &&
|
|
174
|
-
typeof v === "object" &&
|
|
175
|
-
typeof v.__typename === "string"
|
|
176
|
-
) {
|
|
177
|
-
isUnion = true;
|
|
197
|
+
if (shouldConvertUnion && v != null && typeof v === "object") {
|
|
198
|
+
var typename = getTypename(v);
|
|
178
199
|
|
|
179
|
-
|
|
200
|
+
if (typename != null) {
|
|
201
|
+
isUnion = true;
|
|
202
|
+
var unionObj = v;
|
|
180
203
|
|
|
181
|
-
|
|
182
|
-
(
|
|
204
|
+
// Means we're wrapping, and this will be a ReScript value.
|
|
205
|
+
if (nullableValue === null) {
|
|
206
|
+
// Convert it back to a flat JS value
|
|
207
|
+
unionObj = converters[instructions["u"]](v);
|
|
208
|
+
}
|
|
183
209
|
|
|
184
|
-
|
|
185
|
-
fullInstructionMap,
|
|
186
|
-
newPath,
|
|
187
|
-
v,
|
|
188
|
-
instructionMap,
|
|
189
|
-
converters,
|
|
190
|
-
nullableValue,
|
|
191
|
-
instructionPaths,
|
|
192
|
-
unionRootHasFragment
|
|
193
|
-
);
|
|
210
|
+
var newPath = makeNewPath(currentPath, [key, typename]);
|
|
194
211
|
|
|
195
|
-
|
|
196
|
-
|
|
212
|
+
var unionRootHasFragment =
|
|
213
|
+
(instructionMap[getPathName(newPath)] || {}).f === "";
|
|
214
|
+
|
|
215
|
+
var traversedValue = traverse(
|
|
216
|
+
fullInstructionMap,
|
|
217
|
+
newPath,
|
|
218
|
+
unionObj,
|
|
219
|
+
instructionMap,
|
|
220
|
+
converters,
|
|
221
|
+
nullableValue,
|
|
222
|
+
instructionPaths,
|
|
223
|
+
unionRootHasFragment
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
newObj = getNewObj(newObj, currentObj);
|
|
227
|
+
|
|
228
|
+
newObj[key] =
|
|
229
|
+
// Undefined means we're going from JS to ReScript, in which case we
|
|
230
|
+
// need to run the conversion here rather than earlier.
|
|
231
|
+
nullableValue === undefined
|
|
232
|
+
? converters[instructions["u"]](traversedValue)
|
|
233
|
+
: traversedValue;
|
|
234
|
+
}
|
|
197
235
|
}
|
|
198
236
|
|
|
199
237
|
if (shouldAddFragmentFn && typeof v === "object") {
|
package/src/utils.mjs
CHANGED
|
@@ -10,6 +10,19 @@ function makeNewPath(currentPath, newKeys) {
|
|
|
10
10
|
return [].concat(currentPath, newKeys);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
function getTypename(v) {
|
|
14
|
+
if (v != null && typeof v === "object") {
|
|
15
|
+
if (v.__typename) {
|
|
16
|
+
return v.__typename;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// `v.VAL` relies on internal implementation details in ReScript.
|
|
20
|
+
if (v.VAL != null && typeof v.VAL === "object") {
|
|
21
|
+
return v.VAL.__typename;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
13
26
|
/**
|
|
14
27
|
* Runs on each object in the tree and follows the provided instructions
|
|
15
28
|
* to apply transforms etc.
|
|
@@ -36,6 +49,8 @@ function traverse(
|
|
|
36
49
|
}
|
|
37
50
|
|
|
38
51
|
for (var key in currentObj) {
|
|
52
|
+
if (key === "VAL" || key === "NAME") continue;
|
|
53
|
+
|
|
39
54
|
var isUnion = false;
|
|
40
55
|
var originalValue = currentObj[key];
|
|
41
56
|
|
|
@@ -96,30 +111,41 @@ function traverse(
|
|
|
96
111
|
return converters[instructions["c"]](v);
|
|
97
112
|
}
|
|
98
113
|
|
|
99
|
-
if (
|
|
100
|
-
|
|
101
|
-
typeof v === "object" &&
|
|
102
|
-
typeof v.__typename === "string"
|
|
103
|
-
) {
|
|
104
|
-
isUnion = true;
|
|
114
|
+
if (shouldConvertUnion && v != null && typeof v === "object") {
|
|
115
|
+
var typename = getTypename(v);
|
|
105
116
|
|
|
106
|
-
|
|
117
|
+
if (typename != null) {
|
|
118
|
+
isUnion = true;
|
|
119
|
+
var unionObj = v;
|
|
107
120
|
|
|
108
|
-
|
|
109
|
-
(
|
|
121
|
+
// Means we're wrapping, and this will be a ReScript value.
|
|
122
|
+
if (nullableValue === null) {
|
|
123
|
+
// Convert it back to a flat JS value
|
|
124
|
+
unionObj = converters[instructions["u"]](v);
|
|
125
|
+
}
|
|
110
126
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
instructionMap,
|
|
116
|
-
converters,
|
|
117
|
-
nullableValue,
|
|
118
|
-
instructionPaths,
|
|
119
|
-
unionRootHasFragment
|
|
120
|
-
);
|
|
127
|
+
var newPath = makeNewPath(currentPath, [key, typename]);
|
|
128
|
+
|
|
129
|
+
var unionRootHasFragment =
|
|
130
|
+
(instructionMap[getPathName(newPath)] || {}).f === "";
|
|
121
131
|
|
|
122
|
-
|
|
132
|
+
var traversedValue = traverse(
|
|
133
|
+
fullInstructionMap,
|
|
134
|
+
newPath,
|
|
135
|
+
unionObj,
|
|
136
|
+
instructionMap,
|
|
137
|
+
converters,
|
|
138
|
+
nullableValue,
|
|
139
|
+
instructionPaths,
|
|
140
|
+
unionRootHasFragment
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
// Undefined means we're going from JS to ReScript, in which case we
|
|
144
|
+
// need to run the conversion here rather than earlier.
|
|
145
|
+
return nullableValue === undefined
|
|
146
|
+
? converters[instructions["u"]](traversedValue)
|
|
147
|
+
: traversedValue;
|
|
148
|
+
}
|
|
123
149
|
}
|
|
124
150
|
|
|
125
151
|
if (shouldAddFragmentFn && typeof v === "object") {
|
|
@@ -168,32 +194,44 @@ function traverse(
|
|
|
168
194
|
newObj[key] = converters[instructions["c"]](v);
|
|
169
195
|
}
|
|
170
196
|
|
|
171
|
-
if (
|
|
172
|
-
|
|
173
|
-
v != null &&
|
|
174
|
-
typeof v === "object" &&
|
|
175
|
-
typeof v.__typename === "string"
|
|
176
|
-
) {
|
|
177
|
-
isUnion = true;
|
|
197
|
+
if (shouldConvertUnion && v != null && typeof v === "object") {
|
|
198
|
+
var typename = getTypename(v);
|
|
178
199
|
|
|
179
|
-
|
|
200
|
+
if (typename != null) {
|
|
201
|
+
isUnion = true;
|
|
202
|
+
var unionObj = v;
|
|
180
203
|
|
|
181
|
-
|
|
182
|
-
(
|
|
204
|
+
// Means we're wrapping, and this will be a ReScript value.
|
|
205
|
+
if (nullableValue === null) {
|
|
206
|
+
// Convert it back to a flat JS value
|
|
207
|
+
unionObj = converters[instructions["u"]](v);
|
|
208
|
+
}
|
|
183
209
|
|
|
184
|
-
|
|
185
|
-
fullInstructionMap,
|
|
186
|
-
newPath,
|
|
187
|
-
v,
|
|
188
|
-
instructionMap,
|
|
189
|
-
converters,
|
|
190
|
-
nullableValue,
|
|
191
|
-
instructionPaths,
|
|
192
|
-
unionRootHasFragment
|
|
193
|
-
);
|
|
210
|
+
var newPath = makeNewPath(currentPath, [key, typename]);
|
|
194
211
|
|
|
195
|
-
|
|
196
|
-
|
|
212
|
+
var unionRootHasFragment =
|
|
213
|
+
(instructionMap[getPathName(newPath)] || {}).f === "";
|
|
214
|
+
|
|
215
|
+
var traversedValue = traverse(
|
|
216
|
+
fullInstructionMap,
|
|
217
|
+
newPath,
|
|
218
|
+
unionObj,
|
|
219
|
+
instructionMap,
|
|
220
|
+
converters,
|
|
221
|
+
nullableValue,
|
|
222
|
+
instructionPaths,
|
|
223
|
+
unionRootHasFragment
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
newObj = getNewObj(newObj, currentObj);
|
|
227
|
+
|
|
228
|
+
newObj[key] =
|
|
229
|
+
// Undefined means we're going from JS to ReScript, in which case we
|
|
230
|
+
// need to run the conversion here rather than earlier.
|
|
231
|
+
nullableValue === undefined
|
|
232
|
+
? converters[instructions["u"]](traversedValue)
|
|
233
|
+
: traversedValue;
|
|
234
|
+
}
|
|
197
235
|
}
|
|
198
236
|
|
|
199
237
|
if (shouldAddFragmentFn && typeof v === "object") {
|