graphql-platform
graphql-platform copied to clipboard
DataLoader Source Generator
[BatchDataLoader]
public static IQueryable<Asset> AssetById(
IReadOnlyList<int> ids,
[DbContext(DbContextKind.Scoped)] AssetContext context)
=> context.Assets.Where(t => ids.Contains(t.Id));
[DataLoader(DataLoaderKind.Group)]
public static IQueryable<Asset> AssetById(
IReadOnlyList<int> ids,
[DbContext(DbContextKind.Pooled)] AssetContext context,
[Service(ServiceKind.Scoped)] Foo s)
=> context.Assets.Where(t => ids.Contains(t.Id));
[DataLoader]
public static IQueryable<Asset> AssetById(
IReadOnlyList<int> ids,
ISelection selection,
IArgumentMap arguments,
[DbContext(DbContextKind.Pooled)] AssetContext context)
=> context.Assets.Where(t => ids.Contains(t.Id)).Project(selection);
[BatchDataLoader]
public static IDictionary<int, Asset> AssetById(
IReadOnlyList<int> ids,
[DbContext(DbContextKind.Pooled)] AssetContext context,
[Service(ServiceKind.Scoped)] Repo repo)
=> repo.GetItems(ids);
This is very cool, @michaelstaib !
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
StaleBot has great timing 😅 I think we can close this, as it landed yesterday...
@tobias-tengler was the landing including IQueryable support?
What do you mean by IQueryable support? But likely the answer is no. The change was just to simplify how you write DataLoader and give more control over the service scope being used. Nothing special like projection support or similar things was added...
@tobias-tengler Ok, too bad. What I meant was that in original post Michael writes:
[DataLoader(DataLoaderKind.Group)]
public static IQueryable<Asset> AssetById(
IReadOnlyList<int> ids,
[DbContext(DbContextKind.Pooled)] AssetContext context,
[Service(ServiceKind.Scoped)] Foo s)
=> context.Assets.Where(t => ids.Contains(t.Id));
[DataLoader]
public static IQueryable<Asset> AssetById(
IReadOnlyList<int> ids,
ISelection selection,
IArgumentMap arguments,
[DbContext(DbContextKind.Pooled)] AssetContext context)
=> context.Assets.Where(t => ids.Contains(t.Id)).Project(selection);
Which was the reason I heart-ed the openings post =). So when this was closed I was thrilled! But I guess this is not part of HC13?
Not as far as I'm aware. Maybe you can write another issue that specifically requests this :)