Closed anli-xsigns closed 3 months ago
In general if doing DDD the entity types should not be exposed to the GraphQL type system. What we tend to do is throwing CQRS in and have a dedicated query layer that has access to an optimized read model. Only commands have access to the domain entities itself.
But you can also solve you problem ... if you inherit from the DefaultTypeInspector
and override the IsMemberIgnored
method you can check if your ignore condition is met and otherwise refer to the base
.
public override bool IsMemberIgnored(MemberInfo member)
{
if (member is null)
{
throw new ArgumentNullException(nameof(member));
}
if(member.Name == "GetDomainEvents")
{
return true;
}
return base.IsMemberIgnored(member);
}
Register you custom instance of the convention like this:
services.AddGraphQLServer().TryAddConvention<ITypeInspector, MyTypeInspector>();
Help our project by staring us on GitHub. Its the easiest way to give back to this project.
Product
Hot Chocolate
Is your feature request related to a problem?
Please see the source code at https://github.com/anli-xsigns/hc-graphql.
.AddTypes()
to add all types to the graphql server.IReadOnlyList<IDomainEvent> GetDomainEvents()
HotChocolate tries to add the type IDomainEvent https://github.com/anli-xsigns/hc-graphql/blob/master/Domain/IDomainEvent.cs to the schema.The solution you'd like
I would like to prevent HotChocolate from adding the IDomainEvent and even GetDomainEvents() to the schema with an attribute, e. g.
[GraphQLIgnore]