Skip to content

Commit

Permalink
Fixed total count breaking change in connection; (#5122)
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalSenn authored Jun 4, 2022
1 parent 4a9fcd0 commit 14f09aa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public Connection(
ConnectionPageInfo info,
int totalCount = 0)
{
_getTotalCount = _ => new(totalCount);
_getTotalCount = _ => new(info.TotalCount ?? totalCount);
Edges = edges ??
throw new ArgumentNullException(nameof(edges));
Info = info ??
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System;

namespace HotChocolate.Types.Pagination;

/// <summary>
Expand Down Expand Up @@ -25,6 +27,17 @@ public ConnectionPageInfo(
EndCursor = endCursor;
}

[Obsolete("use the constructor without the total count")]
public ConnectionPageInfo(
bool hasNextPage,
bool hasPreviousPage,
string? startCursor,
string? endCursor,
int? totalCount = null) : this(hasNextPage, hasPreviousPage, startCursor, endCursor)
{
TotalCount = totalCount;
}

/// <summary>
/// <c>true</c> if there is another page after the current one.
/// <c>false</c> if this page is the last page of the current data set / collection.
Expand All @@ -46,4 +59,7 @@ public ConnectionPageInfo(
/// When paginating forwards, the cursor to continue.
/// </summary>
public string? EndCursor { get; }

[Obsolete("The total count is on the connection")]
public int? TotalCount { get; }
}

0 comments on commit 14f09aa

Please sign in to comment.