Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/Trax.Effect/Attributes/FieldBindingBehavior.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace Trax.Effect.Attributes;

/// <summary>
/// Controls how fields are bound when generating the GraphQL ObjectType
/// for an entity marked with <see cref="TraxQueryModelAttribute"/>.
/// </summary>
public enum FieldBindingBehavior
{
/// <summary>
/// All public properties and methods are exposed as GraphQL fields (default HotChocolate behavior).
/// </summary>
Implicit = 0,

/// <summary>
/// Only properties decorated with <see cref="System.ComponentModel.DataAnnotations.Schema.ColumnAttribute"/>
/// are exposed. Properties with <c>[NotMapped]</c>, methods, and non-column public members are excluded.
/// </summary>
Explicit = 1,
}
9 changes: 9 additions & 0 deletions src/Trax.Effect/Attributes/TraxQueryModelAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ public class TraxQueryModelAttribute : Attribute
/// </summary>
public bool Projection { get; init; } = true;

/// <summary>
/// Controls how fields are bound on the generated GraphQL ObjectType.
/// When <see cref="FieldBindingBehavior.Explicit"/>, only properties with
/// <see cref="System.ComponentModel.DataAnnotations.Schema.ColumnAttribute"/>
/// are exposed; <c>[NotMapped]</c> properties, methods, and other public members are excluded.
/// Defaults to <see cref="FieldBindingBehavior.Implicit"/> (all public properties exposed).
/// </summary>
public FieldBindingBehavior BindFields { get; init; } = FieldBindingBehavior.Implicit;

/// <summary>
/// Groups this field under a sub-namespace in the GraphQL schema.
/// When set, the field appears under <c>discover { namespace { field } }</c>
Expand Down
Loading