Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/damikun/hcpaginationbug

This is bug example related to https://github.com/ChilliCream/hotchocolate/issues/2154
https://github.com/damikun/hcpaginationbug

Last synced: about 2 months ago
JSON representation

This is bug example related to https://github.com/ChilliCream/hotchocolate/issues/2154

Awesome Lists containing this project

README

        

# HCPaginationBug
This is bug reproduce repo... do not use this as example!

Related to bug: https://github.com/ChilliCream/hotchocolate/issues/2154

Test data included! (in Program.cs)

## Bug location

After quick check it looks like problem in this part but im not sure... i did not debug it yet... It looks like going from + over 0 to - is not handled...

under: https://github.com/ChilliCream/hotchocolate/blob/a7b1f39c686d2d572f0ef61ff9d8c0ceea90b795/src/HotChocolate/Core/src/Types/Types/Relay/QueryableConnectionResolver.cs

```
int count = temp.Count();
int skip = count - last;
```

```
protected virtual IQueryable GetLastEdges(
IQueryable edges, int last,
ref int offset)
{
if (last < 0)
{
throw new ArgumentOutOfRangeException(nameof(last));
}

IQueryable temp = edges;

int count = temp.Count();
int skip = count - last;

if (skip > 1)
{
temp = temp.Skip(skip);
offset += count;
offset -= temp.Count();
}

return temp;
}
```

# To Run
```
1 Fetch to local Git
2 Run: dotnet restore
3 Run: dotnet wacth run
```
Info: Running on .Net5 Standard

# Playground Query
```
query Users(
$first: PaginationAmount
$last: PaginationAmount
$after: String
$before: String
) {
users(
first: $first
after: $after
before: $before
last: $last
) {
pageInfo {
hasPreviousPage
hasNextPage
startCursor
endCursor
}
edges {
cursor
node {
iD
name
}
}
}
}
```
## Query Variables
```
{
"first": null,
"last": 1 ,
"before": "Mg==",
"after": null
}

```
# SQLite database table

under:
appDB.db

| # | ID | Name |
|:-:|:--:|:-----:|
| 1 | 1 | user1 |
| 2 | 2 | user2 |
| 3 | 3 | user3 |
| 4 | 4 | user4 |

# Packages:
```
















runtime; build; native; contentfiles; analyzers; buildtransitive
all


```