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.

See Also:

  • classes that extend this, eg {Schema::Object}

Instance Method Summary collapse

Instance Method Details

#graphql_definitionObject

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
# File 'lib/graphql/schema/member/cached_graphql_definition.rb', line 14

def graphql_definition
  @graphql_definition ||= to_graphql
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.



24
25
26
27
# File 'lib/graphql/schema/member/cached_graphql_definition.rb', line 24

def initialize_copy(original)
  super
  @graphql_definition = nil
end

#type_classObject

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



19
20
21
# File 'lib/graphql/schema/member/cached_graphql_definition.rb', line 19

def type_class
  self
end