diff --git a/src/Trax.Effect/Attributes/FieldBindingBehavior.cs b/src/Trax.Effect/Attributes/FieldBindingBehavior.cs new file mode 100644 index 0000000..e414ba3 --- /dev/null +++ b/src/Trax.Effect/Attributes/FieldBindingBehavior.cs @@ -0,0 +1,19 @@ +namespace Trax.Effect.Attributes; + +/// +/// Controls how fields are bound when generating the GraphQL ObjectType +/// for an entity marked with . +/// +public enum FieldBindingBehavior +{ + /// + /// All public properties and methods are exposed as GraphQL fields (default HotChocolate behavior). + /// + Implicit = 0, + + /// + /// Only properties decorated with + /// are exposed. Properties with [NotMapped], methods, and non-column public members are excluded. + /// + Explicit = 1, +} diff --git a/src/Trax.Effect/Attributes/TraxQueryModelAttribute.cs b/src/Trax.Effect/Attributes/TraxQueryModelAttribute.cs index 6ac1579..aa362e7 100644 --- a/src/Trax.Effect/Attributes/TraxQueryModelAttribute.cs +++ b/src/Trax.Effect/Attributes/TraxQueryModelAttribute.cs @@ -59,6 +59,15 @@ public class TraxQueryModelAttribute : Attribute /// public bool Projection { get; init; } = true; + /// + /// Controls how fields are bound on the generated GraphQL ObjectType. + /// When , only properties with + /// + /// are exposed; [NotMapped] properties, methods, and other public members are excluded. + /// Defaults to (all public properties exposed). + /// + public FieldBindingBehavior BindFields { get; init; } = FieldBindingBehavior.Implicit; + /// /// Groups this field under a sub-namespace in the GraphQL schema. /// When set, the field appears under discover { namespace { field } }