Module: ElasticGraph::SchemaDefinition::SchemaElements
- Defined in:
- lib/elastic_graph/schema_definition/schema_elements/argument.rb,
lib/elastic_graph/schema_definition/schema_elements/field.rb,
lib/elastic_graph/schema_definition/schema_elements/directive.rb,
lib/elastic_graph/schema_definition/schema_elements/enum_type.rb,
lib/elastic_graph/schema_definition/schema_elements/enum_value.rb,
lib/elastic_graph/schema_definition/schema_elements/field_path.rb,
lib/elastic_graph/schema_definition/schema_elements/input_type.rb,
lib/elastic_graph/schema_definition/schema_elements/type_namer.rb,
lib/elastic_graph/schema_definition/schema_elements/union_type.rb,
lib/elastic_graph/schema_definition/schema_elements/input_field.rb,
lib/elastic_graph/schema_definition/schema_elements/object_type.rb,
lib/elastic_graph/schema_definition/schema_elements/scalar_type.rb,
lib/elastic_graph/schema_definition/schema_elements/field_source.rb,
lib/elastic_graph/schema_definition/schema_elements/relationship.rb,
lib/elastic_graph/schema_definition/schema_elements/built_in_types.rb,
lib/elastic_graph/schema_definition/schema_elements/interface_type.rb,
lib/elastic_graph/schema_definition/schema_elements/type_reference.rb,
lib/elastic_graph/schema_definition/schema_elements/enum_value_namer.rb,
lib/elastic_graph/schema_definition/schema_elements/list_counts_state.rb,
lib/elastic_graph/schema_definition/schema_elements/deprecated_element.rb,
lib/elastic_graph/schema_definition/schema_elements/type_with_subfields.rb,
lib/elastic_graph/schema_definition/schema_elements/sub_aggregation_path.rb,
lib/elastic_graph/schema_definition/schema_elements/sort_order_enum_value.rb,
lib/elastic_graph/schema_definition/schema_elements/graphql_sdl_enumerator.rb,
lib/elastic_graph/schema_definition/schema_elements/enums_for_indexed_types.rb
Overview
Namespace for classes which represent GraphQL schema elements.
Defined Under Namespace
Classes: Argument, BuiltInTypes, Directive, EnumType, EnumValue, EnumValueNamer, EnumsForIndexedTypes, Field, FieldPath, GraphQLSDLEnumerator, InputField, InputType, InterfaceType, ListCountsState, ObjectType, Relationship, ScalarType, SortOrderEnumValue, TypeNamer, TypeReference, TypeWithSubfields, UnionType
Constant Summary collapse
- FieldSource =
::Data.define(:relationship_name, :field_path)
- DeprecatedElement =
::Data.define(:schema_def_state, :name, :defined_at, :defined_via) do # @implements DeprecatedElement def description "`#{defined_via}` at #{defined_at.path}:#{defined_at.lineno}" end end
- SubAggregationPath =
Abstraction responsible for identifying paths to sub-aggregations, and, on that basis, determining what the type names should be.
::Data.define( # List of index document types within which the target type exists. This contains the set of parent # index document types--that is, types which are indexed or are themselves used as a `nested` field # on a parent of it. Parent objects which are not "index documents" (e.g. directly at an index level # or a nested field level) are omitted; we omit them because we don't offer sub-aggregations for such # a field, and the set of sub-aggregations we are going to offer is the basis for generating separate # `*SubAggregation` types. :parent_doc_types, # List of fields forming a path from the last parent doc type. :field_path ) do # @implements SubAggregationPath # Determines the set of sub aggregation paths for the given type. def self.paths_for(type, schema_def_state:) root_paths = type.indexed? ? [SubAggregationPath.new([type.name], [])] : [] # : ::Array[SubAggregationPath] non_relation_field_refs = schema_def_state .user_defined_field_references_by_type_name.fetch(type.name) { [] } # Relationship fields are the only case where types can reference each other in circular fashion. # If we don't reject that case here, we can get stuck in infinite recursion. .reject(&:relationship) root_paths + non_relation_field_refs.flat_map do |field_ref| # Here we call `schema_def_state.sub_aggregation_paths_for` rather than directly # recursing to give schema_def_state a chance to cache the results. parent_paths = schema_def_state.sub_aggregation_paths_for(field_ref.parent_type) if field_ref.nested? parent_paths.map { |path| path.plus_parent(field_ref.type_for_derived_types.fully_unwrapped.name) } else parent_paths.map { |path| path.plus_field(field_ref) } end end end def plus_parent(parent) with(parent_doc_types: parent_doc_types + [parent], field_path: []) end def plus_field(field) with(field_path: field_path + [field]) end def field_path_string field_path.map(&:name).join(".") end end