TraxOutboundQueryAttribute
Package Trax.Api.GraphQL.Client.TraxNamespace Trax.Api.GraphQL.Client.TraxSource TraxOutboundQueryAttribute.cs, OutboundQueryDiscovery.cs
Marks a request type as a call to a named external GraphQL endpoint. It is metadata only: it changes
no runtime behaviour and does not choose the client that validates the request.
OutboundQueryDiscovery reads it.
Signature
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
public sealed class TraxOutboundQueryAttribute : Attribute
{
public TraxOutboundQueryAttribute(string endpoint);
public string Endpoint { get; }
}
public static class OutboundQueryDiscovery
{
public static IReadOnlyList<Entry> Discover(params Assembly[] assemblies);
public sealed record Entry(Type RequestType, string Endpoint, string? QueryName);
}Members
| Member | Description |
|---|---|
Endpoint | The endpoint's logical name, such as PlayerService. Not a URL |
Discover(assemblies) | Every concrete request class in assemblies that carries the attribute |
Entry.RequestType | The request type |
Entry.Endpoint | The attribute's Endpoint |
Entry.QueryName | The operation name read from the request's query, or null when the operation is anonymous, not a query or mutation, or the query cannot be read |
Behavior
- The constructor throws
ArgumentExceptionfor a null, empty or whitespace endpoint. DiscoverthrowsArgumentNullExceptionfornull. It creates each type without running a constructor to read itsQuery; any failure there leavesQueryNamenull.- Nothing in Trax calls
Discover, and the dashboard does not show the attribute.
Example
[TraxOutboundQuery("PlayerService")]
public sealed class GetPlayerLevelRequest : IGraphQLClientRequest<int>
{
public string Query => "query PlayerLevel { me { level } }";
}
public static class OutboundReport
{
public static void Print()
{
foreach (var entry in OutboundQueryDiscovery.Discover(typeof(OutboundReport).Assembly))
Console.WriteLine($"{entry.RequestType.Name} -> {entry.Endpoint} ({entry.QueryName})");
}
}