@wundergraph/composition 0.23.2 → 0.25.0

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.
Files changed (37) hide show
  1. package/dist/errors/errors.d.ts +30 -9
  2. package/dist/errors/errors.js +190 -28
  3. package/dist/errors/errors.js.map +1 -1
  4. package/dist/federation/federation-factory.d.ts +11 -2
  5. package/dist/federation/federation-factory.js +293 -4
  6. package/dist/federation/federation-factory.js.map +1 -1
  7. package/dist/federation/utils.d.ts +7 -2
  8. package/dist/index.d.ts +1 -0
  9. package/dist/index.js +1 -0
  10. package/dist/index.js.map +1 -1
  11. package/dist/normalization/normalization-factory.d.ts +13 -9
  12. package/dist/normalization/normalization-factory.js +177 -67
  13. package/dist/normalization/normalization-factory.js.map +1 -1
  14. package/dist/normalization/walkers.js +14 -4
  15. package/dist/normalization/walkers.js.map +1 -1
  16. package/dist/router-configuration/router-configuration.d.ts +26 -4
  17. package/dist/schema-building/ast.js +3 -3
  18. package/dist/schema-building/ast.js.map +1 -1
  19. package/dist/schema-building/type-merging.js +5 -5
  20. package/dist/schema-building/type-merging.js.map +1 -1
  21. package/dist/schema-building/utils.d.ts +4 -2
  22. package/dist/schema-building/utils.js +35 -3
  23. package/dist/schema-building/utils.js.map +1 -1
  24. package/dist/tsconfig.tsbuildinfo +1 -1
  25. package/dist/utils/constants.d.ts +8 -5
  26. package/dist/utils/constants.js +199 -33
  27. package/dist/utils/constants.js.map +1 -1
  28. package/dist/utils/integer-constants.d.ts +2 -0
  29. package/dist/utils/integer-constants.js +6 -0
  30. package/dist/utils/integer-constants.js.map +1 -0
  31. package/dist/utils/string-constants.d.ts +32 -5
  32. package/dist/utils/string-constants.js +42 -9
  33. package/dist/utils/string-constants.js.map +1 -1
  34. package/dist/utils/utils.d.ts +1 -0
  35. package/dist/utils/utils.js +57 -15
  36. package/dist/utils/utils.js.map +1 -1
  37. package/package.json +2 -2
@@ -38,14 +38,15 @@ class NormalizationFactory {
38
38
  configurationDataByParentTypeName = new Map();
39
39
  customDirectiveDefinitions = new Map();
40
40
  directiveDefinitionByDirectiveName = new Map();
41
+ edfsDirectiveReferences = new Set();
41
42
  errors = [];
42
43
  entityDataByTypeName = new Map();
43
44
  entityInterfaces = new Map();
45
+ eventsConfigurations = new Map();
44
46
  graph;
45
47
  parentExtensionDataByTypeName = new Map();
46
48
  interfaceTypeNamesWithAuthorizationDirectives = new Set();
47
49
  isCurrentParentExtension = false;
48
- isEventDrivenSubgraph = false;
49
50
  isSubgraphVersionTwo = false;
50
51
  fieldSetDataByTypeName = new Map();
51
52
  heirFieldAuthorizationDataByTypeName = new Map();
@@ -59,15 +60,14 @@ class NormalizationFactory {
59
60
  parentDefinitionDataByTypeName = new Map();
60
61
  originalParentTypeName = '';
61
62
  parentsWithChildArguments = new Set();
62
- eventsConfigurations = new Map();
63
63
  overridesByTargetSubgraphName = new Map();
64
64
  invalidOrScopesHostPaths = new Set();
65
65
  schemaDefinition;
66
66
  referencedDirectiveNames = new Set();
67
67
  referencedTypeNames = new Set();
68
68
  renamedParentTypeName = '';
69
- warnings = [];
70
69
  subgraphName;
70
+ warnings = [];
71
71
  constructor(graph, subgraphName) {
72
72
  for (const [baseDirectiveName, baseDirectiveDefinition] of constants_1.BASE_DIRECTIVE_DEFINITION_BY_DIRECTIVE_NAME) {
73
73
  this.directiveDefinitionByDirectiveName.set(baseDirectiveName, baseDirectiveDefinition);
@@ -474,25 +474,93 @@ class NormalizationFactory {
474
474
  const overriddenFieldNamesForParent = (0, utils_3.getValueOrDefault)(overrideDataForSubgraph, this.renamedParentTypeName || this.originalParentTypeName, () => new Set());
475
475
  overriddenFieldNamesForParent.add(this.childName);
476
476
  }
477
- getEventPublishAndRequestConfiguration(eventType, directive, errorMessages) {
477
+ getKafkaPublishConfiguration(directive, errorMessages) {
478
+ const topics = [];
479
+ let providerId = string_constants_1.DEFAULT_EDFS_PROVIDER_ID;
480
+ for (const argumentNode of directive.arguments || []) {
481
+ switch (argumentNode.name.value) {
482
+ case string_constants_1.TOPIC: {
483
+ if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
484
+ errorMessages.push((0, errors_1.invalidEventSubjectErrorMessage)(string_constants_1.TOPIC));
485
+ continue;
486
+ }
487
+ topics.push(argumentNode.value.value);
488
+ break;
489
+ }
490
+ case string_constants_1.PROVIDER_ID: {
491
+ if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
492
+ errorMessages.push(errors_1.invalidEventProviderIdErrorMessage);
493
+ continue;
494
+ }
495
+ providerId = argumentNode.value.value;
496
+ break;
497
+ }
498
+ }
499
+ }
500
+ if (errorMessages.length > 0) {
501
+ return;
502
+ }
503
+ return { fieldName: this.childName, providerId, providerType: string_constants_1.PROVIDER_TYPE_KAFKA, topics, type: string_constants_1.PUBLISH };
504
+ }
505
+ getKafkaSubscribeConfiguration(directive, errorMessages) {
506
+ const topics = [];
507
+ let providerId = string_constants_1.DEFAULT_EDFS_PROVIDER_ID;
508
+ for (const argumentNode of directive.arguments || []) {
509
+ switch (argumentNode.name.value) {
510
+ case string_constants_1.TOPICS: {
511
+ if (argumentNode.value.kind !== graphql_1.Kind.LIST) {
512
+ errorMessages.push((0, errors_1.invalidEventSubjectsErrorMessage)(string_constants_1.TOPICS));
513
+ continue;
514
+ }
515
+ for (const value of argumentNode.value.values) {
516
+ if (value.kind !== graphql_1.Kind.STRING || value.value.length < 1) {
517
+ errorMessages.push((0, errors_1.invalidEventSubjectsItemErrorMessage)(string_constants_1.TOPICS));
518
+ break;
519
+ }
520
+ topics.push(value.value);
521
+ }
522
+ break;
523
+ }
524
+ case string_constants_1.PROVIDER_ID: {
525
+ if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
526
+ errorMessages.push(errors_1.invalidEventProviderIdErrorMessage);
527
+ continue;
528
+ }
529
+ providerId = argumentNode.value.value;
530
+ break;
531
+ }
532
+ }
533
+ }
534
+ if (errorMessages.length > 0) {
535
+ return;
536
+ }
537
+ return {
538
+ fieldName: this.childName,
539
+ providerId,
540
+ providerType: string_constants_1.PROVIDER_TYPE_KAFKA,
541
+ topics: topics,
542
+ type: string_constants_1.SUBSCRIBE,
543
+ };
544
+ }
545
+ getNatsPublishAndRequestConfiguration(eventType, directive, errorMessages) {
478
546
  const subjects = [];
479
- let sourceName = string_constants_1.DEFAULT;
547
+ let providerId = string_constants_1.DEFAULT_EDFS_PROVIDER_ID;
480
548
  for (const argumentNode of directive.arguments || []) {
481
549
  switch (argumentNode.name.value) {
482
550
  case string_constants_1.SUBJECT: {
483
551
  if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
484
- errorMessages.push(errors_1.invalidEventSubjectErrorMessage);
552
+ errorMessages.push((0, errors_1.invalidEventSubjectErrorMessage)(string_constants_1.SUBJECT));
485
553
  continue;
486
554
  }
487
555
  subjects.push(argumentNode.value.value);
488
556
  break;
489
557
  }
490
- case string_constants_1.SOURCE_NAME: {
558
+ case string_constants_1.PROVIDER_ID: {
491
559
  if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
492
- errorMessages.push(errors_1.invalidEventSourceNameErrorMessage);
560
+ errorMessages.push(errors_1.invalidEventProviderIdErrorMessage);
493
561
  continue;
494
562
  }
495
- sourceName = argumentNode.value.value;
563
+ providerId = argumentNode.value.value;
496
564
  break;
497
565
  }
498
566
  }
@@ -500,40 +568,40 @@ class NormalizationFactory {
500
568
  if (errorMessages.length > 0) {
501
569
  return;
502
570
  }
503
- return { fieldName: this.childName, sourceName, subjects, type: eventType };
571
+ return { fieldName: this.childName, providerId, providerType: string_constants_1.PROVIDER_TYPE_NATS, subjects, type: eventType };
504
572
  }
505
- getEventSubscribeConfiguration(directive, errorMessages) {
573
+ getNatsSubscribeConfiguration(directive, errorMessages) {
506
574
  const subjects = [];
507
- let sourceName = string_constants_1.DEFAULT;
575
+ let providerId = string_constants_1.DEFAULT_EDFS_PROVIDER_ID;
508
576
  let consumerName = '';
509
577
  let streamName = '';
510
578
  for (const argumentNode of directive.arguments || []) {
511
579
  switch (argumentNode.name.value) {
512
580
  case string_constants_1.SUBJECTS: {
513
581
  if (argumentNode.value.kind !== graphql_1.Kind.LIST) {
514
- errorMessages.push(errors_1.invalidEventSubjectsErrorMessage);
582
+ errorMessages.push((0, errors_1.invalidEventSubjectsErrorMessage)(string_constants_1.SUBJECTS));
515
583
  continue;
516
584
  }
517
585
  for (const value of argumentNode.value.values) {
518
586
  if (value.kind !== graphql_1.Kind.STRING || value.value.length < 1) {
519
- errorMessages.push(errors_1.invalidEventSubjectsItemErrorMessage);
587
+ errorMessages.push((0, errors_1.invalidEventSubjectsItemErrorMessage)(string_constants_1.SUBJECTS));
520
588
  break;
521
589
  }
522
590
  subjects.push(value.value);
523
591
  }
524
592
  break;
525
593
  }
526
- case string_constants_1.SOURCE_NAME: {
594
+ case string_constants_1.PROVIDER_ID: {
527
595
  if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
528
- errorMessages.push(errors_1.invalidEventSourceNameErrorMessage);
596
+ errorMessages.push(errors_1.invalidEventProviderIdErrorMessage);
529
597
  continue;
530
598
  }
531
- sourceName = argumentNode.value.value;
599
+ providerId = argumentNode.value.value;
532
600
  break;
533
601
  }
534
602
  case string_constants_1.STREAM_CONFIGURATION: {
535
603
  if (argumentNode.value.kind !== graphql_1.Kind.OBJECT || argumentNode.value.fields.length < 1) {
536
- errorMessages.push(errors_1.invalidEventDrivenStreamConfigurationInputErrorMessage);
604
+ errorMessages.push(errors_1.invalidNatsStreamInputErrorMessage);
537
605
  continue;
538
606
  }
539
607
  let isValid = true;
@@ -571,7 +639,7 @@ class NormalizationFactory {
571
639
  }
572
640
  }
573
641
  if (!isValid || missingRequiredFieldNames.size > 0) {
574
- errorMessages.push((0, errors_1.invalidEventDrivenStreamConfigurationInputFieldsErrorMessage)([...missingRequiredFieldNames], [...duplicateRequiredFieldNames], [...invalidRequiredFieldNames], [...invalidFieldNames]));
642
+ errorMessages.push((0, errors_1.invalidNatsStreamInputFieldsErrorMessage)([...missingRequiredFieldNames], [...duplicateRequiredFieldNames], [...invalidRequiredFieldNames], [...invalidFieldNames]));
575
643
  }
576
644
  }
577
645
  }
@@ -581,12 +649,30 @@ class NormalizationFactory {
581
649
  }
582
650
  return {
583
651
  fieldName: this.childName,
584
- sourceName,
652
+ providerId,
653
+ providerType: string_constants_1.PROVIDER_TYPE_NATS,
585
654
  subjects,
586
655
  type: string_constants_1.SUBSCRIBE,
587
656
  ...(consumerName && streamName ? { streamConfiguration: { consumerName: consumerName, streamName } } : {}),
588
657
  };
589
658
  }
659
+ validateSubscriptionFilterDirectiveLocation(node) {
660
+ if (!node.directives) {
661
+ return;
662
+ }
663
+ const parentTypeName = this.renamedParentTypeName || this.originalParentTypeName;
664
+ const fieldPath = `${parentTypeName}.${node.name.value}`;
665
+ const isSubscription = this.getOperationTypeNodeForRootTypeName(parentTypeName) === graphql_1.OperationTypeNode.SUBSCRIPTION;
666
+ for (const directiveNode of node.directives) {
667
+ if (directiveNode.name.value !== string_constants_1.SUBSCRIPTION_FILTER) {
668
+ continue;
669
+ }
670
+ if (!isSubscription) {
671
+ this.errors.push((0, errors_1.invalidSubscriptionFilterLocationError)(fieldPath));
672
+ return;
673
+ }
674
+ }
675
+ }
590
676
  extractEventDirectivesToConfiguration(node) {
591
677
  // Validation is handled elsewhere
592
678
  if (!node.directives) {
@@ -597,16 +683,22 @@ class NormalizationFactory {
597
683
  const errorMessages = [];
598
684
  let eventConfiguration;
599
685
  switch (directive.name.value) {
600
- case string_constants_1.EDFS_PUBLISH: {
601
- eventConfiguration = this.getEventPublishAndRequestConfiguration(string_constants_1.PUBLISH, directive, errorMessages);
686
+ case string_constants_1.EDFS_KAFKA_PUBLISH:
687
+ eventConfiguration = this.getKafkaPublishConfiguration(directive, errorMessages);
688
+ break;
689
+ case string_constants_1.EDFS_KAFKA_SUBSCRIBE:
690
+ eventConfiguration = this.getKafkaSubscribeConfiguration(directive, errorMessages);
691
+ break;
692
+ case string_constants_1.EDFS_NATS_PUBLISH: {
693
+ eventConfiguration = this.getNatsPublishAndRequestConfiguration(string_constants_1.PUBLISH, directive, errorMessages);
602
694
  break;
603
695
  }
604
- case string_constants_1.EDFS_REQUEST: {
605
- eventConfiguration = this.getEventPublishAndRequestConfiguration(string_constants_1.REQUEST, directive, errorMessages);
696
+ case string_constants_1.EDFS_NATS_REQUEST: {
697
+ eventConfiguration = this.getNatsPublishAndRequestConfiguration(string_constants_1.REQUEST, directive, errorMessages);
606
698
  break;
607
699
  }
608
- case string_constants_1.EDFS_SUBSCRIBE: {
609
- eventConfiguration = this.getEventSubscribeConfiguration(directive, errorMessages);
700
+ case string_constants_1.EDFS_NATS_SUBSCRIBE: {
701
+ eventConfiguration = this.getNatsSubscribeConfiguration(directive, errorMessages);
610
702
  break;
611
703
  }
612
704
  default:
@@ -623,33 +715,40 @@ class NormalizationFactory {
623
715
  (0, utils_3.getValueOrDefault)(this.eventsConfigurations, this.renamedParentTypeName || this.originalParentTypeName, () => []).push(eventConfiguration);
624
716
  }
625
717
  }
626
- getValidEventsDirectiveNamesForRootTypeName(parentTypeName) {
627
- const operationTypeNode = this.operationTypeNodeByTypeName.get(parentTypeName);
628
- if (!operationTypeNode) {
629
- switch (parentTypeName) {
630
- case string_constants_1.MUTATION:
631
- return new Set([string_constants_1.EDFS_PUBLISH, string_constants_1.EDFS_REQUEST]);
632
- case string_constants_1.QUERY:
633
- return new Set([string_constants_1.EDFS_REQUEST]);
634
- case string_constants_1.SUBSCRIPTION:
635
- return new Set([string_constants_1.EDFS_SUBSCRIBE]);
636
- default:
637
- return;
638
- }
639
- }
718
+ getValidEventsDirectiveNamesForOperationTypeNode(operationTypeNode) {
640
719
  switch (operationTypeNode) {
641
720
  case graphql_1.OperationTypeNode.MUTATION:
642
- return new Set([string_constants_1.EDFS_REQUEST, string_constants_1.EDFS_PUBLISH]);
721
+ return new Set([string_constants_1.EDFS_KAFKA_PUBLISH, string_constants_1.EDFS_NATS_PUBLISH, string_constants_1.EDFS_NATS_REQUEST]);
643
722
  case graphql_1.OperationTypeNode.QUERY:
644
- return new Set([string_constants_1.EDFS_REQUEST]);
723
+ return new Set([string_constants_1.EDFS_NATS_REQUEST]);
645
724
  case graphql_1.OperationTypeNode.SUBSCRIPTION:
646
- return new Set([string_constants_1.EDFS_SUBSCRIBE]);
725
+ return new Set([string_constants_1.EDFS_KAFKA_SUBSCRIBE, string_constants_1.EDFS_NATS_SUBSCRIBE]);
726
+ }
727
+ }
728
+ getOperationTypeNodeForRootTypeName(parentTypeName) {
729
+ const operationTypeNode = this.operationTypeNodeByTypeName.get(parentTypeName);
730
+ if (operationTypeNode) {
731
+ return operationTypeNode;
732
+ }
733
+ switch (parentTypeName) {
734
+ case string_constants_1.MUTATION:
735
+ return graphql_1.OperationTypeNode.MUTATION;
736
+ case string_constants_1.QUERY:
737
+ return graphql_1.OperationTypeNode.QUERY;
738
+ case string_constants_1.SUBSCRIPTION:
739
+ return graphql_1.OperationTypeNode.SUBSCRIPTION;
647
740
  default:
648
741
  return;
649
742
  }
650
743
  }
651
- validateEventDrivenRootType(data, validEventsDirectiveNames, invalidEventsDirectiveDataByRootFieldPath, invalidResponseTypeStringByRootFieldPath, invalidResponseTypeNameByMutationPath) {
652
- const isMutation = validEventsDirectiveNames.has(string_constants_1.EDFS_PUBLISH);
744
+ validateEventDrivenRootType(data, invalidEventsDirectiveDataByRootFieldPath, invalidResponseTypeStringByRootFieldPath, invalidResponseTypeNameByMutationPath) {
745
+ const operationTypeNode = this.getOperationTypeNodeForRootTypeName(data.name);
746
+ if (!operationTypeNode) {
747
+ // should never happen
748
+ this.errors.push((0, errors_1.invalidRootTypeError)(data.name));
749
+ return;
750
+ }
751
+ const validEventDirectiveNames = this.getValidEventsDirectiveNamesForOperationTypeNode(operationTypeNode);
653
752
  for (const [fieldName, fieldData] of data.fieldDataByFieldName) {
654
753
  const fieldPath = `${fieldData.originalParentTypeName}.${fieldName}`;
655
754
  const definedEventsDirectiveNames = new Set();
@@ -660,7 +759,7 @@ class NormalizationFactory {
660
759
  }
661
760
  const invalidEventsDirectiveNames = new Set();
662
761
  for (const definedEventsDirectiveName of definedEventsDirectiveNames) {
663
- if (!validEventsDirectiveNames.has(definedEventsDirectiveName)) {
762
+ if (!validEventDirectiveNames.has(definedEventsDirectiveName)) {
664
763
  invalidEventsDirectiveNames.add(definedEventsDirectiveName);
665
764
  }
666
765
  }
@@ -670,7 +769,7 @@ class NormalizationFactory {
670
769
  invalidDirectiveNames: [...invalidEventsDirectiveNames],
671
770
  });
672
771
  }
673
- if (isMutation) {
772
+ if (operationTypeNode === graphql_1.OperationTypeNode.MUTATION) {
674
773
  const typeString = (0, merge_1.printTypeNode)(fieldData.type);
675
774
  if (typeString !== string_constants_1.NON_NULLABLE_EDFS_PUBLISH_EVENT_RESULT) {
676
775
  invalidResponseTypeNameByMutationPath.set(fieldPath, typeString);
@@ -741,7 +840,7 @@ class NormalizationFactory {
741
840
  }
742
841
  return true;
743
842
  }
744
- isStreamConfigurationInputObjectValid(streamConfigurationInputData) {
843
+ isNatsStreamConfigurationInputObjectValid(streamConfigurationInputData) {
745
844
  if (streamConfigurationInputData.kind !== graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION) {
746
845
  return false;
747
846
  }
@@ -775,9 +874,8 @@ class NormalizationFactory {
775
874
  continue;
776
875
  }
777
876
  // If a required events directive is returned, the parent type is a root type
778
- const validEventsDirectiveNames = this.getValidEventsDirectiveNamesForRootTypeName(data.name);
779
- if (validEventsDirectiveNames) {
780
- this.validateEventDrivenRootType(data, validEventsDirectiveNames, invalidEventsDirectiveDataByRootFieldPath, invalidResponseTypeStringByRootFieldPath, invalidResponseTypeNameByMutationPath);
877
+ if (data.isRootType) {
878
+ this.validateEventDrivenRootType(data, invalidEventsDirectiveDataByRootFieldPath, invalidResponseTypeStringByRootFieldPath, invalidResponseTypeNameByMutationPath);
781
879
  continue;
782
880
  }
783
881
  const keyFieldNames = this.keyFieldNamesByParentTypeName.get(typeName);
@@ -789,17 +887,15 @@ class NormalizationFactory {
789
887
  this.validateEventDrivenObjectFields(data.fieldDataByFieldName, keyFieldNames, nonExternalKeyFieldNameByFieldPath, nonKeyFieldNameByFieldPath);
790
888
  }
791
889
  for (const [typeName, data] of this.parentDefinitionDataByTypeName) {
792
- // validate edfs__PublishResult and edfs__StreamConfiguration separately
793
- if (typeName === string_constants_1.EDFS_PUBLISH_RESULT || typeName === string_constants_1.EDFS_STREAM_CONFIGURATION) {
890
+ // validate edfs__PublishResult and edfs__NatsStreamConfiguration separately
891
+ if (typeName === string_constants_1.EDFS_PUBLISH_RESULT || typeName === string_constants_1.EDFS_NATS_STREAM_CONFIGURATION) {
794
892
  continue;
795
893
  }
796
894
  if (data.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
797
895
  continue;
798
896
  }
799
- // If a required events directive is returned, the parent type is a root type
800
- const validEventsDirectiveNames = this.getValidEventsDirectiveNamesForRootTypeName(data.name);
801
- if (validEventsDirectiveNames) {
802
- this.validateEventDrivenRootType(data, validEventsDirectiveNames, invalidEventsDirectiveDataByRootFieldPath, invalidResponseTypeStringByRootFieldPath, invalidResponseTypeNameByMutationPath);
897
+ if (data.isRootType) {
898
+ this.validateEventDrivenRootType(data, invalidEventsDirectiveDataByRootFieldPath, invalidResponseTypeStringByRootFieldPath, invalidResponseTypeNameByMutationPath);
803
899
  continue;
804
900
  }
805
901
  const keyFieldNames = this.keyFieldNamesByParentTypeName.get(typeName);
@@ -813,12 +909,14 @@ class NormalizationFactory {
813
909
  if (!this.isEdfsPublishResultValid()) {
814
910
  errorMessages.push(errors_1.invalidEdfsPublishResultObjectErrorMessage);
815
911
  }
816
- const streamConfigurationInputData = this.parentDefinitionDataByTypeName.get(string_constants_1.EDFS_STREAM_CONFIGURATION);
817
- if (!streamConfigurationInputData) {
818
- errorMessages.push(errors_1.undefinedStreamConfigurationInputErrorMessage);
819
- }
820
- else if (!this.isStreamConfigurationInputObjectValid(streamConfigurationInputData)) {
821
- errorMessages.push(errors_1.invalidStreamConfigurationInputErrorMessage);
912
+ if (this.edfsDirectiveReferences.has(string_constants_1.EDFS_NATS_SUBSCRIBE)) {
913
+ const streamConfigurationInputData = this.parentDefinitionDataByTypeName.get(string_constants_1.EDFS_NATS_STREAM_CONFIGURATION);
914
+ if (!streamConfigurationInputData) {
915
+ errorMessages.push(errors_1.undefinedNatsStreamConfigurationInputErrorMessage);
916
+ }
917
+ else if (!this.isNatsStreamConfigurationInputObjectValid(streamConfigurationInputData)) {
918
+ errorMessages.push(errors_1.invalidNatsStreamConfigurationDefinitionErrorMessage);
919
+ }
822
920
  }
823
921
  if (invalidEventsDirectiveDataByRootFieldPath.size > 0) {
824
922
  errorMessages.push((0, errors_1.invalidRootTypeFieldEventsDirectivesErrorMessage)(invalidEventsDirectiveDataByRootFieldPath));
@@ -914,10 +1012,22 @@ class NormalizationFactory {
914
1012
  }
915
1013
  definitions.push(constants_1.SCOPE_SCALAR_DEFINITION);
916
1014
  }
917
- if (this.isEventDrivenSubgraph) {
918
- for (const directiveDefinition of constants_1.EVENT_DRIVEN_DIRECTIVE_DEFINITIONS) {
919
- definitions.push(directiveDefinition);
1015
+ for (const directiveName of this.edfsDirectiveReferences) {
1016
+ const directiveDefinition = constants_1.EVENT_DRIVEN_DIRECTIVE_DEFINITIONS_BY_DIRECTIVE_NAME.get(directiveName);
1017
+ if (!directiveDefinition) {
1018
+ // should never happen
1019
+ this.errors.push((0, errors_1.invalidEdfsDirectiveName)(directiveName));
1020
+ continue;
920
1021
  }
1022
+ definitions.push(directiveDefinition);
1023
+ }
1024
+ // subscriptionFilter is temporarily valid only in an EDG
1025
+ if (this.edfsDirectiveReferences.size > 0 && this.referencedDirectiveNames.has(string_constants_1.SUBSCRIPTION_FILTER)) {
1026
+ this.directiveDefinitionByDirectiveName.set(string_constants_1.SUBSCRIPTION_FILTER, constants_1.SUBSCRIPTION_FILTER_DEFINITION);
1027
+ definitions.push(constants_1.SUBSCRIPTION_FILTER_DEFINITION);
1028
+ definitions.push(constants_1.SUBSCRIPTION_FILTER_CONDITION_DEFINITION);
1029
+ definitions.push(constants_1.SUBSCRIPTION_FIELD_CONDITION_DEFINITION);
1030
+ definitions.push(constants_1.SUBSCRIPTION_FILTER_VALUE_DEFINITION);
921
1031
  }
922
1032
  for (const directiveDefinition of this.customDirectiveDefinitions.values()) {
923
1033
  definitions.push(directiveDefinition);
@@ -1189,7 +1299,7 @@ class NormalizationFactory {
1189
1299
  }
1190
1300
  (0, utils_4.addPersistedDirectiveDefinitionDataByNode)(persistedDirectiveDefinitionDataByDirectiveName, directiveDefinitionNode, this.errors, this.directiveDefinitionByDirectiveName, this.handledRepeatedDirectivesByHostPath, executableLocations, this.subgraphName);
1191
1301
  }
1192
- if (this.isEventDrivenSubgraph) {
1302
+ if (this.edfsDirectiveReferences.size > 0) {
1193
1303
  this.validateEventDrivenSubgraph();
1194
1304
  }
1195
1305
  if (this.errors.length > 0) {