Class: ElasticGraph::SchemaDefinition::SchemaElements::GraphQLSDLEnumerator

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/elastic_graph/schema_definition/schema_elements/graphql_sdl_enumerator.rb

Overview

Responsible for enumerating the SDL strings for all GraphQL types, both explicitly defined and derived.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema_def_state, all_types_except_root_query_type) ⇒ GraphQLSDLEnumerator

Returns a new instance of GraphQLSDLEnumerator.



20
21
22
23
# File 'lib/elastic_graph/schema_definition/schema_elements/graphql_sdl_enumerator.rb', line 20

def initialize(schema_def_state, all_types_except_root_query_type)
  @schema_def_state = schema_def_state
  @all_types_except_root_query_type = all_types_except_root_query_type
end

Instance Attribute Details

#schema_def_stateObject (readonly)

Returns the value of attribute schema_def_state.



18
19
20
# File 'lib/elastic_graph/schema_definition/schema_elements/graphql_sdl_enumerator.rb', line 18

def schema_def_state
  @schema_def_state
end

Instance Method Details

#each(&block) ⇒ Object

Yields the SDL for each GraphQL type, including both explicitly defined GraphQL types and derived GraphqL types.



27
28
29
30
31
32
33
34
35
# File 'lib/elastic_graph/schema_definition/schema_elements/graphql_sdl_enumerator.rb', line 27

def each(&block)
  all_types = enumerate_all_types.sort_by(&:name)
  all_type_names = all_types.map(&:name).to_set

  all_types.each do |type|
    next if STOCK_GRAPHQL_SCALARS.include?(type.name)
    yield type.to_sdl { |arg| all_type_names.include?(arg.value_type.fully_unwrapped.name) }
  end
end