Skip to content

Add mechanism to exclude specific Type classes from auto-discovery #8583

@PHILLIPS71

Description

@PHILLIPS71

Product

Hot Chocolate

Is your feature request related to a problem?

I need to prevent a ScalarType class from being auto-discovered and registered by HotChocolate.Types.Analyzers because it's designed to be instantiated dynamically by a TypeInterceptor, not registered automatically.

Context

  • Working with HotChocolate.Types.Analyzers
  • Modeling a generic type Id<T> in GraphQL schema
  • Have a class IdTypedScalar : ScalarType that should be created dynamically by a TypeInterceptor for each concrete type (e.g., Id<User>, Id<Product>, etc.)
  • The analyzers are auto-discovering it and generating builder.AddType<IdTypedScalar>() which fails because it requires constructor parameters (the generic type argument)
  • This class should only be instantiated by my interceptor, not registered automatically

What I've Tried

  • Making it internal / private - still gets discovered
  • Using [GraphQLIgnore] - annotation cannot target a class

Question

Is there a way to exclude specific classes that inherit from ScalarType from being auto-discovered by HotChocolate.Types.Analyzers? Looking for:

  • An attribute to mark the class as non-discoverable
  • Configuration options to exclude specific types
  • Any other mechanism to prevent auto-registration

The solution you'd like

The IdTypedScalar class should be excluded from auto-discovery so that:

  • It doesn't generate builder.AddType<IdTypedScalar>() calls
  • It can still be instantiated by my TypeInterceptor (e.g., new IdTypedScalar(typeof(User)))

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions