Graphql paging not working as expected


#1

I’m running a query to get 100 bills at a time. I get the cursor back from the first call, and use that in the ‘after’ slot for the next call. That works as expected, and so does the next call with the next cursor. But then on the third call, it keeps giving me the same cursor over and over again, even though it says hasNextPage is true.

Notice how the cursor below is ‘YXJyYXljb25uZWN0aW9uOjE5OQ==’. But the response contains that same cursor again, so I just end up in an infinite loop. Any ideas what’s going on here?

    {
      bills (updatedSince:"2018-10-10" first:100, after: "YXJyYXljb25uZWN0aW9uOjE5OQ==", jurisdiction: "Massachusetts") {
        pageInfo {
        hasNextPage
        endCursor
        }
        edges {
          node {
            id
            identifier
            title
            classification
            updatedAt
            createdAt
            legislativeSession {
              identifier
              jurisdiction {
                name
              }
            }
            actions {
              date
              description
              classification
            }
            documents {
              date
              note
              links {
                url
              }
            }
            versions {
              date
              note
              links {
                url
              }
            }
            sources {
              url
              note
            }
          }
        }
      }
    }

#2

Sounds and looks like you’re doing almost everything right. I see the same thing.

But the return packet is really huge, 9700 lines as rendered in GraphiQL, and it’s possible that there’s some bug related to that. The first thing I’d try is 10 at a time, rather than 100, and see if it helps. I’d suggest posting an issue at https://github.com/openstates/new-openstates.org ; if you don’t, I will. Please update if you find out more or get stuck.

Related: Document current V2 throttle limits?


#3

Ed this looks great- I’d be glad to help promote this, just give me a heads up whenever you’re ready.

My focus is likely to be on other aspects of the codebase the next few weeks but I also really appreciate you surfacing the rough areas you found recently & think a lot of them will be tackled in the next “release” of the API.


#4

Thanks for the tip, it looks like that worked! I’ll go ahead and post an issue later today if you haven’t already.


#5

This topic was automatically closed 70 days after the last reply. New replies are no longer allowed.