rescript-relay 1.0.0 → 1.0.2

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 CHANGED
@@ -1,5 +1,22 @@
1
1
  # master
2
2
 
3
+ # 1.0.2
4
+
5
+ ## Bug Fixes
6
+
7
+ - `private` is now correctly marked as a reserved word.
8
+
9
+ ## Improvements
10
+
11
+ - Add ReScript 10 compat in peerDependencies https://github.com/zth/rescript-relay/pull/397 @MoOx
12
+ - `makeConnectionId` helpers are now marked as `@live` to not trigger the dead code analysis.
13
+
14
+ # 1.0.1
15
+
16
+ ## Bug Fixes
17
+
18
+ - Fix issue with custom scalar of JSON values being accidentally mangled https://github.com/zth/rescript-relay/pull/395 @tsnobip
19
+
3
20
  # 1.0.0
4
21
 
5
22
  _[Here's a commit showing a project being upgraded to this version](https://github.com/zth/rescript-relay/commit/5831c2f1f0f13eedc1cb60468c32fd32b2dc01d3)_
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rescript-relay",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "main": "src/RescriptRelay.res",
5
5
  "license": "MIT",
6
6
  "author": "Gabriel Nordeborn",
@@ -39,7 +39,7 @@
39
39
  "test:ci": "jest --ci --runInBand"
40
40
  },
41
41
  "devDependencies": {
42
- "rescript": "^9.1.2",
42
+ "rescript": "^10.0.0",
43
43
  "@rescript/react": "0.10.3",
44
44
  "@testing-library/jest-dom": "^5.16.3",
45
45
  "@testing-library/react": "^13.0.0-alpha.6",
@@ -57,7 +57,7 @@
57
57
  "@rescript/react": "*",
58
58
  "react-relay": ">=11.0.0",
59
59
  "relay-runtime": "*",
60
- "rescript": "^9.1.2"
60
+ "rescript": ">=9.1.2"
61
61
  },
62
62
  "dependencies": {
63
63
  "detect-libc": "^2.0.1"
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -13,7 +13,6 @@ function renderConcurrentRootAtElementWithId(content, id) {
13
13
  };
14
14
  }
15
15
  Client.createRoot(element).render(content);
16
-
17
16
  }
18
17
 
19
18
  exports.renderConcurrentRootAtElementWithId = renderConcurrentRootAtElementWithId;
@@ -9,7 +9,7 @@ function useTransition(param) {
9
9
  return [
10
10
  match[0],
11
11
  React.useCallback((function (cb) {
12
- return startTransition(cb, undefined);
12
+ startTransition(cb, undefined);
13
13
  }), [startTransition])
14
14
  ];
15
15
  }
@@ -131,7 +131,7 @@ var Store = {
131
131
  };
132
132
 
133
133
  function toJs(f, arg) {
134
- return Curry._3(f, arg.kind, arg.owner, arg.fieldPath);
134
+ Curry._3(f, arg.kind, arg.owner, arg.fieldPath);
135
135
  }
136
136
 
137
137
  function make$1(network, store, getDataID, treatMissingFieldsAsNull, missingFieldHandlers, requiredFieldLogger, isServer, param) {
@@ -238,10 +238,10 @@ function MakeLoadQuery(C) {
238
238
  if (o !== undefined) {
239
239
  Caml_option.valFromOption(o).subscribe({
240
240
  complete: (function (param) {
241
- return resolve({
242
- TAG: /* Ok */0,
243
- _0: undefined
244
- });
241
+ resolve({
242
+ TAG: /* Ok */0,
243
+ _0: undefined
244
+ });
245
245
  })
246
246
  });
247
247
  return ;
@@ -36,38 +36,37 @@ function resolveNestedRecordFromRoot(store, path) {
36
36
  }
37
37
 
38
38
  function removeNodeFromConnections(store, node, connections) {
39
- return Belt_List.forEach(connections, (function (connectionConfig) {
40
- var owner = store.get(connectionConfig.parentID);
41
- if (owner == null) {
42
- return ;
43
- }
44
- var connection = RelayRuntime.ConnectionHandler.getConnection(owner, connectionConfig.key, connectionConfig.filters !== undefined ? Caml_option.valFromOption(connectionConfig.filters) : undefined);
45
- if (!(connection == null)) {
46
- RelayRuntime.ConnectionHandler.deleteNode(connection, node.getDataID());
47
- return ;
48
- }
49
-
50
- }));
39
+ Belt_List.forEach(connections, (function (connectionConfig) {
40
+ var owner = store.get(connectionConfig.parentID);
41
+ if (owner == null) {
42
+ return ;
43
+ }
44
+ var connection = RelayRuntime.ConnectionHandler.getConnection(owner, connectionConfig.key, connectionConfig.filters !== undefined ? Caml_option.valFromOption(connectionConfig.filters) : undefined);
45
+ if (!(connection == null)) {
46
+ RelayRuntime.ConnectionHandler.deleteNode(connection, node.getDataID());
47
+ return ;
48
+ }
49
+
50
+ }));
51
51
  }
52
52
 
53
53
  function createAndAddEdgeToConnections(store, node, connections, edgeName, insertAt) {
54
- return Belt_List.forEach(connections, (function (connectionConfig) {
55
- var connectionOwner = store.get(connectionConfig.parentID);
56
- if (connectionOwner == null) {
57
- return ;
58
- }
59
- var connection = RelayRuntime.ConnectionHandler.getConnection(connectionOwner, connectionConfig.key, connectionConfig.filters !== undefined ? Caml_option.valFromOption(connectionConfig.filters) : undefined);
60
- if (connection == null) {
61
- return ;
62
- }
63
- var edge = RelayRuntime.ConnectionHandler.createEdge(store, connection, node, edgeName);
64
- if (insertAt) {
65
- RelayRuntime.ConnectionHandler.insertEdgeBefore(connection, edge, undefined);
66
- } else {
67
- RelayRuntime.ConnectionHandler.insertEdgeAfter(connection, edge, undefined);
68
- }
69
-
70
- }));
54
+ Belt_List.forEach(connections, (function (connectionConfig) {
55
+ var connectionOwner = store.get(connectionConfig.parentID);
56
+ if (connectionOwner == null) {
57
+ return ;
58
+ }
59
+ var connection = RelayRuntime.ConnectionHandler.getConnection(connectionOwner, connectionConfig.key, connectionConfig.filters !== undefined ? Caml_option.valFromOption(connectionConfig.filters) : undefined);
60
+ if (connection == null) {
61
+ return ;
62
+ }
63
+ var edge = RelayRuntime.ConnectionHandler.createEdge(store, connection, node, edgeName);
64
+ if (insertAt) {
65
+ RelayRuntime.ConnectionHandler.insertEdgeBefore(connection, edge, undefined);
66
+ } else {
67
+ RelayRuntime.ConnectionHandler.insertEdgeAfter(connection, edge, undefined);
68
+ }
69
+ }));
71
70
  }
72
71
 
73
72
  exports.resolveNestedRecord = resolveNestedRecord;
@@ -37,7 +37,7 @@ function internal_removeUndefinedAndConvertNullsRaw(record) {
37
37
  return internal_keepMapFieldsRaw(record, (function (param) {
38
38
  var value = param[1];
39
39
  var key = param[0];
40
- var match = Caml_obj.caml_equal(value, Caml_option.some(undefined));
40
+ var match = Caml_obj.equal(value, Caml_option.some(undefined));
41
41
  if (value !== undefined) {
42
42
  return [
43
43
  key,
package/src/utils.js CHANGED
@@ -78,6 +78,16 @@ function traverse(
78
78
  var shouldConvertCustomField =
79
79
  typeof instructions["c"] === "string" && !!converters[instructions["c"]];
80
80
 
81
+ var shouldBlockTraversal = typeof instructions["b"] === "string";
82
+ var allowGoingIntoArray = shouldBlockTraversal
83
+ ? instructions["b"] === "a"
84
+ : true;
85
+
86
+ if (shouldBlockTraversal && !allowGoingIntoArray) {
87
+ newObj = getNewObj(newObj, currentObj);
88
+ continue;
89
+ }
90
+
81
91
  var shouldConvertUnion =
82
92
  typeof instructions["u"] === "string" && !!converters[instructions["u"]];
83
93
 
@@ -92,7 +102,6 @@ function traverse(
92
102
  if (v == null) {
93
103
  return nullableValue;
94
104
  }
95
-
96
105
  if (shouldConvertRootObj) {
97
106
  return traverser(
98
107
  v,
@@ -148,7 +157,7 @@ function traverse(
148
157
  }
149
158
  }
150
159
 
151
- if (shouldAddFragmentFn && typeof v === "object") {
160
+ if (shouldAddFragmentFn && typeof v === "object" && !Array.isArray(v)) {
152
161
  var objWithFragmentFn = Object.assign({}, v);
153
162
  objWithFragmentFn.fragmentRefs = Object.assign({}, objWithFragmentFn);
154
163
  return objWithFragmentFn;
@@ -171,6 +180,7 @@ function traverse(
171
180
  nullableValue,
172
181
  instructions["r"]
173
182
  );
183
+ continue;
174
184
  }
175
185
 
176
186
  if (isTopLevelNodeField) {
@@ -238,7 +248,7 @@ function traverse(
238
248
  }
239
249
  }
240
250
 
241
- if (shouldAddFragmentFn && typeof v === "object") {
251
+ if (shouldAddFragmentFn && typeof v === "object" && !Array.isArray(v)) {
242
252
  newObj = getNewObj(newObj, currentObj);
243
253
  var objWithFragmentFn = Object.assign({}, v);
244
254
  objWithFragmentFn.fragmentRefs = Object.assign({}, objWithFragmentFn);
@@ -264,10 +274,10 @@ function traverse(
264
274
  newObj = getNewObj(newObj, currentObj);
265
275
  newObj[key] = traversedObj;
266
276
  }
267
- } else if (Array.isArray(originalValue)) {
277
+ } else if (Array.isArray(originalValue) && !shouldBlockTraversal) {
268
278
  newObj = getNewObj(newObj, currentObj);
269
279
  newObj[key] = nextObj.map(function (o) {
270
- if (typeof o === "object" && o != null) {
280
+ if (typeof o === "object" && o != null && !Array.isArray(o)) {
271
281
  return traverse(
272
282
  fullInstructionMap,
273
283
  thisPath,
package/src/utils.mjs CHANGED
@@ -78,6 +78,16 @@ function traverse(
78
78
  var shouldConvertCustomField =
79
79
  typeof instructions["c"] === "string" && !!converters[instructions["c"]];
80
80
 
81
+ var shouldBlockTraversal = typeof instructions["b"] === "string";
82
+ var allowGoingIntoArray = shouldBlockTraversal
83
+ ? instructions["b"] === "a"
84
+ : true;
85
+
86
+ if (shouldBlockTraversal && !allowGoingIntoArray) {
87
+ newObj = getNewObj(newObj, currentObj);
88
+ continue;
89
+ }
90
+
81
91
  var shouldConvertUnion =
82
92
  typeof instructions["u"] === "string" && !!converters[instructions["u"]];
83
93
 
@@ -92,7 +102,6 @@ function traverse(
92
102
  if (v == null) {
93
103
  return nullableValue;
94
104
  }
95
-
96
105
  if (shouldConvertRootObj) {
97
106
  return traverser(
98
107
  v,
@@ -148,7 +157,7 @@ function traverse(
148
157
  }
149
158
  }
150
159
 
151
- if (shouldAddFragmentFn && typeof v === "object") {
160
+ if (shouldAddFragmentFn && typeof v === "object" && !Array.isArray(v)) {
152
161
  var objWithFragmentFn = Object.assign({}, v);
153
162
  objWithFragmentFn.fragmentRefs = Object.assign({}, objWithFragmentFn);
154
163
  return objWithFragmentFn;
@@ -171,6 +180,7 @@ function traverse(
171
180
  nullableValue,
172
181
  instructions["r"]
173
182
  );
183
+ continue;
174
184
  }
175
185
 
176
186
  if (isTopLevelNodeField) {
@@ -238,7 +248,7 @@ function traverse(
238
248
  }
239
249
  }
240
250
 
241
- if (shouldAddFragmentFn && typeof v === "object") {
251
+ if (shouldAddFragmentFn && typeof v === "object" && !Array.isArray(v)) {
242
252
  newObj = getNewObj(newObj, currentObj);
243
253
  var objWithFragmentFn = Object.assign({}, v);
244
254
  objWithFragmentFn.fragmentRefs = Object.assign({}, objWithFragmentFn);
@@ -264,10 +274,10 @@ function traverse(
264
274
  newObj = getNewObj(newObj, currentObj);
265
275
  newObj[key] = traversedObj;
266
276
  }
267
- } else if (Array.isArray(originalValue)) {
277
+ } else if (Array.isArray(originalValue) && !shouldBlockTraversal) {
268
278
  newObj = getNewObj(newObj, currentObj);
269
279
  newObj[key] = nextObj.map(function (o) {
270
- if (typeof o === "object" && o != null) {
280
+ if (typeof o === "object" && o != null && !Array.isArray(o)) {
271
281
  return traverse(
272
282
  fullInstructionMap,
273
283
  thisPath,