module GraphQL::Schema::Member::CachedGraphQLDefinition
Adds a layer of caching over user-supplied `.to_graphql` methods. Users override `.to_graphql`, but all runtime code should use `.graphql_definition`. @api private @see concrete classes that extend this, eg {Schema::Object}
Public Instance Methods
deprecated_to_graphql()
click to toggle source
# File lib/graphql/schema/member/cached_graphql_definition.rb, line 25 def deprecated_to_graphql case method(:to_graphql).arity when 0 to_graphql else to_graphql(silence_deprecation_warning: true) end end
graphql_definition(silence_deprecation_warning: false)
click to toggle source
A cached result of {.to_graphql}. It's cached here so that user-overridden {.to_graphql} implementations are also cached
# File lib/graphql/schema/member/cached_graphql_definition.rb, line 14 def graphql_definition(silence_deprecation_warning: false) @graphql_definition ||= begin unless silence_deprecation_warning message = "Legacy `.graphql_definition` objects are deprecated and will be removed in GraphQL-Ruby 2.0. Remove `.graphql_definition` to use a class-based definition instead." caller_message = "\n\nCalled on #{self.inspect} from:\n #{caller(1, 25).map { |l| " #{l}" }.join("\n")}" GraphQL::Deprecation.warn(message + caller_message) end deprecated_to_graphql end end
initialize_copy(original)
click to toggle source
Wipe out the cached graphql_definition
so that `.to_graphql` will be called again.
Calls superclass method
# File lib/graphql/schema/member/cached_graphql_definition.rb, line 40 def initialize_copy(original) super @graphql_definition = nil end
type_class()
click to toggle source
This is for a common interface with .define-based types
# File lib/graphql/schema/member/cached_graphql_definition.rb, line 35 def type_class self end