rescript-relay 1.0.0 → 1.0.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # master
2
2
 
3
+ # 1.0.1
4
+
5
+ ## Bug Fixes
6
+
7
+ - Fix issue with custom scalar of JSON values being accidentally mangled https://github.com/zth/rescript-relay/pull/395 @tsnobip
8
+
3
9
  # 1.0.0
4
10
 
5
11
  _[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.1",
4
4
  "main": "src/RescriptRelay.res",
5
5
  "license": "MIT",
6
6
  "author": "Gabriel Nordeborn",
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
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,