diff --git a/src/Federation/FederationTypeInterceptor.cs b/src/Federation/FederationTypeInterceptor.cs index 3453749..2952f82 100644 --- a/src/Federation/FederationTypeInterceptor.cs +++ b/src/Federation/FederationTypeInterceptor.cs @@ -2,7 +2,6 @@ using System.Linq; using System.Linq.Expressions; using System.Reflection; -using System.Text; using System.Threading.Tasks; using ApolloGraphQL.HotChocolate.Federation.Constants; using ApolloGraphQL.HotChocolate.Federation.Descriptors; @@ -61,11 +60,6 @@ public override void OnAfterInitialize( AddToUnionIfHasTypeLevelKeyDirective( objectType, objectTypeDefinition); - - AggregatePropertyLevelKeyDirectives( - objectType, - objectTypeDefinition, - discoveryContext); } } @@ -222,52 +216,6 @@ private void AddToUnionIfHasTypeLevelKeyDirective( } } - private void AggregatePropertyLevelKeyDirectives( - ObjectType objectType, - ObjectTypeDefinition objectTypeDefinition, - ITypeDiscoveryContext discoveryContext) - { - // if we find key markers on our fields, we need to construct the key directive - // from the annotated fields. - if (objectTypeDefinition.Fields.Any(f => f.ContextData.ContainsKey(KeyMarker))) - { - IReadOnlyList fields = objectTypeDefinition.Fields; - var fieldSet = new StringBuilder(); - - foreach (var fieldDefinition in fields) - { - if (fieldDefinition.ContextData.ContainsKey(KeyMarker)) - { - if (fieldSet.Length > 0) - { - fieldSet.Append(' '); - } - - fieldSet.Append(fieldDefinition.Name); - } - } - - // add the key directive with the dynamically generated field set. - AddKeyDirective(objectTypeDefinition, fieldSet.ToString()); - - // register dependency to the key directive so that it is completed before - // we complete this type. - foreach (var directiveDefinition in objectTypeDefinition.Directives) - { - discoveryContext.Dependencies.Add( - new TypeDependency( - directiveDefinition.Type, - TypeDependencyFulfilled.Completed)); - - discoveryContext.Dependencies.Add(new(directiveDefinition.Type)); - } - - // since this type has now a key directive we also need to add this type to - // the _Entity union type. - _entityTypes.Add(objectType); - } - } - private void AddMemberTypesToTheEntityUnionType( ITypeCompletionContext completionContext, DefinitionBase? definition) @@ -281,18 +229,4 @@ private void AddMemberTypesToTheEntityUnionType( } } } - - private static void AddKeyDirective( - ObjectTypeDefinition objectTypeDefinition, - string fieldSet) - { - var directiveNode = new DirectiveNode( - WellKnownTypeNames.Key, - new ArgumentNode( - WellKnownArgumentNames.Fields, - fieldSet)); - - objectTypeDefinition.Directives.Add( - new DirectiveDefinition(directiveNode)); - } } \ No newline at end of file