-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Way to conditionally use fragment cache? #55
Comments
Hi @tjk! Currently it's not possible via API, but we could to do a similar thing with plain Ruby: field :search_movies, [MovieResultType], null: false do
argument :query, String, required: false
end
def search_movies(query: nil)
if query.blank?
cache_fragment(disabled: !query.blank?) do
Movie.do_expensive_search(query) # and expensive resolving
end
else
Movie.do_expensive_search(query) # and expensive resolving
end
end |
Yea considered this, just thought it was a little gross -- but I'll go with it for now! Thanks. Would love to help with a patch if it's something you want added but I figure it's probably trivial enough that you communicating the API you'd like would take more effort than just doing it yourself... but let me know! :) |
Yeah, I'm definitely open to PRs! |
Pushed my first pass attempt here: #56 |
Basically topic, but would like a way to only go through the cache under certain conditions (couldn't tell from code or docs if already supported). For example, if a particular query will explode the cardinality but I want the base case to be cached. Contrived example:
The text was updated successfully, but these errors were encountered: