Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination after cursor not working but except last cursor #1961

Closed
jomonkj opened this issue Oct 19, 2021 · 1 comment
Closed

Pagination after cursor not working but except last cursor #1961

jomonkj opened this issue Oct 19, 2021 · 1 comment
Labels
bug An error within Lighthouse

Comments

@jomonkj
Copy link

jomonkj commented Oct 19, 2021

Describe the bug

Pagination after cursor not working but except last cursor

Expected behavior/Solution

first result

{
  "data": {
    "tasks": {
      "pageInfo": {
        "total": 100
      },
      "edges": [
        {
          "cursor": "Njc="
        },
        {
          "cursor": "Njg=" #second request need pagination from here
        },
        {
          "cursor": "Njk="
        }
      ]
    }
  }
}

second query

# Write your query or mutation here
{
  tasks(first: 3, after:"Njg=") {
    pageInfo {
      total
    }
    edges {
      cursor
    }
  }
}

second result

{
  "data": {
    "tasks": {
      "pageInfo": {
        "total": 100
      },
      "edges": [
        {
          "cursor": "Njc=" # wrong starting 
        },
        {
          "cursor": "Njg="  
        },
        {
          "cursor": "Njk="
        }
      ]
    }
  }
}

Lighthouse Version

v5.24.0

graphql file

extend type Query @guard{
    tasks:[Task!]! @paginate(type: CONNECTION, builder: "App\\GraphQL\\Builders\\Task")
}

app/GraphQL/Builders/Task.php

<?php

namespace App\GraphQL\Builders;

class Task
{
    /**
     * @param null $_
     * @param array<string, mixed> $args
     */
    public function __invoke($_, array $args)
    {
        $query = \App\Models\Task::query();
//        $search = ArrayHelper::get($args, 'search');
//        if ($search) {
//            $query->search($search);
//        }

        return $query;
    }
}
@spawnia spawnia added the bug An error within Lighthouse label Oct 20, 2021
@spawnia
Copy link
Collaborator

spawnia commented Oct 20, 2021

Your report is completely valid, this is a problem we are aware of. We have an open issue for it, so I am going to close this one.

If you would like to implement a fix, see #311 (comment) for context.

@spawnia spawnia closed this as completed Oct 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error within Lighthouse
Projects
None yet
Development

No branches or pull requests

2 participants