Module: ElasticGraph::SchemaArtifacts::RuntimeMetadata

Defined in:
lib/elastic_graph/schema_artifacts/runtime_metadata/enum.rb,
lib/elastic_graph/schema_artifacts/runtime_metadata/params.rb,
lib/elastic_graph/schema_artifacts/runtime_metadata/schema.rb,
lib/elastic_graph/schema_artifacts/runtime_metadata/relation.rb,
lib/elastic_graph/schema_artifacts/runtime_metadata/extension.rb,
lib/elastic_graph/schema_artifacts/runtime_metadata/sort_field.rb,
lib/elastic_graph/schema_artifacts/runtime_metadata/hash_dumper.rb,
lib/elastic_graph/schema_artifacts/runtime_metadata/index_field.rb,
lib/elastic_graph/schema_artifacts/runtime_metadata/object_type.rb,
lib/elastic_graph/schema_artifacts/runtime_metadata/scalar_type.rb,
lib/elastic_graph/schema_artifacts/runtime_metadata/graphql_field.rb,
lib/elastic_graph/schema_artifacts/runtime_metadata/update_target.rb,
lib/elastic_graph/schema_artifacts/runtime_metadata/extension_loader.rb,
lib/elastic_graph/schema_artifacts/runtime_metadata/index_definition.rb,
lib/elastic_graph/schema_artifacts/runtime_metadata/computation_detail.rb,
lib/elastic_graph/schema_artifacts/runtime_metadata/schema_element_names.rb

Defined Under Namespace

Modules: Enum, HashDumper, Param Classes: ComputationDetail, DynamicParam, ExtensionLoader, GraphQLField, IndexDefinition, IndexField, ObjectType, Relation, ScalarCoercionAdapterInterface, ScalarIndexingPreparerInterface, ScalarType, Schema, SchemaElementNamesDefinition, SortField, StaticParam, UpdateTarget

Constant Summary collapse

Extension =

Represents an extension–a class or module (potentially from outside the ElasticGraph code base) that implements a standard interface to plug in custom functionality.

Extensions are serialized using two fields:

  • extension_name: the Ruby constant of the extension

  • require_path: file path to require to load the extension

However, an Extension instance represents a loaded, resolved extension. We eagerly load extensions (and validate them in the ExtensionLoader) in order to surface any issues with the extension as soon as possible. We don’t want to defer errors if we can detect any issues with the extension at boot time.

::Data.define(:extension_class, :require_path, :extension_config) do
  # @implements Extension

  # Loads an extension using a serialized hash, via the provided `ExtensionLoader`.
  def self.load_from_hash(hash, via:)
    config = Support::HashUtil.symbolize_keys(hash["extension_config"] || {}) # : ::Hash[::Symbol, untyped]
    via.load(hash.fetch("extension_name"), from: hash.fetch("require_path"), config: config)
  end

  # The name of the extension (based on the name of the extension class).
  def extension_name
    extension_class.name.to_s
  end

  # The serialized form of an extension.
  def to_dumpable_hash
    # Keys here are ordered alphabetically; please keep them that way.
    {
      "extension_config" => Support::HashUtil.stringify_keys(extension_config),
      "extension_name" => extension_name,
      "require_path" => require_path
    }.reject { |_, v| v.empty? }
  end
end
SchemaElementNames =
SchemaElementNamesDefinition.new(
  # Filter arg and operation names:
  :filter,
  :equal_to_any_of, :gt, :gte, :lt, :lte, :matches, :matches_phrase, :matches_query, :any_of, :all_of, :not,
  :time_of_day, :any_satisfy,
  # Directives
  :eg_latency_slo, :ms,
  # For sorting.
  :order_by,
  # For aggregation
  :grouped_by, :count, :count_detail, :aggregated_values, :sub_aggregations,
  # Date/time grouping aggregation fields
  :as_date_time, :as_date, :as_time_of_day, :as_day_of_week,
  # Date/time grouping aggregation arguments
  :offset, :amount, :unit, :time_zone, :truncation_unit,
  # TODO: Drop support for legacy grouping schema that uses `granularity` and `offset_days`
  :granularity, :offset_days,
  # For aggregation counts.
  :approximate_value, :exact_value, :upper_bound,
  # For pagination.
  :first, :after, :last, :before,
  :edges, :node, :nodes, :cursor,
  :page_info, :start_cursor, :end_cursor, :total_edge_count, :has_previous_page, :has_next_page,
  # Subfields of `GeoLocation`/`GeoLocationFilterInput`:
  :latitude, :longitude, :near, :max_distance,
  # Subfields of `MatchesQueryFilterInput`/`MatchesPhraseFilterInput`
  :query, :phrase, :allowed_edits_per_term, :require_all_terms,
  # Aggregated values field names:
  :exact_min, :exact_max, :approximate_min, :approximate_max, :approximate_avg, :approximate_sum, :exact_sum,
  :approximate_distinct_value_count
)