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

Able to circumvent pagination when calling same field twice (with different query) using GraphQL API

When I use the following query I am asked to perform pagination (as expected) -

query {
  user(login:"armsp"){
    repositories{
      nodes{
        name
        issues(states: OPEN){
          totalCount
        }
      }
    }    
  }
}

However when I do the following I actually get all the results which doesn't make any sense to me -

 

query {
  user(login:"armsp"){
    repositories{
      totalCount
    }
    repositories{
      nodes{
        name
        issues(states: OPEN){
          totalCount
        }
      }
    }   
  }
}

Shouldn't I be asked for pagination in this query too ?

Now I have very few repos. If I run the same thing on lets say 'microsoft' then I see only 100 repos -

 

query {
  organization(login:"microsoft"){
    repositories{
      totalCount
    }
    repositories{
      nodes{
        name
        issues(states: OPEN){
          totalCount
        }
      }
    }   
  }
}

Q1) Is the number 100 a design decision?

Q2) Is it a good idea to query like this?

Q3) Should I just use pagination even if the nodes are less than 100 ? 

 

I have posted this on SO too. Just wanted a clearer picture of what is going on here.

1 Reply
Community Manager
Message 2 of 2

Re: Able to circumvent pagination when calling same field twice (with different query) using GraphQL

  1. Yes, there are some edge cases where you won't get the error message enforcing a query limit when you should.
  2. Yes, the number 100 is a design decision.
  3. No, it isn't a good idea to write your queries to take advantage of undocumented edge cases because they could be fixed or changed at any time and then your query breaks, possibly in production where it is harder to change.
  4. Yes, you should always include the limit number in connections that expect it. It's up to you whether you use 100 or some other (smaller) number.

 

I hope that helps!