@graphql-tools/executor 1.0.0 → 1.1.0-alpha-20230523100348-6c3466d9

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.
@@ -557,7 +557,20 @@ function completeListItemValue(item, completedResults, errors, exeContext, itemT
557
557
  * null if serialization is not possible.
558
558
  */
559
559
  function completeLeafValue(returnType, result) {
560
- const serializedResult = returnType.serialize(result);
560
+ let serializedResult;
561
+ // Note: We transform GraphQLError to Error in order to be consistent with
562
+ // how non-null checks work later on.
563
+ // See https://github.com/kamilkisiela/graphql-hive/pull/2299
564
+ // See https://github.com/n1ru4l/envelop/issues/1808
565
+ try {
566
+ serializedResult = returnType.serialize(result);
567
+ }
568
+ catch (err) {
569
+ if (err && typeof err['message'] === 'string') {
570
+ throw new Error(err['message']);
571
+ }
572
+ throw err;
573
+ }
561
574
  if (serializedResult == null) {
562
575
  throw new Error(`Expected \`${(0, utils_1.inspect)(returnType)}.serialize(${(0, utils_1.inspect)(result)})\` to ` +
563
576
  `return non-nullable value, returned: ${(0, utils_1.inspect)(serializedResult)}`);
@@ -549,7 +549,20 @@ function completeListItemValue(item, completedResults, errors, exeContext, itemT
549
549
  * null if serialization is not possible.
550
550
  */
551
551
  function completeLeafValue(returnType, result) {
552
- const serializedResult = returnType.serialize(result);
552
+ let serializedResult;
553
+ // Note: We transform GraphQLError to Error in order to be consistent with
554
+ // how non-null checks work later on.
555
+ // See https://github.com/kamilkisiela/graphql-hive/pull/2299
556
+ // See https://github.com/n1ru4l/envelop/issues/1808
557
+ try {
558
+ serializedResult = returnType.serialize(result);
559
+ }
560
+ catch (err) {
561
+ if (err && typeof err['message'] === 'string') {
562
+ throw new Error(err['message']);
563
+ }
564
+ throw err;
565
+ }
553
566
  if (serializedResult == null) {
554
567
  throw new Error(`Expected \`${inspect(returnType)}.serialize(${inspect(result)})\` to ` +
555
568
  `return non-nullable value, returned: ${inspect(serializedResult)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/executor",
3
- "version": "1.0.0",
3
+ "version": "1.1.0-alpha-20230523100348-6c3466d9",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"