Boolean Query Params


I understand that this is likely to change before it makes it out of Canary, and from the latest Core Team Meeting Minutes (2014-02-21) it sounds like they’re already aware that this is an issue.

That being said, is there a way with the current implementation to successfully work with a boolean query param?

For example, I’m listing some Challenges and I want to filter by their complete property, which is a boolean. Is there currently a way to have “All”, “Complete”, and “Incomplete” filters using query params?

I understand that passing false as the value to the query param will currently clear out the query param. Has anybody found a temporary workaround?

Here’s the gist that I apparently cannot embed…


I’m actually working on this now. Here:

I’m hoping to finish it up over the weekend. There are likely some other things that will hapen before query-params is merged into beta and finally release but its a start.

The main problem right now is that a false boolean query-param is ambiguous from an undefined or null query-param. Since your use case needs to destingish between undefined (all) and false (noncompleted) you might be better off using a string query-param instead. For example ?state=complete or ?state=inprogress ?state=all It has the benefit of being future proof for aditional states :smile:

Hope this helps.


So we ended up with a pretty nice solution to this, which is that

  1. default query param values don’t get serialized into the URL and
  2. the type of the default value is used to intelligently deserialize and cast the “true” and “false” string into true and false

So here’s how stuff works now with the latest iteration: