diff --git a/src/OrchardCore.Modules/OrchardCore.Lists/GraphQL/ListQueryObjectType.cs b/src/OrchardCore.Modules/OrchardCore.Lists/GraphQL/ListQueryObjectType.cs index 246cc35bdb6..0862a60aa53 100644 --- a/src/OrchardCore.Modules/OrchardCore.Lists/GraphQL/ListQueryObjectType.cs +++ b/src/OrchardCore.Modules/OrchardCore.Lists/GraphQL/ListQueryObjectType.cs @@ -35,15 +35,14 @@ public ListQueryObjectType(IStringLocalizer S) var session = serviceProvider.GetService(); var accessor = serviceProvider.GetRequiredService(); - var dataLoader = accessor.Context.GetOrAddCollectionBatchLoader("ContainedPublishedContentItems", x => LoadPublishedContentItemsForListAsync(x, session)); + var dataLoader = accessor.Context.GetOrAddCollectionBatchLoader("ContainedPublishedContentItems", + x => LoadPublishedContentItemsForListAsync(x, session, g.GetArgument("skip"), g.GetArgument("first"))); - return ((await dataLoader.LoadAsync(g.Source.ContentItem.ContentItemId).GetResultAsync()) - .Skip(g.GetArgument("skip")) - .Take(g.GetArgument("first"))); + return await dataLoader.LoadAsync(g.Source.ContentItem.ContentItemId).GetResultAsync(); }); } - private static async Task> LoadPublishedContentItemsForListAsync(IEnumerable contentItemIds, ISession session) + private static async Task> LoadPublishedContentItemsForListAsync(IEnumerable contentItemIds, ISession session, int skip, int count) { if (contentItemIds is null || !contentItemIds.Any()) { @@ -54,6 +53,8 @@ private static async Task> LoadPublishedContentItem .With(ci => ci.Published) .With(cp => cp.ListContentItemId.IsIn(contentItemIds)) .OrderBy(o => o.Order) + .Skip(skip) + .Take(count) .ListAsync(); return query.ToLookup(k => k.As().ListContentItemId); diff --git a/src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/ContentItemsFieldType.cs b/src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/ContentItemsFieldType.cs index 7a682b0268e..484494cf969 100644 --- a/src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/ContentItemsFieldType.cs +++ b/src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/ContentItemsFieldType.cs @@ -56,7 +56,7 @@ public ContentItemsFieldType(string contentItemName, ISchema schema, IOptions { Name = "status", Description = "publication status of the content item", ResolvedType = new PublicationStatusGraphType(), DefaultValue = PublicationStatusEnum.Published } ); - Resolver = new LockedAsyncFieldResolver>(Resolve); + Resolver = new LockedAsyncFieldResolver>(ResolveAsync); schema.RegisterType(whereInput); schema.RegisterType(orderByInput); @@ -65,7 +65,7 @@ public ContentItemsFieldType(string contentItemName, ISchema schema, IOptions> Resolve(IResolveFieldContext context) + private async ValueTask> ResolveAsync(IResolveFieldContext context) { var versionOption = VersionOptions.Published;