[Solved] Including PersonVoteNode causes 502 Gateway Error via Bills Node


#1

My query:

{
bills(first:5, after:"", jurisdiction:"Colorado"){
  pageInfo{
    hasNextPage
    hasPreviousPage
    startCursor
    endCursor
  }
  totalCount
  edges{
    node{
      id
      legislativeSession{
        identifier
      }
      identifier
      title
      fromOrganization{
        id
        classification
      }
      classification
      subject
      abstracts{
        abstract
        note
        date
      }
      otherTitles{
        title
        note
      }
      actions{
        description
        organization{
          classification
        }
      date
      order
      classification
      }
      sponsorships{
        name
        entityType
        primary
        classification
        person{
          id
        }
      }
      relatedBills{
        identifier
        legislativeSession 
        relationType
        relatedBill{
          id
          classification
        }
      }
      versions{
        note
        date
        links{
          mediaType
          url
          text
        }
      }
      documents{
        links{
          mediaType
          url
          text
        }
        note
        date
      }
      votes{
        edges{
          node{
            id
            result
            organization{
              classification
            }
            sources{
              url
            }
            votes{
              option
              voter{
                id
              }
              voterName
              note
            }
            motionText
            motionClassification
            counts{
              option
              value
            }
          }
        }
      }
      sources{
        url
      }
      openstatesUrl
      createdAt
      updatedAt
      extras
    }      
  }
}
}

I can run this query without issue in the GraphiQL interface, but if I copy the URL (GraphiQL API Call) or run the query from my script a 502 Bad Gateway error is returned.

If I remove the PersonVoteNode:

votes{
  option
  voter{
    id
  }
  voterName
  note
}

…the query runs fine via a script call. Any ideas?


#2

Figured it out. For anyone that has the issue in the future:

There may be a limit on the query length. Compressing the query before sending solved this issue for me.


#3

There are limits on the response size. See Document current V2 throttle limits?

If you switch to first:1 instead of first:5, and it works, then the response had too many nodes. Because of the potentially large size of your query, I’d just switch to 1 without running into the problem. Of course, I live in NH where we have 400(!) members of our House.

None of that would explain why it started working when you compressed; I’m just warning about your NEXT likely problem.

Is it possible that in addition to compressing the query, you also enabled compression of the response (“Accept-Encoding”) in making it work? That seems much, much more likely to make a difference, because the response is orders of magnitude bigger.


#4

I don’t believe the 502 error is a result of the node limit, as going over the 5000 node limit will result in an appropriate API error. Changing the first variable to “1” also failed to make a difference.

I am using gzip/deflate in my (“Accept-Encoding”) header. The 502 error went away only by compressing the query or by deleting the PersonVoteNode.


#5

Consider capturing this as an issue at https://github.com/openstates/openstates.org/issues . I already checked the open issues and don’t see anything similar.