Filter bills with sponsor name (or id?) in v2?


#1

I’m now moving my voter engagement app from v1 to v2. In v1 I was able to get bills where a given legislator was either the primary or cosponsor. That basic functionality seems to be lost in v2. With v2, I will have to run multiple batch queries to get through the hundreds of possible bills, and then sort those client-side. Which will work, but it’s insanely inefficient.

Or am I missing something. I tried…

     bills(first:100, sponsor:"Hornstein" jurisdiction:"ocd-jurisdiction/country:us/state:mn/government", chamber:"lower")
edges 

and that gave me the error: “Argument “sponsor” has invalid value “Hornstein”.\nExpected “SponsorInput”, found not an object.”

Is there something I can do here with “SponsorInput” so I can only get bills that involve a member (or even better personID)? Or if there’s no way to do this now, is this functionality in the works?

Thanks for the help :slight_smile:


#2

Hornstein doesn’t seem to have any sponsorships, but this worked for Poston:

{
  bills(first:100, sponsor:{name:"Poston"}, jurisdiction:"ocd-jurisdiction/country:us/state:mn/government", chamber:"lower")
  {
    edges {
      node {
        title
        sponsorships {
          name
          person {
            id
            name
          }
        }
      }
    }
  }
}

As you can see, the sponsor parameter is expecting an object of type SponsorInput. This threw me for a minute, too - I didn’t know you could pass an object as a parameter!

When you run this, note that the “person” is null for all sponsorships, which means that they aren’t “resolved” - the raw name provided by the state isn’t matched up with known legislators. I don’t know the status of support for this; it may be state- or chamber-specific.


#3

Oh, beauty!!! Yeah, that worked like a charm. I did a mix of the name and primary = true and boom! It filters as expected.

bills(first: 80, sponsor:{name:"Hornstein", primary:true}, jurisdiction:"Minnesota") {}

Thanks a million!! And nice work with the posts on Medium. I read a few of those last night. I’ll do the same for people trying to access this database from native apis from iOS in Objective C. Still not much out there on this in terms of external documentation. But the data here is amazing. As is the ecosystem and the support given. Love it!


#4

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