Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

"cache if" feature #56

Open
jeromedalbert opened this issue Apr 2, 2019 · 1 comment
Open

"cache if" feature #56

jeromedalbert opened this issue Apr 2, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@jeromedalbert
Copy link
Contributor

jeromedalbert commented Apr 2, 2019

Similar to Rails views:

- cache_if (current_user.nil?) do

And actionpack-action_caching:

caches_action :show, if: -> { current_user.nil? }

It would be nice to be able to do something like this in graphql-cache:

field :calculated_field, Int, cache: { if: -> { current_user.nil? } }

Although the double-brackets might feel awkward, so it might look cleaner to do

field :calculated_field, Int do
  cache if: -> { current_user.nil? }
end

(which is related to my second bullet point on #52 referring to the ability to have cache on its own line)

@jeromedalbert jeromedalbert changed the title "cache_if" feature "cache if" feature Apr 2, 2019
@thebadmonkeydev thebadmonkeydev added the enhancement New feature or request label Apr 4, 2019
@drewlustro
Copy link

I agree this would be nice. On our site we'd like to disable the cache for logged in users.

@thebadmonkeydev thebadmonkeydev self-assigned this Jul 24, 2019
@thebadmonkeydev thebadmonkeydev removed their assignment Aug 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants