@graphitation/supermassive 3.15.1 → 3.15.3

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.
@@ -356,13 +356,6 @@ function executeField(exeContext, parentTypeName, source, fieldGroup, path, incr
356
356
  fieldName
357
357
  });
358
358
  if (!loading) {
359
- handleMissingSchemaError(
360
- exeContext,
361
- void 0,
362
- fieldGroup,
363
- path,
364
- incrementalDataRecord
365
- );
366
359
  return void 0;
367
360
  }
368
361
  return loading.then(() => {
@@ -382,13 +375,6 @@ function executeField(exeContext, parentTypeName, source, fieldGroup, path, incr
382
375
  incrementalDataRecord
383
376
  );
384
377
  }
385
- handleMissingSchemaError(
386
- exeContext,
387
- void 0,
388
- fieldGroup,
389
- path,
390
- incrementalDataRecord
391
- );
392
378
  return void 0;
393
379
  });
394
380
  }
@@ -434,8 +420,7 @@ function afterFieldSubscribeHandle(resolved, isDefaultResolverUsed, exeContext,
434
420
  }
435
421
  }
436
422
  function executeSubscriptionImpl(exeContext) {
437
- var _a;
438
- const { operation, rootValue, schemaFragment } = exeContext;
423
+ const { operation, schemaFragment } = exeContext;
439
424
  const rootTypeName = getOperationRootTypeName(operation);
440
425
  const { groupedFieldSet } = collectFields(exeContext, rootTypeName);
441
426
  const firstRootField = groupedFieldSet.entries().next().value;
@@ -449,12 +434,52 @@ function executeSubscriptionImpl(exeContext) {
449
434
  rootTypeName,
450
435
  fieldName
451
436
  );
452
- if (!fieldDef) {
437
+ if (fieldDef) {
438
+ return runSubscriptionResolver(
439
+ exeContext,
440
+ fieldDef,
441
+ fieldName,
442
+ fieldGroup,
443
+ responseName,
444
+ rootTypeName
445
+ );
446
+ }
447
+ const loading = requestSchemaFragment(exeContext, {
448
+ kind: "ReturnType",
449
+ parentTypeName: rootTypeName,
450
+ fieldName
451
+ });
452
+ if (!loading) {
453
453
  throw locatedError(
454
- `The subscription field "${fieldName}" is not defined.`,
454
+ `Type definition for ${rootTypeName}.${fieldName} is missing`,
455
455
  fieldGroup
456
456
  );
457
457
  }
458
+ return loading.then(() => {
459
+ const fieldDef2 = Definitions.getField(
460
+ schemaFragment.definitions,
461
+ rootTypeName,
462
+ fieldName
463
+ );
464
+ if (fieldDef2 === void 0) {
465
+ throw locatedError(
466
+ `Type definition for ${rootTypeName}.${fieldName} is missing`,
467
+ fieldGroup
468
+ );
469
+ }
470
+ return runSubscriptionResolver(
471
+ exeContext,
472
+ fieldDef2,
473
+ fieldName,
474
+ fieldGroup,
475
+ responseName,
476
+ rootTypeName
477
+ );
478
+ });
479
+ }
480
+ function runSubscriptionResolver(exeContext, fieldDef, fieldName, fieldGroup, responseName, rootTypeName) {
481
+ var _a;
482
+ const { rootValue, schemaFragment } = exeContext;
458
483
  const returnTypeRef = Definitions.getFieldTypeReference(fieldDef);
459
484
  const resolveFn = (_a = Resolvers.getSubscriptionFieldResolver(
460
485
  schemaFragment,
@@ -631,24 +656,6 @@ function handleFieldError(rawError, exeContext, returnTypeRef, fieldGroup, path,
631
656
  const errors = (_a = incrementalDataRecord == null ? void 0 : incrementalDataRecord.errors) != null ? _a : exeContext.errors;
632
657
  errors.push(error);
633
658
  }
634
- function handleMissingSchemaError(exeContext, returnTypeRef, fieldGroup, path, incrementalDataRecord) {
635
- const parentTypeName = path.typename;
636
- const isRootField = parentTypeName === "Mutation" || parentTypeName === "Query";
637
- if (!isRootField) {
638
- return;
639
- }
640
- const fieldName = path.key;
641
- const message = !returnTypeRef ? `Type definition for ${parentTypeName}.${fieldName} is missing` : `Resolver for ${parentTypeName}.${fieldName} is missing`;
642
- const error = new Error(message);
643
- handleFieldError(
644
- error,
645
- exeContext,
646
- returnTypeRef,
647
- fieldGroup,
648
- path,
649
- incrementalDataRecord
650
- );
651
- }
652
659
  function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fieldGroup, path, source, incrementalDataRecord) {
653
660
  var _a;
654
661
  const fieldName = fieldGroup[0].name.value;
@@ -667,15 +674,6 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
667
674
  path
668
675
  );
669
676
  const isDefaultResolverUsed = resolveFn === exeContext.fieldResolver || fieldName === "__typename";
670
- if (resolveFn === exeContext.fieldResolver && typeof source === "undefined") {
671
- handleMissingSchemaError(
672
- exeContext,
673
- returnTypeRef,
674
- fieldGroup,
675
- path,
676
- incrementalDataRecord
677
- );
678
- }
679
677
  const hooks = exeContext.fieldExecutionHooks;
680
678
  let hookContext = void 0;
681
679
  try {