rescript-relay 1.0.0-beta.13 → 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 +29 -4
- 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
|
|
|
@@ -8,7 +8,7 @@ The time has finally come - RescriptRelay `1.0.0` is in beta! The one, big major
|
|
|
8
8
|
|
|
9
9
|
## Upgrade versions
|
|
10
10
|
|
|
11
|
-
- `react-relay` and `relay-runtime` to `13.
|
|
11
|
+
- `react-relay` and `relay-runtime` to `13.2.0`
|
|
12
12
|
|
|
13
13
|
## Remove Packages
|
|
14
14
|
|
|
@@ -31,15 +31,40 @@ You can go ahead and remove these packages, that are no longer needed, as the co
|
|
|
31
31
|
|
|
32
32
|
## Breaking changes
|
|
33
33
|
|
|
34
|
-
-
|
|
34
|
+
- The list of disallowed field names has been adapted to ReScript (it was never properly updated for ReScript when moving from ReasonML). This means that _some of your variable prop names might be renamed_. One example - if you previously had a variable in GraphQL called `$to`, you'd interact with that as `to_` in ReScript. This is because RescriptRelay would pin `to` as a reserved word, and rename it for you. But, `to` _isn't_ actually a keyword in ReScript (it was in ReasonML), so with this release, that `to_` in ReScript will be renamed to `to`. The fix is to just update all `to_` to `to` - let the compiler guide you!
|
|
35
|
+
- Using variable names that are reserved words in ReScript is now _disallowed at the Relay compiler level_. This means that Relay won't compile your project if you have variables whose names are reserved words. The fix is to simply rename the variables.
|
|
36
|
+
- `refetchVariables` now works as intended with regards to supplying only the variables you want _changed_ when refetching, as [detailed under `variables` here](https://relay.dev/docs/next/api-reference/use-refetchable-fragment/#return-value). This means that what was previously `makeRefetchVariables(~someValue=123, ())` should now be `makeRefetchVariables(~someValue=Some(123), ())`.
|
|
37
|
+
Crash course:
|
|
38
|
+
|
|
39
|
+
- `makeRefetchVariables(~someValue=Some(123), ())` means _refetch, use the same values for all variables that was used in the last fetch, but change `someValue` to `123`_.
|
|
40
|
+
- `makeRefetchVariables(~someValue=None, ())` means _refetch, use the same values for all variables that was used in the last fetch, but change `someValue` to `null` (unsetting it)_.
|
|
41
|
+
- `makeRefetchVariables()` means _refetch, use the same values for all variables that was used in the last fetch, change nothing_.
|
|
42
|
+
|
|
43
|
+
This way you can surgically change only certain values when refetching, without having to keep track of the current values for the other values.
|
|
44
|
+
|
|
45
|
+
More details on this [in the docs](https://rescript-relay-documentation.vercel.app/docs/refetching-and-loading-more-data#makerefetchvariables). Thanks to [@tsnobip](https://github.com/tsnobip) for fixing this!
|
|
35
46
|
|
|
36
47
|
## Beta fix changelog
|
|
37
48
|
|
|
38
49
|
### unreleased
|
|
39
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
|
+
|
|
56
|
+
### beta.15
|
|
57
|
+
|
|
58
|
+
- Fixes for input objects.
|
|
59
|
+
|
|
60
|
+
### beta.14
|
|
61
|
+
|
|
62
|
+
- Fixes a few issues introduced in `beta.13`.
|
|
63
|
+
- The list of disallowed field names has been adapted to ReScript. This means that _some of your variable prop names might be renamed_. Check out the Breaking Changes section above for details.
|
|
64
|
+
|
|
40
65
|
### beta.13
|
|
41
66
|
|
|
42
|
-
- `refetchVariables` now works as intended with regards to supplying only the variables you want _changed_ when refetching, as [detailed under `variables` here](https://relay.dev/docs/next/api-reference/use-refetchable-fragment/#return-value).
|
|
67
|
+
- `refetchVariables` now works as intended with regards to supplying only the variables you want _changed_ when refetching, as [detailed under `variables` here](https://relay.dev/docs/next/api-reference/use-refetchable-fragment/#return-value). Check out the [docs](https://rescript-relay-documentation.vercel.app/docs/refetching-and-loading-more-data#makerefetchvariables).
|
|
43
68
|
- Make all object makers inlined. This should improve bundle size some.
|
|
44
69
|
- Support more Linux versions in CI (like the images Vercel uses).
|
|
45
70
|
|
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") {
|