Class: ElasticGraph::SchemaDefinition::SchemaElements::Relationship
- Inherits:
-
Field
- Object
- Struct
- Field
- ElasticGraph::SchemaDefinition::SchemaElements::Relationship
- Defined in:
- elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/relationship.rb
Overview
Wraps a Field to provide additional relationship-specific functionality when defining a field via TypeWithSubfields#relates_to_one or TypeWithSubfields#relates_to_many.
Constant Summary
Constants included from Mixins::HasTypeInfo
Mixins::HasTypeInfo::CUSTOMIZABLE_DATASTORE_PARAMS
Instance Attribute Summary collapse
-
#related_type ⇒ ObjectType, ...
readonly
The type this relationship relates to.
Attributes inherited from Field
#graphql_only, #name, #name_in_index, #schema_def_state
Attributes included from Mixins::HasDocumentation
Instance Method Summary collapse
-
#additional_filter(filter) ⇒ void
Adds additional filter conditions to a relationship beyond the foreign key.
-
#equivalent_field(path, locally_named: path) ⇒ void
Indicates that
path
(a field on the related type) is the equivalent oflocally_named
on this type.
Methods inherited from Field
#aggregatable?, #argument, #customize_aggregated_values_field, #customize_filter_field, #customize_grouped_by_field, #customize_sort_order_enum_values, #customize_sub_aggregations_field, #filterable?, #groupable?, #json_schema, #mapping_type, #on_each_generated_schema_element, #renamed_from, #sortable?, #sourced_from, #sub_aggregatable?, #type
Methods included from Mixins::HasTypeInfo
#json_schema, #json_schema_options, #mapping, #mapping_options
Methods included from Mixins::HasDirectives
#directive, #directives, #directives_sdl
Methods included from Mixins::HasDocumentation
#append_to_documentation, #derived_documentation, #documentation, #formatted_documentation
Methods included from Mixins::VerifiesGraphQLName
Instance Attribute Details
#related_type ⇒ ObjectType, ... (readonly)
Returns the type this relationship relates to.
43 44 45 |
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/relationship.rb', line 43 def @related_type end |
Instance Method Details
#additional_filter(filter) ⇒ void
This method returns an undefined value.
Adds additional filter conditions to a relationship beyond the foreign key.
81 82 83 84 |
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/relationship.rb', line 81 def additional_filter(filter) stringified_filter = Support::HashUtil.stringify_keys(filter) @additional_filter = Support::HashUtil.deep_merge(@additional_filter, stringified_filter) end |
#equivalent_field(path, locally_named: path) ⇒ void
This method returns an undefined value.
Indicates that path
(a field on the related type) is the equivalent of locally_named
on this type.
Use this API to specify a local field’s equivalent path on the related type. This must be used on relationships used by Field#sourced_from when the local type uses Indexing::Index#route_with or Indexing::Index#rollover so that ElasticGraph can determine what field from the related type to use to route the update requests to the correct index and shard.
125 126 127 128 129 130 131 132 |
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/relationship.rb', line 125 def equivalent_field(path, locally_named: path) if @equivalent_field_paths_by_local_path.key?(locally_named) raise Errors::SchemaError, "`equivalent_field` has been called multiple times on `#{parent_type.name}.#{name}` with the same " \ "`locally_named` value (#{locally_named.inspect}), but each local field can have only one `equivalent_field`." else @equivalent_field_paths_by_local_path[locally_named] = path end end |