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
7 changes: 7 additions & 0 deletions src/Trax.Effect/Attributes/TraxMutationAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ public TraxMutationAttribute(params GraphQLOperation[] operations)
/// Clients see a deprecation warning during introspection.
/// </summary>
public string? DeprecationReason { get; init; }

/// <summary>
/// Groups this field under a sub-namespace in the GraphQL schema.
/// When set, the field appears under <c>dispatch { namespace { field } }</c>
/// instead of directly under <c>dispatch { field }</c>.
/// </summary>
public string? Namespace { get; init; }
}

/// <summary>
Expand Down
7 changes: 7 additions & 0 deletions src/Trax.Effect/Attributes/TraxQueryAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,11 @@ public class TraxQueryAttribute : Attribute
/// Clients see a deprecation warning during introspection.
/// </summary>
public string? DeprecationReason { get; init; }

/// <summary>
/// Groups this field under a sub-namespace in the GraphQL schema.
/// When set, the field appears under <c>discover { namespace { field } }</c>
/// instead of directly under <c>discover { field }</c>.
/// </summary>
public string? Namespace { get; init; }
}
68 changes: 68 additions & 0 deletions src/Trax.Effect/Attributes/TraxQueryModelAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
namespace Trax.Effect.Attributes;

/// <summary>
/// Exposes an EF Core entity as a typed GraphQL query field under <c>discover</c>
/// with optional cursor pagination, filtering, sorting, and projection.
/// </summary>
/// <remarks>
/// Place this attribute on entity classes that are exposed via a <c>DbSet&lt;T&gt;</c>
/// on a DbContext registered with <c>AddTraxGraphQL(g =&gt; g.AddDbContext&lt;TContext&gt;())</c>.
/// The generated field name is derived by pluralizing and camelCasing the class name
/// (e.g. <c>Player</c> → <c>players</c>), or overridden via <see cref="Name"/>.
///
/// Each feature (paging, filtering, sorting, projection) can be individually disabled
/// via the corresponding property. All default to <c>true</c>.
/// </remarks>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public class TraxQueryModelAttribute : Attribute
{
/// <summary>
/// Overrides the auto-derived GraphQL field name.
/// When null, the name is derived by pluralizing and camelCasing the class name
/// (e.g. <c>Player</c> → <c>players</c>, <c>MatchResult</c> → <c>matchResults</c>).
/// </summary>
public string? Name { get; init; }

/// <summary>
/// A human-readable description that appears in the GraphQL schema documentation.
/// </summary>
public string? Description { get; init; }

/// <summary>
/// Marks the generated field as deprecated in the GraphQL schema.
/// Clients see a deprecation warning during introspection.
/// </summary>
public string? DeprecationReason { get; init; }

/// <summary>
/// Enables cursor-based pagination (Relay Connection spec) on the query field.
/// When <c>true</c>, the field returns a Connection type with <c>nodes</c>,
/// <c>edges</c>, and <c>pageInfo</c>.
/// </summary>
public bool Paging { get; init; } = true;

/// <summary>
/// Enables filtering on the query field. When <c>true</c>, clients can use
/// a <c>where</c> argument to filter results by entity properties.
/// </summary>
public bool Filtering { get; init; } = true;

/// <summary>
/// Enables sorting on the query field. When <c>true</c>, clients can use
/// an <c>order</c> argument to sort results by entity properties.
/// </summary>
public bool Sorting { get; init; } = true;

/// <summary>
/// Enables field projection on the query field. When <c>true</c>,
/// only the columns requested by the client are selected from the database.
/// </summary>
public bool Projection { get; init; } = true;

/// <summary>
/// Groups this field under a sub-namespace in the GraphQL schema.
/// When set, the field appears under <c>discover { namespace { field } }</c>
/// instead of directly under <c>discover { field }</c>.
/// </summary>
public string? Namespace { get; init; }
}
Loading