Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 3
Message 1 of 3

after cursor: empty value sometimes OK, sometimes not

Solved! Go to Solution.

Hi there,

 

A bit baffled by what I'm experiencing, hopefully I'm missing something.

In a nutshell, I have 2 queries, one to get tags on a repo and another one to perform a search.

Both of them implement pagination and as such I have to pass the afterCursor parameter.

On the first call since there's no afterCursor I simply pass a blank string and it works for tags but not for search:

 

query ($repoOwner: String!, $repoName: String!, $afterCursor: String!) {
  repository(owner: $repoOwner, name: $repoName) {
    name
    refs(refPrefix: "refs/tags/", first: 100, after: $afterCursor) {
      pageInfo {
        hasNextPage
        endCursor
      }
      // rest of the query here...
}

// variables:
{
  "repoOwner": "org name",
  "repoName": "repo name",
  "afterCursor": ""
}

 

yields expected results, while

 

query ($searchQuery: String!, $afterCursor: String!) {
  search(type: REPOSITORY, query: $searchQuery, first: 10, after: $afterCursor) {
    pageInfo {
      hasNextPage
      endCursor
    }
    // rest of the query here...
}

// variables: { "searchQuery": "some search", "afterCursor": "" }

yields error

"type": "INVALID_CURSOR_ARGUMENTS",

"message": "`` does not appear to be a valid cursor."

 

Do acceptable values for afterCursor depend on the connection?

2 Replies
Solution
Community Manager
Message 2 of 3

Re: after cursor: empty value sometimes OK, sometimes not

Have you tried `null` instead of a blank string? It's possible that the implementation slightly varies, yes. You may also want to try using two copies of the query, one with the `after` parameter and one without.

Copilot Lvl 3
Message 3 of 3

Re: after cursor: empty value sometimes OK, sometimes not

Making $afterCursor a String (not String!) and passing a null works!

 

Thanks!!