Skip to content

Commit

Permalink
\Allow "null" to be passed in filters Docs for PR graphiti-api/graphi…
Browse files Browse the repository at this point in the history
  • Loading branch information
zeisler authored Apr 9, 2020
1 parent e88eac3 commit c063c7f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ exclude:

github:
url: 'https://www.graphiti.dev'
#url: 'http://localhost:4000'
# url: 'http://localhost:4000'
defaults:
- scope:
path: "assets/img"
Expand Down
10 changes: 10 additions & 0 deletions guides/concepts/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,16 @@ end
If a filter is marked `single: true`, we'll avoid any array parsing and
escape the value for you, filtering on the string as given.

By default a value that comes in as `null` is treated as a string `"null"`.
To coerce `null` to a Ruby `nil` mark the filter with `allow_nil: true`.
This can be changed for all attributes by setting `filters_accept_nil_by_default`

{% highlight ruby %}
class PostResource < ApplicationResource
self.filters_accept_nil_by_default = true
end
{% endhighlight %}

{% include h.html tag="h4" text="3.6 Statistics" a="statistics" %}

Statistics are useful and common. Consider a datagrid listing posts - we might want a "Total Posts" count displayed above the grid without firing an additional request. Notably, that statistic **should** take into account filtering, but **should not** take into account pagination.
Expand Down

0 comments on commit c063c7f

Please sign in to comment.