Class: ElasticGraph::SchemaArtifacts::RuntimeMetadata::GraphQLResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/elastic_graph/schema_artifacts/runtime_metadata/graphql_resolver.rb

Defined Under Namespace

Classes: InterfaceWithLookahead, InterfaceWithoutLookahead

Constant Summary collapse

NEEDS_LOOKAHEAD =
"needs_lookahead"
RESOLVER_REF =
"resolver_ref"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_hash(hash) ⇒ Object



32
33
34
35
36
37
# File 'lib/elastic_graph/schema_artifacts/runtime_metadata/graphql_resolver.rb', line 32

def self.from_hash(hash)
  new(
    needs_lookahead: hash.fetch(NEEDS_LOOKAHEAD),
    resolver_ref: hash.fetch(RESOLVER_REF)
  )
end

.with_lookahead_loaderObject



16
17
18
# File 'lib/elastic_graph/schema_artifacts/runtime_metadata/graphql_resolver.rb', line 16

def self.with_lookahead_loader
  @with_lookahead_loader ||= ExtensionLoader.new(InterfaceWithLookahead)
end

.without_lookahead_loaderObject



20
21
22
# File 'lib/elastic_graph/schema_artifacts/runtime_metadata/graphql_resolver.rb', line 20

def self.without_lookahead_loader
  @without_lookahead_loader ||= ExtensionLoader.new(InterfaceWithoutLookahead)
end

Instance Method Details

#load_resolverObject



27
28
29
30
# File 'lib/elastic_graph/schema_artifacts/runtime_metadata/graphql_resolver.rb', line 27

def load_resolver
  loader = needs_lookahead ? GraphQLResolver.with_lookahead_loader : GraphQLResolver.without_lookahead_loader
  Extension.load_from_hash(resolver_ref, via: loader)
end

#to_dumpable_hashObject



39
40
41
42
43
44
45
# File 'lib/elastic_graph/schema_artifacts/runtime_metadata/graphql_resolver.rb', line 39

def to_dumpable_hash
  {
    # Keys here are ordered alphabetically; please keep them that way.
    NEEDS_LOOKAHEAD => needs_lookahead,
    RESOLVER_REF => resolver_ref
  }
end