Skip to content

Instantly share code, notes, and snippets.

@jeromedalbert
Created October 26, 2022 01:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeromedalbert/68e58ce62563b3950bf5d715ca45fced to your computer and use it in GitHub Desktop.
Save jeromedalbert/68e58ce62563b3950bf5d715ca45fced to your computer and use it in GitHub Desktop.
# Monkey patch to support an `enabled` option
module GraphQL
module FragmentCache
class << self
attr_accessor :enabled
end
self.enabled = true
class FieldExtension
module MonkeyPatch
def resolve(object:, arguments:, **_options)
return yield(object, arguments) if !GraphQL::FragmentCache.enabled
super
end
end
prepend MonkeyPatch
end
end
end
GraphQL::FragmentCache.enabled = false if Rails.env.test?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment