Module: GraphQL::Schema::Member::CachedGraphQLDefinition Private
- Included in:
- Argument, EnumValue, Field, Interface::DefinitionMethods, GraphQL::Schema::Member, Wrapper
- Defined in:
- lib/graphql/schema/member/cached_graphql_definition.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Adds a layer of caching over user-supplied .to_graphql
methods.
Users override .to_graphql
, but all runtime code should use .graphql_definition
.
Defined Under Namespace
Modules: DeprecatedToGraphQL
Instance Method Summary collapse
-
#deprecated_to_graphql ⇒ Object
private
-
#graphql_definition(silence_deprecation_warning: false) ⇒ Object
private
A cached result of to_graphql.
-
#initialize_copy(original) ⇒ Object
private
Wipe out the cached graphql_definition so that
.to_graphql
will be called again. -
#type_class ⇒ Object
private
This is for a common interface with .define-based types.
Instance Method Details
#deprecated_to_graphql ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 28 29 30 31 32 |
# 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) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
A cached result of to_graphql. It’s cached here so that user-overridden to_graphql implementations are also cached
14 15 16 17 18 19 20 21 22 23 |
# 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 = "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." = "\n\nCalled on #{self.inspect} from:\n #{caller(1, 25).map { |l| " #{l}" }.join("\n")}" GraphQL::Deprecation.warn( + ) end deprecated_to_graphql end end |
#initialize_copy(original) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Wipe out the cached graphql_definition so that .to_graphql
will be called again.
40 41 42 43 |
# File 'lib/graphql/schema/member/cached_graphql_definition.rb', line 40 def initialize_copy(original) super @graphql_definition = nil end |
#type_class ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This is for a common interface with .define-based types
35 36 37 |
# File 'lib/graphql/schema/member/cached_graphql_definition.rb', line 35 def type_class self end |