Fix: totalCount returned -1 when no elements were returned. #8929
+87
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of the changes (Less than 80 chars)
-When exposing a PageConnection the totalCount was returned as -1 when no elements were returned by the quers
Closes #8564(in this specific format)
Note: This is the most straightforward way to solve the problem, by simply adjusting the fallback value. This should be safe because the totalCount field is included in the GraphQL type only when
IncludeTotalCount = true.However, a different approach is to adjust
Page<T>.Emptybased on whetherIncludeTotalCount = truewas specified or not. That approach works too and may also be more future proof, but it is a breaking change and probably not necessary. You can find that approach here. Note that all tests are passing with both approaches.