public OrderTypeUrl (IDataLoaderContextAccessor dataLoaderAccessor, AllocationsRepositoryUrl allocationsRepositoryUrl) { Field(t => t.OrderId); Field(t => t.OmsOrderId); Field(t => t.OmsOrderVersionId); Field(t => t.GamId, nullable: true); Field(t => t.SecurityType); Field(t => t.TradeDate); Field(t => t.Trader, nullable: true); Field(t => t.SourceListCode, nullable: true); Field(t => t.SourceListitemCode); Field(t => t.CreatedDate); // Using dataloader // ---------------- Field <ListGraphType <AllocationTypeUrl> >( "allocations", resolve: context => { var loader = dataLoaderAccessor.Context.GetOrAddCollectionBatchLoader <int, Allocations>( "GetAllocationsByOrderId", allocationsRepositoryUrl.GetForOrders); return(loader.LoadAsync(context.Source.OrderId)); }); }
public MartinType (IDataLoaderContextAccessor dataLoaderAccessor, AllocationsRepositoryUrl allocationsRepository) { Field(t => t.OrderId); Field(t => t.OmsOrderId); Field(t => t.OmsOrderVersionId); Field(t => t.GamId); Field(t => t.SecurityType); Field(t => t.TradeDate); Field(t => t.Trader); Field(t => t.SourceListCode); Field(t => t.SourceListitemCode); Field(t => t.CreatedDate); Field <IntGraphType>().Name("allocationCount").ResolveAsync(async(context) => { return(await allocationsRepository.GetCountForOrder(context.Source.OrderId)); }); // Using dataloader // ---------------- Field <ListGraphType <AllocationTypeUrl> >( "allocations", resolve: context => { var loader = dataLoaderAccessor.Context.GetOrAddCollectionBatchLoader <int, Allocations>( "GetAllocationsByOrderId", allocationsRepository.GetForOrders); return(loader.LoadAsync(context.Source.OrderId)); }); }