# ElasticGraph API Documentation ## API Documentation ### API Documentation - Module: ElasticGraph::Apollo::GraphQL Index (G) » ElasticGraph » Apollo » GraphQL Module: ElasticGraph::Apollo::GraphQL elasticgraph-apollo/lib/elastic_graph/apollo/graphql/engine_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/graphql/service_field_resolver.rb, elasticgraph-apollo/lib/elastic_graph/apollo/graphql/entities_field_resolver.rb, elasticgraph-apollo/lib/elastic_graph/apollo/graphql/http_endpoint_extension.rb Note: This module provides no public types or APIs. It will be used automatically when you use SchemaDefinition::APIExtension as a schema definition extension module. Namespace for all Apollo GraphQL enging logic. ### API Documentation - Module: ElasticGraph::Apollo::SchemaDefinition::APIExtension Index (A) » ElasticGraph » Apollo » SchemaDefinition » APIExtension Module: ElasticGraph::Apollo::SchemaDefinition::APIExtension elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/api_extension.rb Module designed to be extended onto an SchemaDefinition::API instance to customize the schema artifacts based on the Apollo Federation subgraph spec. To use this module, pass it in schema_definition_extension_modules when defining your Local::RakeTasks. Examples: Define local rake tasks with this extension module require "elastic_graph/apollo/schema_definition/api_extension" ElasticGraph::Local::RakeTasks.new( local_config_yaml: "config/settings/local.yaml", path_to_schema: "config/schema.rb" ) do |tasks| tasks.schema_definition_extension_modules = [ElasticGraph::Apollo::SchemaDefinition::APIExtension] end Instance Method Summary collapse #tag_built_in_types_with(name, except: []) ⇒ void Applies an apollo tag to built-in types so that they are included in the Apollo contract schema. #target_apollo_federation_version(version) ⇒ void Picks which version of Apollo federation to target. Instance Method Details #tag_built_in_types_with(name, except: []) ⇒ void This method returns an undefined value.Applies an apollo tag to built-in types so that they are included in the Apollo contract schema. Examples: Tag all built-in types (except two) for inclusion in the public schema ElasticGraph.define_schema do |schema| schema.tag_built_in_types_with "public", except: ["IntAggregatedValue", "FloatAggregatedValues"] end Parameters: name (String) — tag name except (Array) (defaults to: []) — built-in types not to tag See Also: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::Tag FieldExtension#tag_with #target_apollo_federation_version(version) ⇒ void This method returns an undefined value.Picks which version of Apollo federation to target. By default, the latest supported version is targeted, but you can call this to pick an earlier version, which may be necessary if your organization is on an older version of Apollo federation. Examples: Set the Apollo Federation Version ElasticGraph.define_schema do |schema| schema.target_apollo_federation_version "2.6" end Parameters: version (String) — version number This method returns an undefined value.Applies an apollo tag to built-in types so that they are included in the Apollo contract schema. This method returns an undefined value.Picks which version of Apollo federation to target. By default, the latest supported version is targeted, but you can call this to pick an earlier version, which may be necessary if your organization is on an older version of Apollo federation. ### API Documentation - Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::Authenticated Index (A) » ElasticGraph » Apollo » SchemaDefinition » ApolloDirectives » Authenticated Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::Authenticated Included in: EnumTypeExtension, FieldExtension, InterfaceTypeExtension, ObjectTypeExtension, ScalarTypeExtension elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/apollo_directives.rb Supports Apollo’s @authenticated directive. Instance Method Summary collapse #apollo_authenticated ⇒ void Adds the @authenticated directive to the schema element. Instance Method Details #apollo_authenticated ⇒ void This method returns an undefined value.Adds the @authenticated directive to the schema element. Examples: Add @authenticated to a type ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.apollo_authenticated end end This method returns an undefined value.Adds the @authenticated directive to the schema element. ### API Documentation - Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::Extends Index (E) » ElasticGraph » Apollo » SchemaDefinition » ApolloDirectives » Extends Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::Extends Included in: InterfaceTypeExtension, ObjectTypeExtension elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/apollo_directives.rb Supports Apollo’s @extends directive. Instance Method Summary collapse #apollo_extends ⇒ void Adds the @extends directive to the schema element. Instance Method Details #apollo_extends ⇒ void This method returns an undefined value.Adds the @extends directive to the schema element. Examples: Add @extends to a type ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.apollo_extends end end This method returns an undefined value.Adds the @extends directive to the schema element. ### API Documentation - Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::External Index (E) » ElasticGraph » Apollo » SchemaDefinition » ApolloDirectives » External Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::External Included in: FieldExtension, ObjectTypeExtension elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/apollo_directives.rb Supports Apollo’s @external directive. Instance Method Summary collapse #apollo_external ⇒ void Adds the @external directive to the schema element. Instance Method Details #apollo_external ⇒ void This method returns an undefined value.Adds the @external directive to the schema element. Examples: Add @external to a type ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.apollo_external end end This method returns an undefined value.Adds the @external directive to the schema element. ### API Documentation - Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::Inaccessible Index (I) » ElasticGraph » Apollo » SchemaDefinition » ApolloDirectives » Inaccessible Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::Inaccessible Included in: ElasticGraph::Apollo::SchemaDefinition::ArgumentExtension, EnumTypeExtension, EnumValueExtension, FieldExtension, InputTypeExtension, InterfaceTypeExtension, ObjectTypeExtension, ScalarTypeExtension, UnionTypeExtension elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/apollo_directives.rb Supports Apollo’s @inaccessible directive. Instance Method Summary collapse #apollo_inaccessible ⇒ void Adds the @inaccessible directive to the schema element. Instance Method Details #apollo_inaccessible ⇒ void This method returns an undefined value.Adds the @inaccessible directive to the schema element. Examples: Add @inaccessible to a type ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.apollo_inaccessible end end This method returns an undefined value.Adds the @inaccessible directive to the schema element. ### API Documentation - Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::InterfaceObject Index (I) » ElasticGraph » Apollo » SchemaDefinition » ApolloDirectives » InterfaceObject Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::InterfaceObject Included in: ObjectTypeExtension elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/apollo_directives.rb Supports Apollo’s @interfaceObject directive. Instance Method Summary collapse #apollo_interface_object ⇒ void Adds the @interfaceObject directive to the schema element. Instance Method Details #apollo_interface_object ⇒ void This method returns an undefined value.Adds the @interfaceObject directive to the schema element. Examples: Add @interfaceObject to a type ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.apollo_interface_object end end This method returns an undefined value.Adds the @interfaceObject directive to the schema element. ### API Documentation - Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::Key Index (K) » ElasticGraph » Apollo » SchemaDefinition » ApolloDirectives » Key Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::Key Included in: InterfaceTypeExtension, ObjectTypeExtension elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/apollo_directives.rb Supports Apollo’s @key directive. Instance Method Summary collapse #apollo_key(fields:, resolvable: true) ⇒ void Adds the @key directive to the schema element. Instance Method Details #apollo_key(fields:, resolvable: true) ⇒ void Note: ElasticGraph automatically defines an apollo_key of id for every indexed type. This API is only needed when defining additional keys on an indexed type, or defining a key for a non-indexed type. This method returns an undefined value.Adds the @key directive to the schema element. Examples: Define a @key on a non-indexed type ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.field "organizationId", "ID" t.field "id", "ID" t.apollo_key fields: "id organizationId", resolvable: false end end Parameters: fields (String) — A GraphQL selection set (provided as a string) of fields and subfields that contribute to the entity’s unique key. resolvable (Boolean) (defaults to: true) — If false, indicates to the Apollo router that this subgraph doesn’t define a reference resolver for this entity. This means that router query plans can’t “jump to” this subgraph to resolve fields that aren’t defined in another subgraph. Note: ElasticGraph automatically defines an apollo_key of id for every indexed type. This API is only needed when defining additional keys on an indexed type, or defining a key for a non-indexed type. This method returns an undefined value.Adds the @key directive to the schema element. ### API Documentation - Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::Override Index (O) » ElasticGraph » Apollo » SchemaDefinition » ApolloDirectives » Override Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::Override Included in: FieldExtension elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/apollo_directives.rb Supports Apollo’s @override directive. Instance Method Summary collapse #apollo_override(from:) ⇒ void Adds the @override directive to the schema element. Instance Method Details #apollo_override(from:) ⇒ void This method returns an undefined value.Adds the @override directive to the schema element. Examples: Add @override to a field ElasticGraph.define_schema do |schema| schema.object_type "Product" do |t| t.field "inStock", "Boolean" do |f| f.apollo_override from: "Products" end end end Parameters: from (String) — The name of the other subgraph that no longer resolves the field. This method returns an undefined value.Adds the @override directive to the schema element. ### API Documentation - Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::Policy Index (P) » ElasticGraph » Apollo » SchemaDefinition » ApolloDirectives » Policy Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::Policy Included in: EnumTypeExtension, FieldExtension, InterfaceTypeExtension, ObjectTypeExtension, ScalarTypeExtension elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/apollo_directives.rb Supports Apollo’s @policy directive. Instance Method Summary collapse #apollo_policy(policies:) ⇒ void Adds the @policy directive to the schema element. Instance Method Details #apollo_policy(policies:) ⇒ void This method returns an undefined value.Adds the @policy directive to the schema element. Examples: Add @policy to a type ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.apollo_policy policies: ["Policy1", "Policy2"] end end Parameters: policies (Array) — List of authorization policies. This method returns an undefined value.Adds the @policy directive to the schema element. ### API Documentation - Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::Provides Index (P) » ElasticGraph » Apollo » SchemaDefinition » ApolloDirectives » Provides Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::Provides Included in: FieldExtension elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/apollo_directives.rb Supports Apollo’s @provides directive. Instance Method Summary collapse #apollo_provides(fields:) ⇒ void Adds the @provides directive to the schema element. Instance Method Details #apollo_provides(fields:) ⇒ void This method returns an undefined value.Adds the @provides directive to the schema element. Examples: Add @provides to a field ElasticGraph.define_schema do |schema| schema.object_type "Product" do |t| t.field "name", "String" end schema.object_type "StoreLocation" do |t| t.field "products", "[Product!]!" do |f| f.mapping type: "nested" f.apollo_provides fields: "name" end end end Parameters: fields (String) — A GraphQL selection set (provided as a string) of object fields and subfields that the subgraph can resolve only at this query path. This method returns an undefined value.Adds the @provides directive to the schema element. ### API Documentation - Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::Requires Index (R) » ElasticGraph » Apollo » SchemaDefinition » ApolloDirectives » Requires Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::Requires Included in: FieldExtension elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/apollo_directives.rb Supports Apollo’s @requires directive. Instance Method Summary collapse #apollo_requires(fields:) ⇒ void Adds the @requires directive to the schema element. Instance Method Details #apollo_requires(fields:) ⇒ void This method returns an undefined value.Adds the @requires directive to the schema element. Examples: Add @requires to a field ElasticGraph.define_schema do |schema| schema.object_type "Product" do |t| t.field "size", "Int" t.field "weight", "Int" t.field "shippingEstimate", "String" do |f| f.apollo_requires fields: "size weight" end end end Parameters: fields (String) — A GraphQL selection set (provided as a string) of object fields and subfields that the subgraph can resolve only at this query path. This method returns an undefined value.Adds the @requires directive to the schema element. ### API Documentation - Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::RequiresScopes Index (R) » ElasticGraph » Apollo » SchemaDefinition » ApolloDirectives » RequiresScopes Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::RequiresScopes Included in: EnumTypeExtension, FieldExtension, InterfaceTypeExtension, ObjectTypeExtension, ScalarTypeExtension elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/apollo_directives.rb Supports Apollo’s @requiresScopes directive. Instance Method Summary collapse #apollo_requires_scopes(scopes:) ⇒ void Adds the @requiresScopes directive to the schema element. Instance Method Details #apollo_requires_scopes(scopes:) ⇒ void This method returns an undefined value.Adds the @requiresScopes directive to the schema element. Examples: Add @requiresScopes to a field ElasticGraph.define_schema do |schema| schema.object_type "Product" do |t| t.field "shippingEstimate", "String" do |f| f.apollo_requires_scopes scopes: "shipping" end end end Parameters: scopes (Array) — List of JWT scopes that must be granted to the user in order to access the underlying element data. This method returns an undefined value.Adds the @requiresScopes directive to the schema element. ### API Documentation - Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::Shareable Index (S) » ElasticGraph » Apollo » SchemaDefinition » ApolloDirectives » Shareable Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::Shareable Included in: FieldExtension, ObjectTypeExtension elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/apollo_directives.rb Supports Apollo’s @shareable directive. Instance Method Summary collapse #apollo_shareable ⇒ void Adds the @shareable directive to the schema element. Instance Method Details #apollo_shareable ⇒ void This method returns an undefined value.Adds the @shareable directive to the schema element. Examples: Add @shareable to a type ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.apollo_shareable end end This method returns an undefined value.Adds the @shareable directive to the schema element. ### API Documentation - Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::Tag Index (T) » ElasticGraph » Apollo » SchemaDefinition » ApolloDirectives » Tag Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::Tag Included in: ElasticGraph::Apollo::SchemaDefinition::ArgumentExtension, EnumTypeExtension, EnumValueExtension, FieldExtension, InputTypeExtension, InterfaceTypeExtension, ObjectTypeExtension, ScalarTypeExtension, UnionTypeExtension elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/apollo_directives.rb Supports Apollo’s @tag directive. Instance Method Summary collapse #apollo_tag(name:) ⇒ void Adds the @tag directive to the schema element. Instance Method Details #apollo_tag(name:) ⇒ void This method returns an undefined value.Adds the @tag directive to the schema element. Examples: Add @tag to a type ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.apollo_tag name: "public" end end See Also: ElasticGraph::Apollo::SchemaDefinition::APIExtension#tag_built_in_types_with FieldExtension#tag_with This method returns an undefined value.Adds the @tag directive to the schema element. ### API Documentation - Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives Index (A) » ElasticGraph » Apollo » SchemaDefinition » ApolloDirectives Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/apollo_directives.rb Namespace for mixins that provide support for Apollo’s federation directives. Each Apollo federation directive is offered via an API starting with apollo. For example, apollo_key can be used to define an Apollo @key. Defined Under Namespace Modules: Authenticated, Extends, External, Inaccessible, InterfaceObject, Key, Override, Policy, Provides, Requires, RequiresScopes, Shareable, Tag ### API Documentation - Module: ElasticGraph::Apollo::SchemaDefinition::ArgumentExtension Index (A) » ElasticGraph » Apollo » SchemaDefinition » ArgumentExtension Module: ElasticGraph::Apollo::SchemaDefinition::ArgumentExtension Includes: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::Inaccessible, ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::Tag elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/argument_extension.rb Extends SchemaDefinition::SchemaElements::Argument to offer Apollo argument directives. Method Summary Methods included from ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::Tag #apollo_tag Methods included from ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::Inaccessible #apollo_inaccessible ### API Documentation - Module: ElasticGraph::Apollo::SchemaDefinition::EnumTypeExtension Index (E) » ElasticGraph » Apollo » SchemaDefinition » EnumTypeExtension Module: ElasticGraph::Apollo::SchemaDefinition::EnumTypeExtension Includes: ApolloDirectives::Authenticated, ApolloDirectives::Inaccessible, ApolloDirectives::Policy, ApolloDirectives::RequiresScopes, ApolloDirectives::Tag elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/enum_type_extension.rb Extends SchemaDefinition::SchemaElements::EnumType to offer Apollo enum type directives. Method Summary Methods included from ApolloDirectives::Tag #apollo_tag Methods included from ApolloDirectives::RequiresScopes #apollo_requires_scopes Methods included from ApolloDirectives::Policy #apollo_policy Methods included from ApolloDirectives::Inaccessible #apollo_inaccessible Methods included from ApolloDirectives::Authenticated #apollo_authenticated ### API Documentation - Module: ElasticGraph::Apollo::SchemaDefinition::EnumValueExtension Index (E) » ElasticGraph » Apollo » SchemaDefinition » EnumValueExtension Module: ElasticGraph::Apollo::SchemaDefinition::EnumValueExtension Includes: ApolloDirectives::Inaccessible, ApolloDirectives::Tag elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/enum_value_extension.rb Extends SchemaDefinition::SchemaElements::EnumValue to offer Apollo enum value directives. Method Summary Methods included from ApolloDirectives::Tag #apollo_tag Methods included from ApolloDirectives::Inaccessible #apollo_inaccessible ### API Documentation - Module: ElasticGraph::Apollo::SchemaDefinition::FieldExtension Index (F) » ElasticGraph » Apollo » SchemaDefinition » FieldExtension Module: ElasticGraph::Apollo::SchemaDefinition::FieldExtension Includes: ApolloDirectives::Authenticated, ApolloDirectives::External, ApolloDirectives::Inaccessible, ApolloDirectives::Override, ApolloDirectives::Policy, ApolloDirectives::Provides, ApolloDirectives::Requires, ApolloDirectives::RequiresScopes, ApolloDirectives::Shareable, ApolloDirectives::Tag elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/field_extension.rb Extends SchemaDefinition::SchemaElements::Field to offer Apollo field directives. Class Method Summary collapse .tagged_with?(element, tag_name) ⇒ Boolean Helper method that indicates if the given schema element has a specific tag. Instance Method Summary collapse #tag_with(tag_name) ⇒ void Extension method designed to support Apollo’s contract variant tagging. Methods included from ApolloDirectives::Tag #apollo_tag Methods included from ApolloDirectives::Shareable #apollo_shareable Methods included from ApolloDirectives::RequiresScopes #apollo_requires_scopes Methods included from ApolloDirectives::Requires #apollo_requires Methods included from ApolloDirectives::Provides #apollo_provides Methods included from ApolloDirectives::Policy #apollo_policy Methods included from ApolloDirectives::Override #apollo_override Methods included from ApolloDirectives::Inaccessible #apollo_inaccessible Methods included from ApolloDirectives::External #apollo_external Methods included from ApolloDirectives::Authenticated #apollo_authenticated Class Method Details .tagged_with?(element, tag_name) ⇒ Boolean Helper method that indicates if the given schema element has a specific tag. Parameters: element (Object) — element to check tag_name (String) — tag to check (Boolean) Instance Method Details #tag_with(tag_name) ⇒ void This method returns an undefined value.Extension method designed to support Apollo’s contract variant tagging. Calling this method on a field will cause the field and every schema element derived from the field (e.g. the filter field, he aggregation field, etc), to be tagged with the given tag_name, ensuring that all capabilities related to the field are available in the contract variant. Examples: Tag a field (and its derived elements) with “public” ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.field "name", "String" do |f| f.tag_with "public" end end end Parameters: tag_name (String) — tag to add to schema elements generated for this field See Also: ApolloDirectives::Tag APIExtension#tag_built_in_types_with Helper method that indicates if the given schema element has a specific tag. This method returns an undefined value.Extension method designed to support Apollo’s contract variant tagging. Calling this method on a field will cause the field and every schema element derived from the field (e.g. the filter field, he aggregation field, etc), to be tagged with the given tag_name, ensuring that all capabilities related to the field are available in the contract variant. ### API Documentation - Module: ElasticGraph::Apollo::SchemaDefinition::InputTypeExtension Index (I) » ElasticGraph » Apollo » SchemaDefinition » InputTypeExtension Module: ElasticGraph::Apollo::SchemaDefinition::InputTypeExtension Includes: ApolloDirectives::Inaccessible, ApolloDirectives::Tag elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/input_type_extension.rb Extends SchemaDefinition::SchemaElements::InputType to offer Apollo input type directives. Method Summary Methods included from ApolloDirectives::Tag #apollo_tag Methods included from ApolloDirectives::Inaccessible #apollo_inaccessible ### API Documentation - Module: ElasticGraph::Apollo::SchemaDefinition::InterfaceTypeExtension Index (I) » ElasticGraph » Apollo » SchemaDefinition » InterfaceTypeExtension Module: ElasticGraph::Apollo::SchemaDefinition::InterfaceTypeExtension Includes: ApolloDirectives::Authenticated, ApolloDirectives::Extends, ApolloDirectives::Inaccessible, ApolloDirectives::Key, ApolloDirectives::Policy, ApolloDirectives::RequiresScopes, ApolloDirectives::Tag elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/interface_type_extension.rb Extends SchemaDefinition::SchemaElements::InterfaceType to offer Apollo interface type directives. Method Summary Methods included from ApolloDirectives::Tag #apollo_tag Methods included from ApolloDirectives::RequiresScopes #apollo_requires_scopes Methods included from ApolloDirectives::Policy #apollo_policy Methods included from ApolloDirectives::Key #apollo_key Methods included from ApolloDirectives::Inaccessible #apollo_inaccessible Methods included from ApolloDirectives::Extends #apollo_extends Methods included from ApolloDirectives::Authenticated #apollo_authenticated ### API Documentation - Module: ElasticGraph::Apollo::SchemaDefinition::ObjectTypeExtension Index (O) » ElasticGraph » Apollo » SchemaDefinition » ObjectTypeExtension Module: ElasticGraph::Apollo::SchemaDefinition::ObjectTypeExtension Includes: ApolloDirectives::Authenticated, ApolloDirectives::Extends, ApolloDirectives::External, ApolloDirectives::Inaccessible, ApolloDirectives::InterfaceObject, ApolloDirectives::Key, ApolloDirectives::Policy, ApolloDirectives::RequiresScopes, ApolloDirectives::Shareable, ApolloDirectives::Tag elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/object_type_extension.rb Extends SchemaDefinition::SchemaElements::ObjectType to offer Apollo object type directives. Method Summary Methods included from ApolloDirectives::Tag #apollo_tag Methods included from ApolloDirectives::Shareable #apollo_shareable Methods included from ApolloDirectives::RequiresScopes #apollo_requires_scopes Methods included from ApolloDirectives::Policy #apollo_policy Methods included from ApolloDirectives::Key #apollo_key Methods included from ApolloDirectives::InterfaceObject #apollo_interface_object Methods included from ApolloDirectives::Inaccessible #apollo_inaccessible Methods included from ApolloDirectives::External #apollo_external Methods included from ApolloDirectives::Extends #apollo_extends Methods included from ApolloDirectives::Authenticated #apollo_authenticated ### API Documentation - Module: ElasticGraph::Apollo::SchemaDefinition::ScalarTypeExtension Index (S) » ElasticGraph » Apollo » SchemaDefinition » ScalarTypeExtension Module: ElasticGraph::Apollo::SchemaDefinition::ScalarTypeExtension Includes: ApolloDirectives::Authenticated, ApolloDirectives::Inaccessible, ApolloDirectives::Policy, ApolloDirectives::RequiresScopes, ApolloDirectives::Tag elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/scalar_type_extension.rb Extends SchemaDefinition::SchemaElements::ScalarType to offer Apollo scalar type directives. Method Summary Methods included from ApolloDirectives::Tag #apollo_tag Methods included from ApolloDirectives::RequiresScopes #apollo_requires_scopes Methods included from ApolloDirectives::Policy #apollo_policy Methods included from ApolloDirectives::Inaccessible #apollo_inaccessible Methods included from ApolloDirectives::Authenticated #apollo_authenticated ### API Documentation - Module: ElasticGraph::Apollo::SchemaDefinition::UnionTypeExtension Index (U) » ElasticGraph » Apollo » SchemaDefinition » UnionTypeExtension Module: ElasticGraph::Apollo::SchemaDefinition::UnionTypeExtension Includes: ApolloDirectives::Inaccessible, ApolloDirectives::Tag elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/union_type_extension.rb Extends SchemaDefinition::SchemaElements::UnionType to offer Apollo union type directives. Method Summary Methods included from ApolloDirectives::Tag #apollo_tag Methods included from ApolloDirectives::Inaccessible #apollo_inaccessible ### API Documentation - Module: ElasticGraph::Apollo::SchemaDefinition Index (S) » ElasticGraph » Apollo » SchemaDefinition Module: ElasticGraph::Apollo::SchemaDefinition elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/api_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/field_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/state_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/apollo_directives.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/factory_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/argument_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/enum_type_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/enum_value_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/input_type_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/union_type_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/entity_type_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/object_type_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/scalar_type_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/interface_type_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/graphql_sdl_enumerator_extension.rb Namespace for all Apollo schema definition support. APIExtension is the primary entry point and should be used as a schema definition extension module. Defined Under Namespace Modules: APIExtension, ApolloDirectives, ArgumentExtension, EnumTypeExtension, EnumValueExtension, FieldExtension, InputTypeExtension, InterfaceTypeExtension, ObjectTypeExtension, ScalarTypeExtension, UnionTypeExtension ### API Documentation - Module: ElasticGraph::Apollo Index (A) » ElasticGraph » Apollo Module: ElasticGraph::Apollo elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/api_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/graphql/engine_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/graphql/service_field_resolver.rb, elasticgraph-apollo/lib/elastic_graph/apollo/graphql/entities_field_resolver.rb, elasticgraph-apollo/lib/elastic_graph/apollo/graphql/http_endpoint_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/field_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/state_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/apollo_directives.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/factory_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/argument_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/enum_type_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/enum_value_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/input_type_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/union_type_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/entity_type_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/object_type_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/scalar_type_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/interface_type_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/graphql_sdl_enumerator_extension.rb ElasticGraph extension library that implements the Apollo subgraph federation spec, turning any ElasticGraph instance into an Apollo subgraph. ElasticGraph::Apollo has two parts: SchemaDefinition is an extension used while defining an ElasticGraph schema. It includes all schema elements that are part of the Apollo spec, including _Entity and the various directives. GraphQL is an extension used by elasticgraph-graphql to support queries against Apollo’s subgraph schema additions (e.g. _service and _entities). It includes reference resolvers for all indexed types in your schema. To use elasticgraph-apollo, simply use SchemaDefinition::APIExtension as a schema definition extension module. The GraphQL extension module will get used by elasticgraph-graphql automatically. Examples: Use elasticgraph-apollo in a project require "elastic_graph/apollo/schema_definition/api_extension" ElasticGraph::Local::RakeTasks.new( local_config_yaml: "config/settings/local.yaml", path_to_schema: "config/schema.rb" ) do |tasks| tasks.schema_definition_extension_modules = [ElasticGraph::Apollo::SchemaDefinition::APIExtension] end Defined Under Namespace Modules: GraphQL, SchemaDefinition ### API Documentation - Module: ElasticGraph::JSONSchema::MetaSchemaLoader Index (M) » ElasticGraph » JSONSchema » MetaSchemaLoader Module: ElasticGraph::JSONSchema::MetaSchemaLoader elasticgraph-json_schema/lib/elastic_graph/json_schema/meta_schema_validator.rb Responsible for building Validators that can validate JSON schema definitions. Class Method Summary collapse .load_strict_validator(overrides = {}) ⇒ Object Builds a validator to validate a JSON schema definition according to the JSON schema meta schema. Class Method Details .load_strict_validator(overrides = {}) ⇒ Object Builds a validator to validate a JSON schema definition according to the JSON schema meta schema. Parameters: overrides (Hash) (defaults to: {}) — meta schema overrides Builds a validator to validate a JSON schema definition according to the JSON schema meta schema. ### API Documentation - Class: ElasticGraph::JSONSchema::Validator Index (V) » ElasticGraph » JSONSchema » Validator Class: ElasticGraph::JSONSchema::Validator Inherits: Object Object ElasticGraph::JSONSchema::Validator show all elasticgraph-json_schema/lib/elastic_graph/json_schema/validator.rb Responsible for validating JSON data against the ElasticGraph JSON schema for a particular type. Instance Attribute Summary collapse #sanitize_pii ⇒ Boolean readonly Whether to omit data that may contain PII from error messages. #schema ⇒ Hash readonly A JSON schema. Instance Method Summary collapse #valid?(data) ⇒ Boolean Validates the given data against the JSON schema, returning true if the data is valid. #validate(data) ⇒ Array> Validates the given data against the JSON schema, returning an array of error objects for any validation errors. #validate_with_error_message(data) ⇒ nil, String Validates the given data against the JSON schema, returning an error message string if it is invalid. Instance Attribute Details #sanitize_pii ⇒ Boolean (readonly) Returns whether to omit data that may contain PII from error messages. (Boolean) — whether to omit data that may contain PII from error messages #schema ⇒ Hash (readonly) Returns a JSON schema. (Hash) — a JSON schema Instance Method Details #valid?(data) ⇒ Boolean Validates the given data against the JSON schema, returning true if the data is valid. Parameters: data (Object) — JSON data to validate (Boolean) — true if the data is valid; false if it is invalid See Also: #validate #validate_with_error_message #validate(data) ⇒ Array> Validates the given data against the JSON schema, returning an array of error objects for any validation errors. Parameters: data (Object) — JSON data to validate (Array>) — validation errors; will be empty if data is valid See Also: #valid? #validate_with_error_message #validate_with_error_message(data) ⇒ nil, String Note: The returned error message may contain PII unless #sanitize_pii has not been set. Validates the given data against the JSON schema, returning an error message string if it is invalid. The error message is intended to be usable to include in a log message or a raised error. Parameters: data (Object) — JSON data to validate (nil, String) — a validation error message, if the data is invalid See Also: #valid? #validate Returns whether to omit data that may contain PII from error messages. Returns a JSON schema. Validates the given data against the JSON schema, returning true if the data is valid. Validates the given data against the JSON schema, returning an array of error objects for any validation errors. Note: The returned error message may contain PII unless #sanitize_pii has not been set. Validates the given data against the JSON schema, returning an error message string if it is invalid. The error message is intended to be usable to include in a log message or a raised error. ### API Documentation - Class: ElasticGraph::JSONSchema::ValidatorFactory Index (V) » ElasticGraph » JSONSchema » ValidatorFactory Class: ElasticGraph::JSONSchema::ValidatorFactory Inherits: Object Object ElasticGraph::JSONSchema::ValidatorFactory show all elasticgraph-json_schema/lib/elastic_graph/json_schema/validator_factory.rb Factory class responsible for creating Validators for particular ElasticGraph types. Instance Method Summary collapse #initialize(schema:, sanitize_pii:) ⇒ ValidatorFactory constructor A new instance of ValidatorFactory. #validator_for(type_name) ⇒ Validator Gets the Validator for a particular ElasticGraph type. #with_unknown_properties_disallowed(except: []) ⇒ ValidatorFactory Returns a new factory configured to disallow unknown properties. Constructor Details #initialize(schema:, sanitize_pii:) ⇒ ValidatorFactory Returns a new instance of ValidatorFactory. Parameters: schema (Hash) — the JSON schema for an entire ElasticGraph schema sanitize_pii (Boolean) — whether to omit data that may contain PII from error messages Instance Method Details #validator_for(type_name) ⇒ Validator Gets the ElasticGraph::JSONSchema::Validator for a particular ElasticGraph type. Parameters: type_name (String) — name of an ElasticGraph type (Validator) #with_unknown_properties_disallowed(except: []) ⇒ ValidatorFactory Returns a new factory configured to disallow unknown properties. By default, JSON schema allows unknown properties (they’ll simply be ignored when validating a JSON document). It can be useful to validate more strictly, so that a document with properties not defined in the JSON schema gets validation errors. Parameters: except (Array) (defaults to: []) — paths under which unknown properties should still be allowed (ValidatorFactory) Returns a new instance of ValidatorFactory. Gets the ElasticGraph::JSONSchema::Validator for a particular ElasticGraph type. Returns a new factory configured to disallow unknown properties. By default, JSON schema allows unknown properties (they’ll simply be ignored when validating a JSON document). It can be useful to validate more strictly, so that a document with properties not defined in the JSON schema gets validation errors. ### API Documentation - Module: ElasticGraph::JSONSchema Index (J) » ElasticGraph » JSONSchema Module: ElasticGraph::JSONSchema elasticgraph-json_schema/lib/elastic_graph/json_schema/meta_schema_validator.rb, elasticgraph-json_schema/lib/elastic_graph/json_schema/validator.rb, elasticgraph-json_schema/lib/elastic_graph/json_schema/validator_factory.rb Provides JSON Schema validation for ElasticGraph. Defined Under Namespace Modules: MetaSchemaLoader Classes: Validator, ValidatorFactory Class Method Summary collapse .elastic_graph_internal_meta_schema_validator ⇒ Validator Provides a validator to validate a JSON schema definition according to the JSON schema meta schema. .strict_meta_schema_validator ⇒ Validator Provides a validator to validate a JSON schema definitions according to the JSON schema meta schema. Class Method Details .elastic_graph_internal_meta_schema_validator ⇒ Validator Provides a validator to validate a JSON schema definition according to the JSON schema meta schema. The validator is configured to validate strictly, so that non-standard JSON schema properties are disallowed, except for internal ElasticGraph metadata properties. (Validator) See Also: strict_meta_schema_validator .strict_meta_schema_validator ⇒ Validator Provides a validator to validate a JSON schema definitions according to the JSON schema meta schema. The validator is configured to validate strictly, so that non-standard JSON schema properties are disallowed. (Validator) See Also: elastic_graph_internal_meta_schema_validator Provides a validator to validate a JSON schema definition according to the JSON schema meta schema. The validator is configured to validate strictly, so that non-standard JSON schema properties are disallowed, except for internal ElasticGraph metadata properties. Provides a validator to validate a JSON schema definitions according to the JSON schema meta schema. The validator is configured to validate strictly, so that non-standard JSON schema properties are disallowed. ### API Documentation - Class: ElasticGraph::Local::RakeTasks Index (R) » ElasticGraph » Local » RakeTasks Class: ElasticGraph::Local::RakeTasks Inherits: Rake::TaskLib Object Rake::TaskLib ElasticGraph::Local::RakeTasks show all elasticgraph-local/lib/elastic_graph/local/rake_tasks.rb Note: All tasks (besides the schema_artifacts tasks) require docker and docker-compose to be available on your machine. Defines tasks for local development. These tasks include: Running OpenSearch and/or Elasticsearch locally ((elasticsearch|opensearch):[env]:(boot|daemon|halt)) Managing schema artifacts (schema_artifacts:(check|dump)) Configuring OpenSearch/Elasticsearch locally (clusters:configure:(dry_run|perform)) Indexing fake data (index_fake_data:[type]) Booting an ElasticGraph application locally (boot_locally) Constant Summary collapse UI_PORT_OFFSET = Offset we add to a port number for the UI (e.g. Kibana or OpenSearch Dashboards). Example: if Elasticsearch/OpenSearch is running on port 9876, the UI for it will run on port 19876. 10_000 Instance Attribute Summary collapse #daemon_timeout ⇒ Integer Maximum time (in seconds) to wait for the datastore to boot when booting it as a daemon. #derived_type_name_formats ⇒ Object Overrides for the naming formats used by ElasticGraph for derived GraphQL type names. #elasticsearch_versions ⇒ Array List of Elasticsearch versions you want to be able to boot. #enforce_json_schema_version ⇒ Boolean Whether or not to enforce the requirement that the JSON schema version is incremented every time dumping the JSON schemas results in a changed artifact. #enum_value_overrides_by_type ⇒ Hash> Overrides for the names of specific GraphQL enum values for specific enum types. #env_port_mapping ⇒ Hash Hash mapping environments (e.g. :test, :dev, etc) to port numbers for use when booting Elasticsearch or OpenSearch. #index_document_sizes ⇒ Boolean When enabled, ElasticGraph will configure the index mappings so that the datastore indexes a _size field in each index document. #opensearch_versions ⇒ Array List of OpenSearch versions you want to be able to boot. #output ⇒ IO IO for printing output (defaults to stdout). #schema_definition_extension_modules ⇒ Array List of Ruby modules to extend onto the SchemaDefinition::API instance. #schema_element_name_form ⇒ :camelCase, :snake_case The form of names for schema elements (fields, arguments, directives) generated by ElasticGraph, either :snake_case or :camelCase. #schema_element_name_overrides ⇒ Hash Overrides for specific names of schema elements (fields, arguments, directives) generated by ElasticGraph. #type_name_overrides ⇒ Hash Overrides for the names of specific GraphQL types. Instance Method Summary collapse #define_fake_data_batch_for(type) {|Array>, Array>| ... } ⇒ Object Register a callback for use when indexing a batch fake data. #initialize(local_config_yaml:, path_to_schema:) {|RakeTasks| ... } ⇒ RakeTasks constructor A new instance of RakeTasks. Constructor Details #initialize(local_config_yaml:, path_to_schema:) {|RakeTasks| ... } ⇒ RakeTasks Note: This method uses keyword args for all required arguments. Optional task settings are instead specified using the block. Returns a new instance of RakeTasks. Parameters: local_config_yaml (String, Pathname) — path to the settings YAML file for the local/development environment path_to_schema (String, Pathname) — path to the Ruby schema definition file–either the only file that defines the schema (using ElasticGraph.define_schema) or the “main” schema definition file, which loads other files which further define parts of the schema. Yields: (RakeTasks) — instance for further configuration Yield (void) Instance Attribute Details #daemon_timeout ⇒ Integer Maximum time (in seconds) to wait for the datastore to boot when booting it as a daemon. Defaults to 120. (Integer) — maximum time in seconds to wait when booting Elasticsearch/OpenSearch as a daemon #derived_type_name_formats ⇒ Object Overrides for the naming formats used by ElasticGraph for derived GraphQL type names. For example, to use Metrics instead of AggregatedValues as the suffix for the generated types supporting getting aggregated metrid values, set to {AggregatedValues: "%{base}Metrics"}. See SchemaDefinition::SchemaElements::TypeNamer::DEFAULT_FORMATS for the available formats. Defaults to an empty hash. Examples: Change the AggregatedValues type suffix to Metrics ElasticGraph::Local::RakeTasks.new( local_config_yaml: "config/settings/local.yaml", path_to_schema: "config/schema.rb" ) do |tasks| tasks.derived_type_name_formats = {AggregatedValues: "%{base}Metrics"} end #elasticsearch_versions ⇒ Array List of Elasticsearch versions you want to be able to boot. Rake tasks will be defined for each version to support booting and halting Elasticsearch locally. If the configuration of local_config_yaml only configures opensearch as a cluster backend, will default to an empty array. Otherwise, defaults to the versions of Elasticsearch that are exercised by the ElasticGraph test suite, as defined by lib/elastic_graph/local/tested_datastore_versions.yaml: # This file determines the versions the ElasticGraph CI build tests against, and is also# used to provide the default versions offered by the `elasticgraph-local` rake tasks.elasticsearch:- 8.16.1 # latest version as of 2024-12-08.opensearch:- 2.18.0 # latest version as of 2024-12-08.- 2.7.0 # lowest version ElasticGraph currently supports Examples: Configure the Elasticsearch versions available to boot locally ElasticGraph::Local::RakeTasks.new( local_config_yaml: "config/settings/local.yaml", path_to_schema: "config/schema.rb" ) do |tasks| tasks.elasticsearch_versions = ["8.16.1"] end (Array) — list of Elasticsearch versions See Also: #opensearch_versions #enforce_json_schema_version ⇒ Boolean Note: Generally speaking, you will want this to be true for any ElasticGraph application that is in production as the versioning of JSON schemas is what supports safe schema evolution as it allows ElasticGraph to identify which version of the JSON schema the publishing system was operating on when it published an event. It can be useful to set it to false before your application is in production, as you do not want to be forced to bump the version after every single schema change while you are building an initial prototype. Whether or not to enforce the requirement that the JSON schema version is incremented every time dumping the JSON schemas results in a changed artifact. Defaults to true. Examples: Disable enforcement during initial prototyping ElasticGraph::Local::RakeTasks.new( local_config_yaml: "config/settings/local.yaml", path_to_schema: "config/schema.rb" ) do |tasks| # TODO: remove this once we're past the prototyping stage tasks.enforce_json_schema_version = false end (Boolean) — whether to require json_schema_version to be incremented on changes that impact json_schemas.yaml See Also: SchemaDefinition::API#json_schema_version #enum_value_overrides_by_type ⇒ Hash> Overrides for the names of specific GraphQL enum values for specific enum types. For example, to rename the DayOfWeek.MONDAY enum to DayOfWeek.MON, set to {DayOfWeek: {MONDAY: "MON"}}. Defaults to an empty hash. Examples: Shorten the names of the DayOfWeek enum values ElasticGraph::Local::RakeTasks.new( local_config_yaml: "config/settings/local.yaml", path_to_schema: "config/schema.rb" ) do |tasks| tasks.enum_value_overrides_by_type = { DayOfWeek: { MONDAY: "MON", TUESDAY: "TUE", WEDNESDAY: "WED", THURSDAY: "THU", FRIDAY: "FRI", SATURDAY: "SAT", SUNDAY: "SUN" } } end (Hash>) — overrides for the names of specific enum values for specific enum types #env_port_mapping ⇒ Hash Note: When booting Elasticsearch/OpenSearch, Kibana (or its OpenSearch equivalent, “OpenSearch Dashboards”) will also get booted, selecting the port by adding 10000 to the configured port. Hash mapping environments (e.g. :test, :dev, etc) to port numbers for use when booting Elasticsearch or OpenSearch. The hash automatically includes an entry for the :local environment, using a port number extracted from local_config_yaml. Examples: Define what port to use to boot the datastore for the :test environment ElasticGraph::Local::RakeTasks.new( local_config_yaml: "config/settings/local.yaml", path_to_schema: "config/schema.rb" ) do |tasks| tasks.env_port_mapping = {test: 9999} end (Hash) — mapping from environment name to port number #index_document_sizes ⇒ Boolean Note: Enabling this requires the mapper-size plugin to be installed on your datastore cluster. You are responsible for ensuring that is installed if you enable this feature. If you enable this and the plugin is not installed, you will get errors! When enabled, ElasticGraph will configure the index mappings so that the datastore indexes a _size field in each index document. ElasticGraph itself does not do anything with this field, but it will be available for your use in any direct queries (e.g. via Kibana). Defaults to false since it requires a plugin. Examples: Enable indexing document sizes ElasticGraph::Local::RakeTasks.new( local_config_yaml: "config/settings/local.yaml", path_to_schema: "config/schema.rb" ) do |tasks| tasks.index_document_sizes = true end (Boolean) — whether or not the _size field should be indexed on each indexed type #opensearch_versions ⇒ Array List of OpenSearch versions you want to be able to boot. Rake tasks will be defined for each version to support booting and halting OpenSearch locally. If the configuration of local_config_yaml only configures elasticsearch as a cluster backend, will default to an empty array. Otherwise, defaults to the versions of OpenSearch that are exercised by the ElasticGraph test suite, as defined by lib/elastic_graph/local/tested_datastore_versions.yaml: # This file determines the versions the ElasticGraph CI build tests against, and is also# used to provide the default versions offered by the `elasticgraph-local` rake tasks.elasticsearch:- 8.16.1 # latest version as of 2024-12-08.opensearch:- 2.18.0 # latest version as of 2024-12-08.- 2.7.0 # lowest version ElasticGraph currently supports Examples: Configure the OpenSearch versions available to boot locally ElasticGraph::Local::RakeTasks.new( local_config_yaml: "config/settings/local.yaml", path_to_schema: "config/schema.rb" ) do |tasks| tasks.opensearch_versions = ["2.18.0"] end (Array) — list of OpenSearch versions See Also: #elasticsearch_versions #output ⇒ IO IO for printing output (defaults to stdout). (IO) — IO object used for printing output. #schema_definition_extension_modules ⇒ Array List of Ruby modules to extend onto the SchemaDefinition::API instance. Designed to support ElasticGraph extensions (such as Apollo::SchemaDefinition::APIExtension). Defaults to an empty list. Examples: Use elasticgraph-apollo require "elastic_graph/apollo/schema_definition/api_extension" ElasticGraph::Local::RakeTasks.new( local_config_yaml: "config/settings/local.yaml", path_to_schema: "config/schema.rb" ) do |tasks| tasks.schema_definition_extension_modules = [ElasticGraph::Apollo::SchemaDefinition::APIExtension] end Extension that defines a @since directive and offers a since API on fields module SinceExtension # `self.extended` is a standard Ruby hook that gets called when a module is extended onto an object. # The argument is the object the module was extended onto (a `SchemaDefinition::API` instance in this case). def self.extended(api) # Define our `@since` directive api.raw_sdl "directive @since(date: Date!) on FIELD_DEFINITION" # In order to hook into fields, extend the `SchemaDefinition::Factory` with a module. The factory is used # for creation of all schema definition objects. api.factory.extend FactoryExtension end module FactoryExtension # Hook into the creation of all `SchemaDefinition::Field` objects so that we can extend each field # instance with our `FieldExtension` module. def new_field(*args, **options) super(*args, **options) do |field| field.extend FieldExtension yield field if block_given? end end end # Offer a `f.since date` API on fields. module FieldExtension def since(date) directive "since", date: date end end end ElasticGraph::Local::RakeTasks.new( local_config_yaml: "config/settings/local.yaml", path_to_schema: "config/schema.rb" ) do |tasks| tasks.schema_definition_extension_modules = [SinceExtension] end (Array) — list of extension modules #schema_element_name_form ⇒ :camelCase, :snake_case The form of names for schema elements (fields, arguments, directives) generated by ElasticGraph, either :snake_case or :camelCase. For example, if set to :camelCase, ElasticGraph will generate a groupedBy field, but if set to :snake_case, ElasticGraph will generate a grouped_by field. Defaults to :camelCase since most GraphQL schemas use that casing. Examples: Use snake_case names instead of camelCase ElasticGraph::Local::RakeTasks.new( local_config_yaml: "config/settings/local.yaml", path_to_schema: "config/schema.rb" ) do |tasks| tasks.schema_element_name_form = :snake_case end (:camelCase, :snake_case) — which form to use #schema_element_name_overrides ⇒ Hash Overrides for specific names of schema elements (fields, arguments, directives) generated by ElasticGraph. For example, to rename the gt filter field to greaterThan, set to {gt: "greaterThan"}. Defaults to an empty hash. Examples: Spell out comparison operators instead of using shortened forms ElasticGraph::Local::RakeTasks.new( local_config_yaml: "config/settings/local.yaml", path_to_schema: "config/schema.rb" ) do |tasks| tasks.schema_element_name_overrides = { gt: "greaterThan", gte: "greaterThanOrEqualTo", lt: "lessThan", lte: "lessThanOrEqualTo" } end (Hash) — overrides for specific field, argument, or directive names #type_name_overrides ⇒ Hash Overrides for the names of specific GraphQL types. For example, to rename the JsonSafeLong scalar to BigInt, set to {JsonSafeLong: "BigInt}. Defaults to an empty hash. Examples: Rename JsonSafeLong to BigInt ElasticGraph::Local::RakeTasks.new( local_config_yaml: "config/settings/local.yaml", path_to_schema: "config/schema.rb" ) do |tasks| tasks.type_name_overrides = {JsonSafeLong: "BigInt"} end (Hash) — overrides for specific type names Instance Method Details #define_fake_data_batch_for(type) {|Array>, Array>| ... } ⇒ Object Register a callback for use when indexing a batch fake data. An index_fake_data:[type] rake task will be generated for each registered callback. Examples: Register a callback to generate fake campaigns data ElasticGraph::Local::RakeTasks.new( local_config_yaml: "config/settings/local.yaml", path_to_schema: "config/schema.rb" ) do |tasks| tasks.define_fake_data_batch_for :campaigns do FactoryBot.build_list(:campaigns) end end Parameters: type (Symbol) — type of data batch. Can be the name of a GraphQL type or any other name you want to give a batch of fake data Yields: (Array>, Array>) — list the block should append to when generating data Yield (void) Note: This method uses keyword args for all required arguments. Optional task settings are instead specified using the block. Returns a new instance of RakeTasks. Maximum time (in seconds) to wait for the datastore to boot when booting it as a daemon. Defaults to 120. Overrides for the naming formats used by ElasticGraph for derived GraphQL type names. For example, to use Metrics instead of AggregatedValues as the suffix for the generated types supporting getting aggregated metrid values, set to {AggregatedValues: "%{base}Metrics"}. See SchemaDefinition::SchemaElements::TypeNamer::DEFAULT_FORMATS for the available formats. Defaults to an empty hash. List of Elasticsearch versions you want to be able to boot. Rake tasks will be defined for each version to support booting and halting Elasticsearch locally. If the configuration of local_config_yaml only configures opensearch as a cluster backend, will default to an empty array. Otherwise, defaults to the versions of Elasticsearch that are exercised by the ElasticGraph test suite, as defined by lib/elastic_graph/local/tested_datastore_versions.yaml: # This file determines the versions the ElasticGraph CI build tests against, and is also# used to provide the default versions offered by the `elasticgraph-local` rake tasks.elasticsearch:- 8.16.1 # latest version as of 2024-12-08.opensearch:- 2.18.0 # latest version as of 2024-12-08.- 2.7.0 # lowest version ElasticGraph currently supports Note: Generally speaking, you will want this to be true for any ElasticGraph application that is in production as the versioning of JSON schemas is what supports safe schema evolution as it allows ElasticGraph to identify which version of the JSON schema the publishing system was operating on when it published an event. It can be useful to set it to false before your application is in production, as you do not want to be forced to bump the version after every single schema change while you are building an initial prototype. Whether or not to enforce the requirement that the JSON schema version is incremented every time dumping the JSON schemas results in a changed artifact. Defaults to true. Overrides for the names of specific GraphQL enum values for specific enum types. For example, to rename the DayOfWeek.MONDAY enum to DayOfWeek.MON, set to {DayOfWeek: {MONDAY: "MON"}}. Defaults to an empty hash. Note: When booting Elasticsearch/OpenSearch, Kibana (or its OpenSearch equivalent, “OpenSearch Dashboards”) will also get booted, selecting the port by adding 10000 to the configured port. Hash mapping environments (e.g. :test, :dev, etc) to port numbers for use when booting Elasticsearch or OpenSearch. The hash automatically includes an entry for the :local environment, using a port number extracted from local_config_yaml. Note: Enabling this requires the mapper-size plugin to be installed on your datastore cluster. You are responsible for ensuring that is installed if you enable this feature. If you enable this and the plugin is not installed, you will get errors! When enabled, ElasticGraph will configure the index mappings so that the datastore indexes a _size field in each index document. ElasticGraph itself does not do anything with this field, but it will be available for your use in any direct queries (e.g. via Kibana). Defaults to false since it requires a plugin. List of OpenSearch versions you want to be able to boot. Rake tasks will be defined for each version to support booting and halting OpenSearch locally. If the configuration of local_config_yaml only configures elasticsearch as a cluster backend, will default to an empty array. Otherwise, defaults to the versions of OpenSearch that are exercised by the ElasticGraph test suite, as defined by lib/elastic_graph/local/tested_datastore_versions.yaml: # This file determines the versions the ElasticGraph CI build tests against, and is also# used to provide the default versions offered by the `elasticgraph-local` rake tasks.elasticsearch:- 8.16.1 # latest version as of 2024-12-08.opensearch:- 2.18.0 # latest version as of 2024-12-08.- 2.7.0 # lowest version ElasticGraph currently supports IO for printing output (defaults to stdout). List of Ruby modules to extend onto the SchemaDefinition::API instance. Designed to support ElasticGraph extensions (such as Apollo::SchemaDefinition::APIExtension). Defaults to an empty list. The form of names for schema elements (fields, arguments, directives) generated by ElasticGraph, either :snake_case or :camelCase. For example, if set to :camelCase, ElasticGraph will generate a groupedBy field, but if set to :snake_case, ElasticGraph will generate a grouped_by field. Defaults to :camelCase since most GraphQL schemas use that casing. Overrides for specific names of schema elements (fields, arguments, directives) generated by ElasticGraph. For example, to rename the gt filter field to greaterThan, set to {gt: "greaterThan"}. Defaults to an empty hash. Overrides for the names of specific GraphQL types. For example, to rename the JsonSafeLong scalar to BigInt, set to {JsonSafeLong: "BigInt}. Defaults to an empty hash. Register a callback for use when indexing a batch fake data. An index_fake_data:[type] rake task will be generated for each registered callback. ### API Documentation - Module: ElasticGraph::Local Index (L) » ElasticGraph » Local Module: ElasticGraph::Local elasticgraph-local/lib/elastic_graph/local/rake_tasks.rb, elasticgraph-local/lib/elastic_graph/local/docker_runner.rb, elasticgraph-local/lib/elastic_graph/local/local_indexer.rb, elasticgraph-local/lib/elastic_graph/local/indexing_coordinator.rb Provides support for developing and running ElasticGraph applications locally. Defined Under Namespace Classes: RakeTasks ### API Documentation - Class: ElasticGraph::Rack::GraphQLEndpoint Index (G) » ElasticGraph » Rack » GraphQLEndpoint Class: ElasticGraph::Rack::GraphQLEndpoint Inherits: Object Object ElasticGraph::Rack::GraphQLEndpoint show all elasticgraph-rack/lib/elastic_graph/rack/graphql_endpoint.rb A simple Rack wrapper around an ElasticGraph GraphQL endpoint. This can be used for local development, mounted in a Rails application, or run in any other Rack-compatible context. Examples: Simple config.ru to run an ElasticGraph endpoint as a Rack application require "elastic_graph/graphql" require "elastic_graph/rack/graphql_endpoint" graphql = ElasticGraph::GraphQL.from_yaml_file("config/settings/development.yaml") run ElasticGraph::Rack::GraphQLEndpoint.new(graphql) Instance Method Summary collapse #call(env) ⇒ Array(Integer, Hash, Array) Responds to a Rack request. #initialize(graphql) ⇒ GraphQLEndpoint constructor A new instance of GraphQLEndpoint. Constructor Details #initialize(graphql) ⇒ GraphQLEndpoint Returns a new instance of GraphQLEndpoint. Parameters: graphql (ElasticGraph::GraphQL) — ElasticGraph GraphQL instance Instance Method Details #call(env) ⇒ Array(Integer, Hash, Array) Responds to a Rack request. Parameters: env (Hash) — Rack env (Array(Integer, Hash, Array)) Returns a new instance of GraphQLEndpoint. Responds to a Rack request. ### API Documentation - Module: ElasticGraph::Rack::GraphiQL Index (G) » ElasticGraph » Rack » GraphiQL Module: ElasticGraph::Rack::GraphiQL elasticgraph-rack/lib/elastic_graph/rack/graphiql.rb A Rack application that serves both an ElasticGraph GraphQL endpoint and a GraphiQL IDE. This can be used for local development, mounted in a Rails application, or run in any other Rack-compatible context. Examples: Simple config.ru to run GraphiQL as a Rack application, targeting an ElasticGraph endpoint require "elastic_graph/graphql" require "elastic_graph/rack/graphiql" graphql = ElasticGraph::GraphQL.from_yaml_file("config/settings/development.yaml") run ElasticGraph::Rack::GraphiQL.new(graphql) Class Method Summary collapse .new(graphql) ⇒ Rack::Builder Builds a Rack application that serves both an ElasticGraph GraphQL endpoint and a GraphiQL IDE. Class Method Details .new(graphql) ⇒ Rack::Builder Builds a Rack application that serves both an ElasticGraph GraphQL endpoint and a GraphiQL IDE. Parameters: graphql (ElasticGraph::GraphQL) — ElasticGraph GraphQL instance (Rack::Builder) — built Rack application Builds a Rack application that serves both an ElasticGraph GraphQL endpoint and a GraphiQL IDE. ### API Documentation - Module: ElasticGraph::Rack Index (R) » ElasticGraph » Rack Module: ElasticGraph::Rack elasticgraph-rack/lib/elastic_graph/rack.rb, elasticgraph-rack/lib/elastic_graph/rack/graphiql.rb, elasticgraph-rack/lib/elastic_graph/rack/graphql_endpoint.rb Adapts an ElasticGraph GraphQL endpoint to run as a Rack application. This allows an ElasticGraph GraphQL endpoint to run inside any Rack-compatible web framework, including Ruby on Rails, or as a stand-alone application. Two configurations are supported: Use GraphQLEndpoint to serve a GraphQL endpoint. Use GraphiQL to serve a GraphQL endpoint and the GraphiQL IDE. Defined Under Namespace Modules: GraphiQL Classes: GraphQLEndpoint ### API Documentation - Class: ElasticGraph::SchemaDefinition::API Index (A) » ElasticGraph » SchemaDefinition » API Class: ElasticGraph::SchemaDefinition::API Inherits: Object Object ElasticGraph::SchemaDefinition::API show all elasticgraph-schema_definition/lib/elastic_graph/schema_definition/api.rb Root API object that provides the schema definition API. Examples: ElasticGraph.define_schema do |schema| # The `schema` object is an instance of `API` end Instance Attribute Summary collapse #factory ⇒ Factory readonly Object responsible for instantiating all schema element classes. #state ⇒ State readonly Object which holds all state for the schema definition. Instance Method Summary collapse #deleted_type(name) ⇒ void Registers the name of a type that existed in a prior version of the schema but has been deleted. #enum_type(name) {|SchemaElements::EnumType| ... } ⇒ void Defines a GraphQL enum type. #interface_type(name) {|SchemaElements::InterfaceType| ... } ⇒ void Defines a GraphQL interface. #json_schema_version(version) ⇒ void Defines the version number of the current JSON schema. #object_type(name) {|SchemaElements::ObjectType| ... } ⇒ void Defines a GraphQL object type Use it to define a concrete type that has subfields. #on_built_in_types {|SchemaElements::EnumType, SchemaElements::InputType, SchemaElements::InterfaceType, SchemaElements::ObjectType, SchemaElements::ScalarType, SchemaElements::UnionType| ... } ⇒ void Registers a customization callback that will be applied to every built-in type automatically provided by ElasticGraph. #raw_sdl(string) ⇒ void Defines a raw GraphQL SDL snippet that will be included in the generated schema.graphql artifact. #register_graphql_extension(extension_module, defined_at:, **extension_config) ⇒ void Registers a GraphQL extension module that will be loaded and used by elasticgraph-graphql. #results ⇒ Object The results of the schema definition. #scalar_type(name) {|SchemaElements::ScalarType| ... } ⇒ void Defines a GraphQL scalar type. #union_type(name) {|SchemaElements::UnionType| ... } ⇒ void Defines a GraphQL union type. Instance Attribute Details #factory ⇒ Factory (readonly) Returns object responsible for instantiating all schema element classes. (Factory) — object responsible for instantiating all schema element classes #state ⇒ State (readonly) Returns object which holds all state for the schema definition. (State) — object which holds all state for the schema definition Instance Method Details #deleted_type(name) ⇒ void Note: In situations where this API applies, ElasticGraph will give you an error message indicating that you need to use this API or SchemaElements::TypeWithSubfields#renamed_from. Likewise, when ElasticGraph no longer needs to know about this, it’ll give you a warning indicating the call to this method can be removed. This method returns an undefined value.Registers the name of a type that existed in a prior version of the schema but has been deleted. Examples: Indicate that Widget has been deleted ElasticGraph.define_schema do |schema| schema.deleted_type "Widget" end Parameters: name (String) — name of type that used to exist but has been deleted #enum_type(name) {|SchemaElements::EnumType| ... } ⇒ void This method returns an undefined value.Defines a GraphQL enum type. The type is restricted to an enumerated set of values, each with a unique name. Use value or values to define the enum values in the passed block. Note: if required by your configuration, this may generate a pair of Enum types (an input enum and an output enum). Examples: Define an enum type ElasticGraph.define_schema do |schema| schema.enum_type "Currency" do |t| t.value "USD" do |v| v.documentation "US Dollars." end t.value "JPY" do |v| v.documentation "Japanese Yen." end # You can define multiple values in one call if you don't care about their docs or directives. t.values "GBP", "AUD" end end Parameters: name (String) — name of the enum type Yields: (SchemaElements::EnumType) — enum type object #interface_type(name) {|SchemaElements::InterfaceType| ... } ⇒ void This method returns an undefined value.Defines a GraphQL interface. Use it to define an abstract supertype with one or more fields that concrete implementations of the interface must also define. Each implementation can be an SchemaElements::ObjectType or SchemaElements::InterfaceType. Examples: Define an interface and implement it ElasticGraph.define_schema do |schema| schema.interface_type "Athlete" do |t| t.field "name", "String" t.field "team", "String" end schema.object_type "BaseballPlayer" do |t| t.implements "Athlete" t.field "name", "String" t.field "team", "String" t.field "battingAvg", "Float" end schema.object_type "BasketballPlayer" do |t| t.implements "Athlete" t.field "name", "String" t.field "team", "String" t.field "pointsPerGame", "Float" end end Parameters: name (String) — name of the interface Yields: (SchemaElements::InterfaceType) — interface type object #json_schema_version(version) ⇒ void Note: While this is an important part of how ElasticGraph is designed to support schema evolution, it can be annoying constantly have to increment this while rapidly changing the schema during prototyping. You can disable the requirement to increment this on every JSON schema change by setting enforce_json_schema_version to false in your Rakefile. This method returns an undefined value.Defines the version number of the current JSON schema. Importantly, every time a change is made that impacts the JSON schema artifact, the version number must be incremented to ensure that each different version of the JSON schema is identified by a unique version number. The publisher will then include this version number in published events to identify the version of the schema it was using. This avoids the need to deploy the publisher and ElasticGraph indexer at the same time to keep them in sync. Examples: Set the JSON schema version to 1 ElasticGraph.define_schema do |schema| schema.json_schema_version 1 end Parameters: version (Integer) — current version number of the JSON schema artifact See Also: Local::RakeTasks#enforce_json_schema_version #object_type(name) {|SchemaElements::ObjectType| ... } ⇒ void This method returns an undefined value.Defines a GraphQL object type Use it to define a concrete type that has subfields. Object types can either be indexed (e.g. directly indexed in the datastore, and available to query from the root Query object) or embedded in other indexed types. Examples: Define embedded and indexed object types ElasticGraph.define_schema do |schema| # `Money` is an embedded object type schema.object_type "Money" do |t| t.field "currency", "String" t.field "amount", "JsonSafeLong" end # `Transaction` is an indexed object type schema.object_type "Transaction" do |t| t.root_query_fields plural: "transactions" t.field "id", "ID" t.field "cost", "Money" t.index "transactions" end end Parameters: name (String) — name of the object type Yields: (SchemaElements::ObjectType) — object type object #on_built_in_types {|SchemaElements::EnumType, SchemaElements::InputType, SchemaElements::InterfaceType, SchemaElements::ObjectType, SchemaElements::ScalarType, SchemaElements::UnionType| ... } ⇒ void This method returns an undefined value.Registers a customization callback that will be applied to every built-in type automatically provided by ElasticGraph. Provides an opportunity to customize the built-in types (e.g. to add directives to them or whatever). Examples: Customize documentation of built-in types ElasticGraph.define_schema do |schema| schema.on_built_in_types do |type| type.append_to_documentation "This is a built-in ElasticGraph type." end end Yields: (SchemaElements::EnumType, SchemaElements::InputType, SchemaElements::InterfaceType, SchemaElements::ObjectType, SchemaElements::ScalarType, SchemaElements::UnionType) — built in type #raw_sdl(string) ⇒ void This method returns an undefined value.Defines a raw GraphQL SDL snippet that will be included in the generated schema.graphql artifact. Designed to be an escape hatch, for when ElasticGraph doesn’t provide another way to write some type of GraphQL SDL element that you need. Currently, the only known use case is to define custom GraphQL directives. Examples: Define a custom directive and use it ElasticGraph.define_schema do |schema| # Define a directive we can use to annotate what system a data type comes from. schema.raw_sdl "directive @sourcedFrom(system: String!) on OBJECT" schema.object_type "Transaction" do |t| t.directive "sourcedFrom", system: "transaction-processor" end end Parameters: string (String) — Raw snippet of SDL #register_graphql_extension(extension_module, defined_at:, **extension_config) ⇒ void This method returns an undefined value.Registers a GraphQL extension module that will be loaded and used by elasticgraph-graphql. While such extension modules can also be configured in a settings YAML file, it can be useful to register it here when you want to ensure that the extension is used in all environments. For example, an extension library that defines custom schema elements (such as elasticgraph-apollo) may need to ensure its corresponding GraphQL extension module is used since the custom schema elements would not work correctly otherwise. Examples: Register elasticgraph-query_registry extension module require(query_registry_require_path = "elastic_graph/query_registry/graphql_extension") ElasticGraph.define_schema do |schema| schema.register_graphql_extension ElasticGraph::QueryRegistry::GraphQLExtension, defined_at: query_registry_require_path end Parameters: extension_module (Module) — GraphQL extension module defined_at (String) — the require path of the extension module extension_config (Hash) — configuration options for the extension module #results ⇒ Object Returns the results of the schema definition. the results of the schema definition #scalar_type(name) {|SchemaElements::ScalarType| ... } ⇒ void This method returns an undefined value.Defines a GraphQL scalar type. ElasticGraph itself uses this to define a few common scalar types (e.g. Date and DateTime), but it is also available to you to use to define your own custom scalar types. Examples: Define a scalar type ElasticGraph.define_schema do |schema| schema.scalar_type "URL" do |t| t.mapping type: "keyword" t.json_schema type: "string", format: "uri" end end Parameters: name (String) — name of the scalar type Yields: (SchemaElements::ScalarType) — scalar type object #union_type(name) {|SchemaElements::UnionType| ... } ⇒ void This method returns an undefined value.Defines a GraphQL union type. Use it to define an abstract supertype with one or more concrete subtypes. Each subtype must be an SchemaElements::ObjectType, but they do not have to share any fields in common. Examples: Define a union type ElasticGraph.define_schema do |schema| schema.object_type "Card" do |t| # ... end schema.object_type "BankAccount" do |t| # ... end schema.object_type "BitcoinWallet" do |t| # ... end schema.union_type "FundingSource" do |t| t.subtype "Card" t.subtypes "BankAccount", "BitcoinWallet" end end Parameters: name (String) — name of the union type Yields: (SchemaElements::UnionType) — union type object Returns object responsible for instantiating all schema element classes. Returns object which holds all state for the schema definition. Note: In situations where this API applies, ElasticGraph will give you an error message indicating that you need to use this API or SchemaElements::TypeWithSubfields#renamed_from. Likewise, when ElasticGraph no longer needs to know about this, it’ll give you a warning indicating the call to this method can be removed. This method returns an undefined value.Registers the name of a type that existed in a prior version of the schema but has been deleted. This method returns an undefined value.Defines a GraphQL enum type. The type is restricted to an enumerated set of values, each with a unique name. Use value or values to define the enum values in the passed block. Note: if required by your configuration, this may generate a pair of Enum types (an input enum and an output enum). This method returns an undefined value.Defines a GraphQL interface. Use it to define an abstract supertype with one or more fields that concrete implementations of the interface must also define. Each implementation can be an SchemaElements::ObjectType or SchemaElements::InterfaceType. Note: While this is an important part of how ElasticGraph is designed to support schema evolution, it can be annoying constantly have to increment this while rapidly changing the schema during prototyping. You can disable the requirement to increment this on every JSON schema change by setting enforce_json_schema_version to false in your Rakefile. This method returns an undefined value.Defines the version number of the current JSON schema. Importantly, every time a change is made that impacts the JSON schema artifact, the version number must be incremented to ensure that each different version of the JSON schema is identified by a unique version number. The publisher will then include this version number in published events to identify the version of the schema it was using. This avoids the need to deploy the publisher and ElasticGraph indexer at the same time to keep them in sync. This method returns an undefined value.Defines a GraphQL object type Use it to define a concrete type that has subfields. Object types can either be indexed (e.g. directly indexed in the datastore, and available to query from the root Query object) or embedded in other indexed types. This method returns an undefined value.Registers a customization callback that will be applied to every built-in type automatically provided by ElasticGraph. Provides an opportunity to customize the built-in types (e.g. to add directives to them or whatever). This method returns an undefined value.Defines a raw GraphQL SDL snippet that will be included in the generated schema.graphql artifact. Designed to be an escape hatch, for when ElasticGraph doesn’t provide another way to write some type of GraphQL SDL element that you need. Currently, the only known use case is to define custom GraphQL directives. This method returns an undefined value.Registers a GraphQL extension module that will be loaded and used by elasticgraph-graphql. While such extension modules can also be configured in a settings YAML file, it can be useful to register it here when you want to ensure that the extension is used in all environments. For example, an extension library that defines custom schema elements (such as elasticgraph-apollo) may need to ensure its corresponding GraphQL extension module is used since the custom schema elements would not work correctly otherwise. Returns the results of the schema definition. This method returns an undefined value.Defines a GraphQL scalar type. ElasticGraph itself uses this to define a few common scalar types (e.g. Date and DateTime), but it is also available to you to use to define your own custom scalar types. This method returns an undefined value.Defines a GraphQL union type. Use it to define an abstract supertype with one or more concrete subtypes. Each subtype must be an SchemaElements::ObjectType, but they do not have to share any fields in common. ### API Documentation - Class: ElasticGraph::SchemaDefinition::Indexing::DerivedFields::AppendOnlySet Index (A) » ElasticGraph » SchemaDefinition » Indexing » DerivedFields » AppendOnlySet Class: ElasticGraph::SchemaDefinition::Indexing::DerivedFields::AppendOnlySet Private Inherits: Object Object ElasticGraph::SchemaDefinition::Indexing::DerivedFields::AppendOnlySet show all elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_fields/append_only_set.rb Responsible for providing bits of the painless script specific to a ElasticGraph::SchemaDefinition::Indexing::DerivedIndexedType#append_only_set field. Instance Method Summary collapse #apply_operation_returning_update_status ⇒ String private A line of painless code to append a value to the set and return a boolean indicating if the set was updated. #function_definitions ⇒ Array private Painless functions required by append_only_set. #setup_statements ⇒ Array private The statements here initialize the field to an empty list if it is null. Instance Method Details #apply_operation_returning_update_status ⇒ String Returns a line of painless code to append a value to the set and return a boolean indicating if the set was updated. (String) — a line of painless code to append a value to the set and return a boolean indicating if the set was updated. #function_definitions ⇒ Array Returns painless functions required by append_only_set. (Array) — painless functions required by append_only_set. #setup_statements ⇒ Array The statements here initialize the field to an empty list if it is null. This primarily happens when the document does not already exist, but can also happen when we add a new derived field to an existing type. (Array) — a list of painless statements that must be called at the top of the script to set things up. Returns a line of painless code to append a value to the set and return a boolean indicating if the set was updated. Returns painless functions required by append_only_set. The statements here initialize the field to an empty list if it is null. This primarily happens when the document does not already exist, but can also happen when we add a new derived field to an existing type. ### API Documentation - Module: ElasticGraph::SchemaDefinition::Indexing::DerivedFields::FieldInitializerSupport Index (F) » ElasticGraph » SchemaDefinition » Indexing » DerivedFields » FieldInitializerSupport Module: ElasticGraph::SchemaDefinition::Indexing::DerivedFields::FieldInitializerSupport Private elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_fields/field_initializer_support.rb Contains helper logic for field initialization applicable to all types of derived fields. Constant Summary collapse EMPTY_PAINLESS_LIST = Painless literal for an empty list, from the docs. "[]" EMPTY_PAINLESS_MAP = Painless literal for an empty map, from the docs. "[:]" Class Method Summary collapse .build_empty_value_initializers(destination_field, leaf_value:) ⇒ Array private A list of painless statements that will initialize a given destination_field path to an empty value. .default_source_field_to_empty(field_path, empty_value) ⇒ String private A painless statement that will default a single field to an empty value. Class Method Details .build_empty_value_initializers(destination_field, leaf_value:) ⇒ Array Returns a list of painless statements that will initialize a given destination_field path to an empty value. (Array) — a list of painless statements that will initialize a given destination_field path to an empty value. .default_source_field_to_empty(field_path, empty_value) ⇒ String Returns a painless statement that will default a single field to an empty value. (String) — a painless statement that will default a single field to an empty value. Returns a list of painless statements that will initialize a given destination_field path to an empty value. Returns a painless statement that will default a single field to an empty value. ### API Documentation - Class: ElasticGraph::SchemaDefinition::Indexing::DerivedFields::ImmutableValue Index (I) » ElasticGraph » SchemaDefinition » Indexing » DerivedFields » ImmutableValue Class: ElasticGraph::SchemaDefinition::Indexing::DerivedFields::ImmutableValue Private Inherits: Object Object ElasticGraph::SchemaDefinition::Indexing::DerivedFields::ImmutableValue show all elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_fields/immutable_value.rb Responsible for providing bits of the painless script specific to a ElasticGraph::SchemaDefinition::Indexing::DerivedIndexedType#immutable_value field. Instance Method Summary collapse #apply_operation_returning_update_status ⇒ String private A line of painless code to manage an immutable value field and return a boolean indicating if it was updated. #function_definitions ⇒ Array private Painless functions required by immutable_value. #setup_statements ⇒ Array private A list of painless statements that must be called at the top of the script to set things up. Instance Method Details #apply_operation_returning_update_status ⇒ String Returns a line of painless code to manage an immutable value field and return a boolean indicating if it was updated. (String) — a line of painless code to manage an immutable value field and return a boolean indicating if it was updated. #function_definitions ⇒ Array Returns painless functions required by immutable_value. (Array) — painless functions required by immutable_value. #setup_statements ⇒ Array Returns a list of painless statements that must be called at the top of the script to set things up. (Array) — a list of painless statements that must be called at the top of the script to set things up. Returns a line of painless code to manage an immutable value field and return a boolean indicating if it was updated. Returns painless functions required by immutable_value. Returns a list of painless statements that must be called at the top of the script to set things up. ### API Documentation - Class: ElasticGraph::SchemaDefinition::Indexing::DerivedFields::MinOrMaxValue Index (M) » ElasticGraph » SchemaDefinition » Indexing » DerivedFields » MinOrMaxValue Class: ElasticGraph::SchemaDefinition::Indexing::DerivedFields::MinOrMaxValue Private Inherits: Object Object ElasticGraph::SchemaDefinition::Indexing::DerivedFields::MinOrMaxValue show all elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_fields/min_or_max_value.rb Responsible for providing bits of the painless script specific to a ElasticGraph::SchemaDefinition::Indexing::DerivedIndexedType#min_value or ElasticGraph::SchemaDefinition::Indexing::DerivedIndexedType#max_value field. Class Method Summary collapse .function_def(min_or_max) ⇒ String private Painless function for managing a min or max field. Instance Method Summary collapse #apply_operation_returning_update_status ⇒ String private A line of painless code to manage a min or max value field and return a boolean indicating if it was updated. #function_definitions ⇒ Array private Painless functions required by a min or max value field. #setup_statements ⇒ Array private A list of painless statements that must be called at the top of the script to set things up. Class Method Details .function_def(min_or_max) ⇒ String Returns painless function for managing a min or max field. Parameters: min_or_max (:min, :max) — which type of function to generate. (String) — painless function for managing a min or max field. Instance Method Details #apply_operation_returning_update_status ⇒ String Returns a line of painless code to manage a min or max value field and return a boolean indicating if it was updated. (String) — a line of painless code to manage a min or max value field and return a boolean indicating if it was updated. #function_definitions ⇒ Array Returns painless functions required by a min or max value field. (Array) — painless functions required by a min or max value field. #setup_statements ⇒ Array Returns a list of painless statements that must be called at the top of the script to set things up. (Array) — a list of painless statements that must be called at the top of the script to set things up. Returns painless function for managing a min or max field. Returns a line of painless code to manage a min or max value field and return a boolean indicating if it was updated. Returns painless functions required by a min or max value field. Returns a list of painless statements that must be called at the top of the script to set things up. ### API Documentation - Module: ElasticGraph::SchemaDefinition::Indexing::DerivedFields Index (D) » ElasticGraph » SchemaDefinition » Indexing » DerivedFields Module: ElasticGraph::SchemaDefinition::Indexing::DerivedFields Private elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_fields/field_initializer_support.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_fields/append_only_set.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_fields/immutable_value.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_fields/min_or_max_value.rb Contains implementation logic for the different kinds of derived fields. Defined Under Namespace Modules: FieldInitializerSupport Classes: AppendOnlySet, ImmutableValue, MinOrMaxValue ### API Documentation - Class: ElasticGraph::SchemaDefinition::Indexing::DerivedIndexedType Index (D) » ElasticGraph » SchemaDefinition » Indexing » DerivedIndexedType Class: ElasticGraph::SchemaDefinition::Indexing::DerivedIndexedType Inherits: Object Object ElasticGraph::SchemaDefinition::Indexing::DerivedIndexedType show all elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_indexed_type.rb Used to configure the derivation of a derived indexed type from a source type. This type is yielded from Mixins::HasIndices#derive_indexed_type_fields. Examples: Derive a Course type from StudentCourseEnrollment events ElasticGraph.define_schema do |schema| # `StudentCourseEnrollment` is a directly indexed type. schema.object_type "StudentCourseEnrollment" do |t| t.field "id", "ID" t.field "courseId", "ID" t.field "courseName", "String" t.field "studentName", "String" t.field "courseStartDate", "Date" t.index "student_course_enrollments" # Here we define how the `Course` indexed type is derived when we index `StudentCourseEnrollment` events. t.derive_indexed_type_fields "Course", from_id: "courseId" do |derive| # `derive` is an instance of `DerivedIndexedType`. derive.immutable_value "name", from: "courseName" derive.append_only_set "students", from: "studentName" derive.min_value "firstOfferedDate", from: "courseStartDate" derive.max_value "mostRecentlyOfferedDate", from: "courseStartDate" end end # `Course` is an indexed type that is derived entirely from `StudentCourseEnrollment` events. schema.object_type "Course" do |t| t.field "id", "ID" t.field "name", "String" t.field "students", "[String!]!" t.field "firstOfferedDate", "Date" t.field "mostRecentlyOfferedDate", "Date" t.index "courses" end end Instance Attribute Summary collapse #fields ⇒ Array Derived field definitions. #id_source ⇒ String Path to field on the source type used as id on the derived type. #rollover_timestamp_value_source ⇒ String? Path to field on the source type used as the timestamp field for rollover. #routing_value_source ⇒ String? Path to field on the source type used for shard routing. #source_type ⇒ SchemaElements::ObjectType The type used as a source for this derive type. Instance Method Summary collapse #append_only_set(field_name, from:) ⇒ DerivedIndexedType::AppendOnlySet Configures field_name (on the derived indexing type) to contain the set union of all values from the from field on the source type. #immutable_value(field_name, from:, nullable: true, can_change_from_null: false) ⇒ DerivedFields::ImmutableValue Configures field_name (on the derived indexing type) to contain a single immutable value from the from field on the source type. #initialize(source_type:, destination_type_ref:, id_source:, routing_value_source:, rollover_timestamp_value_source:) {|DerivedIndexedType| ... } ⇒ DerivedIndexedType constructor private A new instance of DerivedIndexedType. #max_value(field_name, from:) ⇒ DerivedIndexedType::MinOrMaxValue Configures field_name (on the derived indexing type) to contain the maximum of all values from the from field on the source type. #min_value(field_name, from:) ⇒ DerivedIndexedType::MinOrMaxValue Configures field_name (on the derived indexing type) to contain the minimum of all values from the from field on the source type. #painless_script ⇒ Scripting::Script private Painless script that will maintain the derived fields. #runtime_metadata_for_source_type ⇒ SchemaArtifacts::RuntimeMetadata::UpdateTarget private Runtime metadata for the source type. Constructor Details #initialize(source_type:, destination_type_ref:, id_source:, routing_value_source:, rollover_timestamp_value_source:) {|DerivedIndexedType| ... } ⇒ DerivedIndexedType Returns a new instance of DerivedIndexedType. Parameters: source_type (SchemaElements::ObjectType) — the type used as a source for this derive type destination_type_ref (SchemaElements::TypeReference) — the derived type id_source (String) — path to field on the source type used as id on the derived type routing_value_source (String, nil) — path to field on the source type used for shard routing rollover_timestamp_value_source (String, nil) — path to field on the source type used as the timestamp field for rollover Yields: (DerivedIndexedType) — the DerivedIndexedType instance Instance Attribute Details #fields ⇒ Array Returns derived field definitions. (Array) — derived field definitions #id_source ⇒ String Returns path to field on the source type used as id on the derived type. (String) — path to field on the source type used as id on the derived type #rollover_timestamp_value_source ⇒ String? Returns path to field on the source type used as the timestamp field for rollover. (String, nil) — path to field on the source type used as the timestamp field for rollover #routing_value_source ⇒ String? Returns path to field on the source type used for shard routing. (String, nil) — path to field on the source type used for shard routing #source_type ⇒ SchemaElements::ObjectType Returns the type used as a source for this derive type. (SchemaElements::ObjectType) — the type used as a source for this derive type Instance Method Details #append_only_set(field_name, from:) ⇒ DerivedIndexedType::AppendOnlySet Configures field_name (on the derived indexing type) to contain the set union of all values from the from field on the source type. Values are only ever appended to the set, so the field will act as an append-only set. Examples: ElasticGraph.define_schema do |schema| schema.object_type "StudentCourseEnrollment" do |t| t.field "id", "ID" t.field "courseId", "ID" t.field "studentName", "String" t.index "student_course_enrollments" t.derive_indexed_type_fields "Course", from_id: "courseId" do |derive| derive.append_only_set "students", from: "studentName" end end schema.object_type "Course" do |t| t.field "id", "ID" t.field "students", "[String!]!" t.index "courses" end end Parameters: field_name (String) — name of field on the derived indexing type to store the derived set from (String) — path to field on the source type to source values from (DerivedIndexedType::AppendOnlySet) #immutable_value(field_name, from:, nullable: true, can_change_from_null: false) ⇒ DerivedFields::ImmutableValue Configures field_name (on the derived indexing type) to contain a single immutable value from the from field on the source type. Immutability is enforced by triggering an indexing failure with a clear error if any event’s source value is different from the value already indexed on this field. Examples: ElasticGraph.define_schema do |schema| schema.object_type "StudentCourseEnrollment" do |t| t.field "id", "ID" t.field "courseId", "ID" t.field "courseName", "String" t.index "student_course_enrollments" t.derive_indexed_type_fields "Course", from_id: "courseId" do |derive| derive.immutable_value "name", from: "courseName" end end schema.object_type "Course" do |t| t.field "id", "ID" t.field "name", "String" t.index "courses" end end Parameters: field_name (String) — name of field on the derived indexing type to store the derived value from (String) — path to field on the source type to source values from nullable (Boolean) (defaults to: true) — whether the field is allowed to be set to null. When set to false, events that contain a null value in the from field will be rejected instead of setting the field’s value to null. can_change_from_null (Boolean) (defaults to: false) — whether a one-time mutation of the field value is allowed from null to a non-null value. This can be useful when dealing with a field that may not have a value on all source events. For example, if the source field was not initially part of the schema of your source dataset, you may have old records that lack a value for this field. When set, this option allows a one-time mutation of the field value from null to a non-null value. Once set to a non-null value, any additional null values that are encountered will be ignored (ensuring that the indexed data converges on the same state regardless of the order the events are ingested in). Note: this option cannot be enabled when nullable: false has been set. (DerivedFields::ImmutableValue) #max_value(field_name, from:) ⇒ DerivedIndexedType::MinOrMaxValue Configures field_name (on the derived indexing type) to contain the maximum of all values from the from field on the source type. Examples: ElasticGraph.define_schema do |schema| schema.object_type "StudentCourseEnrollment" do |t| t.field "id", "ID" t.field "courseId", "ID" t.field "courseStartDate", "Date" t.index "student_course_enrollments" t.derive_indexed_type_fields "Course", from_id: "courseId" do |derive| derive.max_value "mostRecentlyOfferedDate", from: "courseStartDate" end end schema.object_type "Course" do |t| t.field "id", "ID" t.field "mostRecentlyOfferedDate", "Date" t.index "courses" end end Parameters: field_name (String) — name of field on the derived indexing type to store the derived value from (String) — path to field on the source type to source values from (DerivedIndexedType::MinOrMaxValue) #min_value(field_name, from:) ⇒ DerivedIndexedType::MinOrMaxValue Configures field_name (on the derived indexing type) to contain the minimum of all values from the from field on the source type. Examples: ElasticGraph.define_schema do |schema| schema.object_type "StudentCourseEnrollment" do |t| t.field "id", "ID" t.field "courseId", "ID" t.field "courseStartDate", "Date" t.index "student_course_enrollments" t.derive_indexed_type_fields "Course", from_id: "courseId" do |derive| derive.min_value "firstOfferedDate", from: "courseStartDate" end end schema.object_type "Course" do |t| t.field "id", "ID" t.field "firstOfferedDate", "Date" t.index "courses" end end Parameters: field_name (String) — name of field on the derived indexing type to store the derived value from (String) — path to field on the source type to source values from (DerivedIndexedType::MinOrMaxValue) #painless_script ⇒ Scripting::Script Returns Painless script that will maintain the derived fields. (Scripting::Script) — Painless script that will maintain the derived fields #runtime_metadata_for_source_type ⇒ SchemaArtifacts::RuntimeMetadata::UpdateTarget Returns runtime metadata for the source type. (SchemaArtifacts::RuntimeMetadata::UpdateTarget) — runtime metadata for the source type Returns a new instance of DerivedIndexedType. Returns derived field definitions. Returns path to field on the source type used as id on the derived type. Returns path to field on the source type used as the timestamp field for rollover. Returns path to field on the source type used for shard routing. Returns the type used as a source for this derive type. Configures field_name (on the derived indexing type) to contain the set union of all values from the from field on the source type. Values are only ever appended to the set, so the field will act as an append-only set. Configures field_name (on the derived indexing type) to contain a single immutable value from the from field on the source type. Immutability is enforced by triggering an indexing failure with a clear error if any event’s source value is different from the value already indexed on this field. Configures field_name (on the derived indexing type) to contain the maximum of all values from the from field on the source type. Configures field_name (on the derived indexing type) to contain the minimum of all values from the from field on the source type. Returns Painless script that will maintain the derived fields. Returns runtime metadata for the source type. ### API Documentation - Module: ElasticGraph::SchemaDefinition::Indexing::EventEnvelope Index (E) » ElasticGraph » SchemaDefinition » Indexing » EventEnvelope Module: ElasticGraph::SchemaDefinition::Indexing::EventEnvelope Private elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/event_envelope.rb Contains logic related to “event envelope”–the layer of metadata that wraps all indexing events. Class Method Summary collapse .json_schema(indexed_type_names, json_schema_version) ⇒ Hash private The JSON schema for the ElasticGraph event envelope for the given indexed_type_names. Class Method Details .json_schema(indexed_type_names, json_schema_version) ⇒ Hash Returns the JSON schema for the ElasticGraph event envelope for the given indexed_type_names. Parameters: indexed_type_names (Array) — names of the indexed types json_schema_version (Integer) — the version of the JSON schema (Hash) — the JSON schema for the ElasticGraph event envelope for the given indexed_type_names. Returns the JSON schema for the ElasticGraph event envelope for the given indexed_type_names. ### API Documentation - Class: ElasticGraph::SchemaDefinition::Indexing::Field Index (F) » ElasticGraph » SchemaDefinition » Indexing » Field Class: ElasticGraph::SchemaDefinition::Indexing::Field Private Inherits: Object Object ElasticGraph::SchemaDefinition::Indexing::Field show all elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field.rb Represents a field in a JSON document during indexing. Constant Summary collapse JSON_SCHEMA_OVERRIDES_BY_MAPPING_TYPE = Note: We don’t handle integer here because it’s the default numeric type (handled by our definition of the Int scalar type). Note: Likewise, we don’t handle long here because a custom scalar type must be used for that since GraphQL’s Int type can’t handle long values. JSON schema overrides that automatically apply to specific mapping types so that the JSON schema validation will reject values which cannot be indexed into fields of a specific mapping type. See Also: Elasticsearch numeric field type documentation { "byte" => {"minimum" => -(2**7), "maximum" => (2**7) - 1}, "short" => {"minimum" => -(2**15), "maximum" => (2**15) - 1}, "keyword" => {"maxLength" => DEFAULT_MAX_KEYWORD_LENGTH}, "text" => {"maxLength" => DEFAULT_MAX_TEXT_LENGTH} } Class Method Summary collapse .normalized_mapping_hash_for(fields) ⇒ Hash private Builds a hash containing the mapping for the provided fields, normalizing it in the same way that the datastore does so that consistency checks between our index configuration and what’s in the datastore work properly. Instance Method Summary collapse #json_schema ⇒ Hash private The JSON schema definition for this field. #json_schema_metadata ⇒ JSONSchemaFieldMetadata private Additional ElasticGraph metadata to be stored in the JSON schema for this field. #mapping ⇒ Hash private The mapping for this field. Class Method Details .normalized_mapping_hash_for(fields) ⇒ Hash Builds a hash containing the mapping for the provided fields, normalizing it in the same way that the datastore does so that consistency checks between our index configuration and what’s in the datastore work properly. Parameters: fields (Array) — fields to generate a mapping hash from (Hash) — generated mapping hash Instance Method Details #json_schema ⇒ Hash Returns the JSON schema definition for this field. The returned object should be composed entirely of Ruby primitives that, when converted to a JSON string, match the requirements of the JSON schema spec. (Hash) — the JSON schema definition for this field. The returned object should be composed entirely of Ruby primitives that, when converted to a JSON string, match the requirements of the JSON schema spec. #json_schema_metadata ⇒ JSONSchemaFieldMetadata Returns additional ElasticGraph metadata to be stored in the JSON schema for this field. (JSONSchemaFieldMetadata) — additional ElasticGraph metadata to be stored in the JSON schema for this field. #mapping ⇒ Hash Returns the mapping for this field. The returned hash should be composed entirely of Ruby primitives that, when converted to a JSON string, match the structure required by Elasticsearch. (Hash) — the mapping for this field. The returned hash should be composed entirely of Ruby primitives that, when converted to a JSON string, match the structure required by Elasticsearch. Builds a hash containing the mapping for the provided fields, normalizing it in the same way that the datastore does so that consistency checks between our index configuration and what’s in the datastore work properly. Returns the JSON schema definition for this field. The returned object should be composed entirely of Ruby primitives that, when converted to a JSON string, match the requirements of the JSON schema spec. Returns additional ElasticGraph metadata to be stored in the JSON schema for this field. Returns the mapping for this field. The returned hash should be composed entirely of Ruby primitives that, when converted to a JSON string, match the structure required by Elasticsearch. ### API Documentation - Class: ElasticGraph::SchemaDefinition::Indexing::FieldReference Index (F) » ElasticGraph » SchemaDefinition » Indexing » FieldReference Class: ElasticGraph::SchemaDefinition::Indexing::FieldReference Private Inherits: Data Object Data ElasticGraph::SchemaDefinition::Indexing::FieldReference show all elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_reference.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_reference.rb A lazy reference to a Field. It contains all attributes needed to build a Field, but the referenced type may not be resolvable yet (which is why this exists). Instance Method Summary collapse #resolve ⇒ Field? private The Field this reference resolves to (if it can be resolved). Instance Method Details #resolve ⇒ Field? Returns the ElasticGraph::SchemaDefinition::Indexing::Field this reference resolves to (if it can be resolved). (Field, nil) — the ElasticGraph::SchemaDefinition::Indexing::Field this reference resolves to (if it can be resolved) Returns the ElasticGraph::SchemaDefinition::Indexing::Field this reference resolves to (if it can be resolved). ### API Documentation - Class: ElasticGraph::SchemaDefinition::Indexing::FieldType::Enum Index (E) » ElasticGraph » SchemaDefinition » Indexing » FieldType » Enum Class: ElasticGraph::SchemaDefinition::Indexing::FieldType::Enum Private Inherits: Data Object Data ElasticGraph::SchemaDefinition::Indexing::FieldType::Enum show all elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/enum.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/enum.rb Responsible for the JSON schema and mapping of a SchemaElements::EnumType. Instance Attribute Summary collapse #enum_value_names ⇒ Array readonly List of names of values in this enum type. Instance Method Summary collapse #format_field_json_schema_customizations(customizations) ⇒ Hash private Formatted customizations. #json_schema_field_metadata_by_field_name ⇒ Hash private Additional ElasticGraph metadata to put in the JSON schema for this enum type. #to_json_schema ⇒ Hash private The JSON schema for this enum type. #to_mapping ⇒ Hash private The datastore mapping for this enum type. Instance Attribute Details #enum_value_names ⇒ Array (readonly) Returns list of names of values in this enum type. (Array) — list of names of values in this enum type. Instance Method Details #format_field_json_schema_customizations(customizations) ⇒ Hash Returns formatted customizations. Parameters: customizations (Hash) — JSON schema customizations (Hash) — formatted customizations. #json_schema_field_metadata_by_field_name ⇒ Hash Returns additional ElasticGraph metadata to put in the JSON schema for this enum type. (Hash) — additional ElasticGraph metadata to put in the JSON schema for this enum type. #to_json_schema ⇒ Hash Returns the JSON schema for this enum type. (Hash) — the JSON schema for this enum type. #to_mapping ⇒ Hash Returns the datastore mapping for this enum type. (Hash) — the datastore mapping for this enum type. Returns list of names of values in this enum type. Returns formatted customizations. Returns additional ElasticGraph metadata to put in the JSON schema for this enum type. Returns the JSON schema for this enum type. Returns the datastore mapping for this enum type. ### API Documentation - Class: ElasticGraph::SchemaDefinition::Indexing::FieldType::Object Index (O) » ElasticGraph » SchemaDefinition » Indexing » FieldType » Object Class: ElasticGraph::SchemaDefinition::Indexing::FieldType::Object Private Inherits: Object Object ElasticGraph::SchemaDefinition::Indexing::FieldType::Object show all elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/object.rb Responsible for the JSON schema and mapping of a SchemaElements::ObjectType. Instance Attribute Summary collapse #json_schema_options ⇒ Hash readonly Options to be included in the JSON schema. #mapping_options ⇒ Hash readonly Options to be included in the mapping. #subfields ⇒ Array readonly The subfields of this object type. #type_name ⇒ String readonly Name of the object type. Instance Method Summary collapse #format_field_json_schema_customizations(customizations) ⇒ Hash private Formatted customizations. #json_schema_field_metadata_by_field_name ⇒ Hash private Additional ElasticGraph metadata to put in the JSON schema for this object type. #to_json_schema ⇒ Hash private The JSON schema for this object type. #to_mapping ⇒ Hash private The datastore mapping for this object type. Instance Attribute Details #json_schema_options ⇒ Hash (readonly) Returns options to be included in the JSON schema. (Hash) — options to be included in the JSON schema #mapping_options ⇒ Hash (readonly) Returns options to be included in the mapping. (Hash) — options to be included in the mapping #subfields ⇒ Array (readonly) Returns the subfields of this object type. (Array) — the subfields of this object type #type_name ⇒ String (readonly) Returns name of the object type. (String) — name of the object type Instance Method Details #format_field_json_schema_customizations(customizations) ⇒ Hash Returns formatted customizations. Parameters: customizations (Hash) — JSON schema customizations (Hash) — formatted customizations. #json_schema_field_metadata_by_field_name ⇒ Hash Returns additional ElasticGraph metadata to put in the JSON schema for this object type. (Hash) — additional ElasticGraph metadata to put in the JSON schema for this object type. #to_json_schema ⇒ Hash Returns the JSON schema for this object type. (Hash) — the JSON schema for this object type. #to_mapping ⇒ Hash Returns the datastore mapping for this object type. (Hash) — the datastore mapping for this object type. Returns options to be included in the JSON schema. Returns options to be included in the mapping. Returns the subfields of this object type. Returns name of the object type. Returns formatted customizations. Returns additional ElasticGraph metadata to put in the JSON schema for this object type. Returns the JSON schema for this object type. Returns the datastore mapping for this object type. ### API Documentation - Class: ElasticGraph::SchemaDefinition::Indexing::FieldType::Scalar Index (S) » ElasticGraph » SchemaDefinition » Indexing » FieldType » Scalar Class: ElasticGraph::SchemaDefinition::Indexing::FieldType::Scalar Private Inherits: Data Object Data ElasticGraph::SchemaDefinition::Indexing::FieldType::Scalar show all elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/scalar.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/scalar.rb Responsible for the JSON schema and mapping of a SchemaElements::ScalarType. Instance Attribute Summary collapse #scalar_type ⇒ SchemaElements::ScalarType readonly The scalar type. Instance Method Summary collapse #format_field_json_schema_customizations(customizations) ⇒ Hash private Formatted customizations. #json_schema_field_metadata_by_field_name ⇒ Hash private Additional ElasticGraph metadata to put in the JSON schema for this scalar type. #to_json_schema ⇒ Hash private The JSON schema for this scalar type. #to_mapping ⇒ Hash private The datastore mapping for this scalar type. Instance Attribute Details #scalar_type ⇒ SchemaElements::ScalarType (readonly) Returns the scalar type. (SchemaElements::ScalarType) — the scalar type Instance Method Details #format_field_json_schema_customizations(customizations) ⇒ Hash Returns formatted customizations. Parameters: customizations (Hash) — JSON schema customizations (Hash) — formatted customizations. #json_schema_field_metadata_by_field_name ⇒ Hash Returns additional ElasticGraph metadata to put in the JSON schema for this scalar type. (Hash) — additional ElasticGraph metadata to put in the JSON schema for this scalar type. #to_json_schema ⇒ Hash Returns the JSON schema for this scalar type. (Hash) — the JSON schema for this scalar type. #to_mapping ⇒ Hash Returns the datastore mapping for this scalar type. (Hash) — the datastore mapping for this scalar type. Returns the scalar type. Returns formatted customizations. Returns additional ElasticGraph metadata to put in the JSON schema for this scalar type. Returns the JSON schema for this scalar type. Returns the datastore mapping for this scalar type. ### API Documentation - Class: ElasticGraph::SchemaDefinition::Indexing::FieldType::Union Index (U) » ElasticGraph » SchemaDefinition » Indexing » FieldType » Union Class: ElasticGraph::SchemaDefinition::Indexing::FieldType::Union Private Inherits: Object Object ElasticGraph::SchemaDefinition::Indexing::FieldType::Union show all elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/union.rb Note: In JSON schema, we model this with a oneOf, and a __typename field on each subtype. Note: Within the mapping, we have a single object type that has a set union of the properties of the subtypes (and also a __typename keyword field). Responsible for the JSON schema and mapping of a SchemaElements::UnionType. Instance Attribute Summary collapse #subtypes_by_name ⇒ Hash readonly The subtypes of the union, keyed by name. Instance Method Summary collapse #format_field_json_schema_customizations(customizations) ⇒ Hash private Formatted customizations. #json_schema_field_metadata_by_field_name ⇒ Hash private Additional ElasticGraph metadata to put in the JSON schema for this union type. #to_json_schema ⇒ Hash private The JSON schema for this union type. #to_mapping ⇒ Hash private The datastore mapping for this union type. Instance Attribute Details #subtypes_by_name ⇒ Hash (readonly) Returns the subtypes of the union, keyed by name. (Hash) — the subtypes of the union, keyed by name. Instance Method Details #format_field_json_schema_customizations(customizations) ⇒ Hash Returns formatted customizations. Parameters: customizations (Hash) — JSON schema customizations (Hash) — formatted customizations. #json_schema_field_metadata_by_field_name ⇒ Hash Returns additional ElasticGraph metadata to put in the JSON schema for this union type. (Hash) — additional ElasticGraph metadata to put in the JSON schema for this union type. #to_json_schema ⇒ Hash Returns the JSON schema for this union type. (Hash) — the JSON schema for this union type. #to_mapping ⇒ Hash Returns the datastore mapping for this union type. (Hash) — the datastore mapping for this union type. Returns the subtypes of the union, keyed by name. Returns formatted customizations. Returns additional ElasticGraph metadata to put in the JSON schema for this union type. Returns the JSON schema for this union type. Returns the datastore mapping for this union type. ### API Documentation - Module: ElasticGraph::SchemaDefinition::Indexing::FieldType Index (F) » ElasticGraph » SchemaDefinition » Indexing » FieldType Module: ElasticGraph::SchemaDefinition::Indexing::FieldType Private elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/enum.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/union.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/object.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/scalar.rb Contains implementation logic for the different types of indexing fields. Defined Under Namespace Classes: Enum, Object, Scalar, Union ### API Documentation - Class: ElasticGraph::SchemaDefinition::Indexing::Index Index (I) » ElasticGraph » SchemaDefinition » Indexing » Index Class: ElasticGraph::SchemaDefinition::Indexing::Index Inherits: Struct Object Struct ElasticGraph::SchemaDefinition::Indexing::Index show all elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/index.rb Represents an index in a datastore. Defined within an indexed type. Modeled as a separate object to facilitate further customization of the index. Instance Attribute Summary collapse #default_sort_pairs ⇒ Array<(String, Symbol)> readonly (field name, direction) pairs for the default sort. #indexed_type ⇒ SchemaElements::ObjectType, ... readonly Type backed by this index. #name ⇒ String readonly Name of the index. #rollover_config ⇒ RolloverConfig? readonly Rollover configuration for the index. #routing_field_path ⇒ Array readonly Path to the field used for shard routing. #schema_def_state ⇒ State readonly Schema definition state. #settings ⇒ Hash<(String, Object)> readonly Datastore settings for the index. Instance Method Summary collapse #default_sort(*field_name_direction_pairs) ⇒ void Specifies how documents in this index should sort by default, when no orderBy argument is provided to the GraphQL query. #initialize(name, settings, schema_def_state, indexed_type) {|Index| ... } ⇒ Index constructor private A new instance of Index. #rollover(frequency, timestamp_field_path_name) ⇒ void Causes this index to “rollover” at the provided frequency based on the value of the provided timestamp_field_path_name. #route_with(routing_field_path_name) ⇒ void Configures the index to route documents to shards based on the specified field. #runtime_metadata ⇒ SchemaArtifacts::RuntimeMetadata::IndexDefinition Runtime metadata for this index. #to_index_config ⇒ Hash Datastore configuration for this index for when it does not use rollover. #to_index_template_config ⇒ Hash Datastore configuration for the index template that will be defined if rollover is used. #uses_custom_routing? ⇒ Boolean Whether or not this index uses custom shard routing. Constructor Details #initialize(name, settings, schema_def_state, indexed_type) {|Index| ... } ⇒ Index Returns a new instance of Index. Parameters: name (String) — name of the index settings (Hash<(String, Object)>) — datastore settings for the index schema_def_state (State) — schema definition state indexed_type (SchemaElements::ObjectType, SchemaElements::InterfaceType, SchemaElements::UnionType) — type backed by this index Yields: (Index) — the index, for further customization Instance Attribute Details #default_sort_pairs ⇒ Array<(String, Symbol)> (readonly) Returns (field name, direction) pairs for the default sort. (Array<(String, Symbol)>) — (field name, direction) pairs for the default sort #indexed_type ⇒ SchemaElements::ObjectType, ... (readonly) Returns type backed by this index. (SchemaElements::ObjectType, SchemaElements::InterfaceType, SchemaElements::UnionType) — type backed by this index #name ⇒ String (readonly) Returns name of the index. (String) — name of the index #rollover_config ⇒ RolloverConfig? (readonly) Returns rollover configuration for the index. (RolloverConfig, nil) — rollover configuration for the index #routing_field_path ⇒ Array (readonly) Returns path to the field used for shard routing. (Array) — path to the field used for shard routing #schema_def_state ⇒ State (readonly) Returns schema definition state. (State) — schema definition state #settings ⇒ Hash<(String, Object)> (readonly) Returns datastore settings for the index. (Hash<(String, Object)>) — datastore settings for the index Instance Method Details #default_sort(*field_name_direction_pairs) ⇒ void Note: the field name strings can be a dot-separated nested fields, but all referenced fields must exist when this is called. This method returns an undefined value.Specifies how documents in this index should sort by default, when no orderBy argument is provided to the GraphQL query. Examples: Sort on name (ascending) with createdAt (descending) as a tie-breaker ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.field "id", "ID!" t.field "name", "String" t.field "createdAt", "DateTime" t.index "campaigns"do |i| i.default_sort "name", :asc, "createdAt", :desc end end end Parameters: field_name_direction_pairs (Array<(String, Symbol)>) — pairs of field names and :asc or :desc #rollover(frequency, timestamp_field_path_name) ⇒ void Note: the timestamp field specified here must be immutable. To understand why, consider a :yearly rollover index used for data based on createdAt; if ElasticGraph ingests record 123 with a createdAt of 2023-12-31T23:59:59Z, it will be indexed in the 2023 index. Later if it receives an update event for record 123 with a createdAt of 2024-01-01T00:00:00Z (a mere one second later!), ElasticGraph will store the new version of the payment in the 2024 index, and leave the old copy of the payment in the 2023 index unchanged. It’ll have duplicates for that document. Note: changing the rollover configuration on an existing index that already has data will result in duplicate documents This method returns an undefined value.Causes this index to “rollover” at the provided frequency based on the value of the provided timestamp_field_path_name. This is particularly useful for time-series data. Partitioning the data into hourly, daily, monthly or yearly buckets allows for different index configurations, and can be necessary when a dataset is too large to fit in one dataset given Elasticsearch/OpenSearch limitations on the number of shards in one index. In addition, ElasticGraph optimizes queries which filter on the timestamp field to target the subset of the indices in which matching documents could reside. Examples: Define a campaigns index to rollover yearly based on createdAt ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.field "id", "ID!" t.field "name", "String" t.field "createdAt", "DateTime" t.index "campaigns"do |i| i.rollover :yearly, "createdAt" end end end Parameters: frequency (:yearly, :monthly, :daily, :hourly) — how often to rollover the index timestamp_field_path_name (String) — dot-separated path to the timestamp field used for rollover. Note: all referenced fields must exist when this is called. #route_with(routing_field_path_name) ⇒ void Note: it is essential that the shards are well-balanced. If the data’s distribution is lopsided, using this feature can make performance worse. Note: the routing field specified here must be immutable. If ElasticGraph receives an updated version of a document with a different routing value, it’ll write the new version of the document to a different shard and leave the copy on the old shard unchanged, leading to duplicates. Note: changing the shard routing configuration on an existing index that already has data will result in duplicate documents This method returns an undefined value.Configures the index to route documents to shards based on the specified field. ElasticGraph optimizes queries that filter on the shard routing field so that they only run on a subset of nodes instead of all nodes. This can make a big difference in query performance if queries usually filter on a certain field. Using an appropriate field for shard routing is often essential for horizontal scaling, as it avoids having every query hit every node, allowing additional nodes to increase query throughput. Examples: Define a campaigns index to shard on organizationId ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.field "id", "ID!" t.field "name", "String" t.field "organizationId", "ID" t.index "campaigns"do |i| i.route_with "organizationId" end end end Parameters: routing_field_path_name (String) — dot-separated path to the field used for shard routing. Note: all referenced fields must exist when this is called. #runtime_metadata ⇒ SchemaArtifacts::RuntimeMetadata::IndexDefinition Returns runtime metadata for this index. (SchemaArtifacts::RuntimeMetadata::IndexDefinition) — runtime metadata for this index #to_index_config ⇒ Hash Returns datastore configuration for this index for when it does not use rollover. (Hash) — datastore configuration for this index for when it does not use rollover #to_index_template_config ⇒ Hash Returns datastore configuration for the index template that will be defined if rollover is used. (Hash) — datastore configuration for the index template that will be defined if rollover is used #uses_custom_routing? ⇒ Boolean Returns whether or not this index uses custom shard routing. (Boolean) — whether or not this index uses custom shard routing See Also: #route_with Returns a new instance of Index. Returns (field name, direction) pairs for the default sort. Returns type backed by this index. Returns name of the index. Returns rollover configuration for the index. Returns path to the field used for shard routing. Returns schema definition state. Returns datastore settings for the index. Note: the field name strings can be a dot-separated nested fields, but all referenced fields must exist when this is called. This method returns an undefined value.Specifies how documents in this index should sort by default, when no orderBy argument is provided to the GraphQL query. Note: the timestamp field specified here must be immutable. To understand why, consider a :yearly rollover index used for data based on createdAt; if ElasticGraph ingests record 123 with a createdAt of 2023-12-31T23:59:59Z, it will be indexed in the 2023 index. Later if it receives an update event for record 123 with a createdAt of 2024-01-01T00:00:00Z (a mere one second later!), ElasticGraph will store the new version of the payment in the 2024 index, and leave the old copy of the payment in the 2023 index unchanged. It’ll have duplicates for that document. Note: changing the rollover configuration on an existing index that already has data will result in duplicate documents This method returns an undefined value.Causes this index to “rollover” at the provided frequency based on the value of the provided timestamp_field_path_name. This is particularly useful for time-series data. Partitioning the data into hourly, daily, monthly or yearly buckets allows for different index configurations, and can be necessary when a dataset is too large to fit in one dataset given Elasticsearch/OpenSearch limitations on the number of shards in one index. In addition, ElasticGraph optimizes queries which filter on the timestamp field to target the subset of the indices in which matching documents could reside. Note: it is essential that the shards are well-balanced. If the data’s distribution is lopsided, using this feature can make performance worse. Note: the routing field specified here must be immutable. If ElasticGraph receives an updated version of a document with a different routing value, it’ll write the new version of the document to a different shard and leave the copy on the old shard unchanged, leading to duplicates. Note: changing the shard routing configuration on an existing index that already has data will result in duplicate documents This method returns an undefined value.Configures the index to route documents to shards based on the specified field. ElasticGraph optimizes queries that filter on the shard routing field so that they only run on a subset of nodes instead of all nodes. This can make a big difference in query performance if queries usually filter on a certain field. Using an appropriate field for shard routing is often essential for horizontal scaling, as it avoids having every query hit every node, allowing additional nodes to increase query throughput. Returns runtime metadata for this index. Returns datastore configuration for this index for when it does not use rollover. Returns datastore configuration for the index template that will be defined if rollover is used. Returns whether or not this index uses custom shard routing. ### API Documentation - Class: ElasticGraph::SchemaDefinition::Indexing::JSONSchemaFieldMetadata Index (J) » ElasticGraph » SchemaDefinition » Indexing » JSONSchemaFieldMetadata Class: ElasticGraph::SchemaDefinition::Indexing::JSONSchemaFieldMetadata Private Inherits: Data Object Data ElasticGraph::SchemaDefinition::Indexing::JSONSchemaFieldMetadata show all elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/json_schema_field_metadata.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/json_schema_field_metadata.rb Metadata about an ElasticGraph field that needs to be stored in our versioned JSON schemas alongside the JSON schema fields. Instance Attribute Summary collapse #name_in_index ⇒ String readonly Name of the field in the index. #type ⇒ String readonly Name of the ElasticGraph type for this field. Instance Method Summary collapse #to_dumpable_hash ⇒ Hash private Hash form of the metadata that can be dumped in JSON schema. Instance Attribute Details #name_in_index ⇒ String (readonly) Returns name of the field in the index. (String) — name of the field in the index #type ⇒ String (readonly) Returns name of the ElasticGraph type for this field. (String) — name of the ElasticGraph type for this field Instance Method Details #to_dumpable_hash ⇒ Hash Returns hash form of the metadata that can be dumped in JSON schema. (Hash) — hash form of the metadata that can be dumped in JSON schema Returns name of the field in the index. Returns name of the ElasticGraph type for this field. Returns hash form of the metadata that can be dumped in JSON schema. ### API Documentation - Module: ElasticGraph::SchemaDefinition::Indexing Index (I) » ElasticGraph » SchemaDefinition » Indexing Module: ElasticGraph::SchemaDefinition::Indexing elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/index.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/event_envelope.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_reference.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/enum.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/rollover_config.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/union.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/object.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/scalar.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/list_counts_mapping.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_indexed_type.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/relationship_resolver.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/update_target_factory.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/update_target_resolver.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/json_schema_with_metadata.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/json_schema_field_metadata.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_fields/append_only_set.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_fields/immutable_value.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_fields/min_or_max_value.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_fields/field_initializer_support.rb Contains schema definition logic specific to indexing (such as JSON schema and mapping generation). Defined Under Namespace Modules: DerivedFields, EventEnvelope, FieldType Classes: DerivedIndexedType, Field, FieldReference, Index, JSONSchemaFieldMetadata ### API Documentation - Module: ElasticGraph::SchemaDefinition::Mixins::CanBeGraphQLOnly Index (C) » ElasticGraph » SchemaDefinition » Mixins » CanBeGraphQLOnly Module: ElasticGraph::SchemaDefinition::Mixins::CanBeGraphQLOnly Included in: SchemaElements::EnumType, SchemaElements::ScalarType, SchemaElements::TypeWithSubfields, SchemaElements::UnionType elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/can_be_graphql_only.rb Used to indicate if a type only exists in the GraphQL schema (e.g. it has no indexing component). Instance Method Summary collapse #graphql_only(value) ⇒ void Sets whether or not this type only exists in the GraphQL schema. #graphql_only? ⇒ Boolean Whether or not this type only exists in the GraphQL schema. Instance Method Details #graphql_only(value) ⇒ void This method returns an undefined value.Sets whether or not this type only exists in the GraphQL schema Parameters: value (Boolean) — whether or not this type only exists in the GraphQL schema #graphql_only? ⇒ Boolean Returns whether or not this type only exists in the GraphQL schema. (Boolean) — whether or not this type only exists in the GraphQL schema This method returns an undefined value.Sets whether or not this type only exists in the GraphQL schema Returns whether or not this type only exists in the GraphQL schema. ### API Documentation - Module: ElasticGraph::SchemaDefinition::Mixins::HasDerivedGraphQLTypeCustomizations Index (H) » ElasticGraph » SchemaDefinition » Mixins » HasDerivedGraphQLTypeCustomizations Module: ElasticGraph::SchemaDefinition::Mixins::HasDerivedGraphQLTypeCustomizations Included in: SchemaElements::EnumType, SchemaElements::ScalarType, SchemaElements::TypeWithSubfields, SchemaElements::UnionType elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_derived_graphql_type_customizations.rb Mixin that supports the customization of derived GraphQL types. For each type you define, ElasticGraph generates a number of derived GraphQL types that are needed to facilitate the ElasticGraph Query API. Methods in this module can be used to customize those derived GraphQL types. Instance Method Summary collapse #customize_derived_type_fields(type_name, *field_names, &customization_block) ⇒ void Registers a customization block for the named fields on the named derived GraphQL type. #customize_derived_types(*type_names, &customization_block) ⇒ void Registers a customization block for the named derived graphql types. Instance Method Details #customize_derived_type_fields(type_name, *field_names, &customization_block) ⇒ void This method returns an undefined value.Registers a customization block for the named fields on the named derived GraphQL type. The provided block will get run on the named fields of the named derived GraphQL type, allowing them to be customized. Examples: Customize named fields of a derived GraphQL type ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.field "id", "ID!" t.index "campaigns" t.customize_derived_type_fields "CampaignConnection", "pageInfo", "totalEdgeCount" do |dt| # Add a `@deprecated` directive to `CampaignConnection.pageInfo` and `CampaignConnection.totalEdgeCount`. dt.directive "deprecated" end end end Parameters: type_name (String) — name of the derived type containing fields you want to customize field_names (Array) — names of the fields on the derived types that you wish to customize #customize_derived_types(*type_names, &customization_block) ⇒ void This method returns an undefined value.Registers a customization block for the named derived graphql types. The provided block will get run on the named derived GraphQL types, allowing them to be customized. Examples: Customize named derived GraphQL types ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.field "id", "ID!" t.index "campaigns" t.customize_derived_types "CampaignFilterInput", "CampaignSortOrderInput" do |dt| # Add a `@deprecated` directive to two specific derived types. dt.directive "deprecated" end end end Customize all derived GraphQL types ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.field "id", "ID!" t.index "campaigns" t.customize_derived_types :all do |dt| # Add a `@deprecated` directive to all derived types. dt.directive "deprecated" end end end Parameters: type_names (Array) — names of the derived types to customize, or :all to customize all derived types This method returns an undefined value.Registers a customization block for the named fields on the named derived GraphQL type. The provided block will get run on the named fields of the named derived GraphQL type, allowing them to be customized. This method returns an undefined value.Registers a customization block for the named derived graphql types. The provided block will get run on the named derived GraphQL types, allowing them to be customized. ### API Documentation - Module: ElasticGraph::SchemaDefinition::Mixins::HasDirectives Index (H) » ElasticGraph » SchemaDefinition » Mixins » HasDirectives Module: ElasticGraph::SchemaDefinition::Mixins::HasDirectives Included in: SchemaElements::Argument, SchemaElements::EnumType, SchemaElements::EnumValue, SchemaElements::Field, SchemaElements::ScalarType, SchemaElements::TypeWithSubfields, SchemaElements::UnionType elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_directives.rb Provides support for annotating any schema element with a GraphQL directive. Instance Method Summary collapse #directive(name, arguments = {}) ⇒ void Adds a GraphQL directive to the current schema element. #directives ⇒ Array Directives attached to this schema element. #directives_sdl(suffix_with: "", prefix_with: "") ⇒ String private Helper method designed for use by including classes to get the formatted directive SDL. Instance Method Details #directive(name, arguments = {}) ⇒ void Note: If you’re using a custom directive rather than a standard GraphQL directive like @deprecated, you’ll also need to use API#raw_sdl to define the custom directive. This method returns an undefined value.Adds a GraphQL directive to the current schema element. Examples: Add a standard GraphQL directive to a field ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.field "id", "ID" do |f| f.directive "deprecated" end end end Define a custom GraphQL directive and add it to an object type ElasticGraph.define_schema do |schema| # Define a directive we can use to annotate what system a data type comes from. schema.raw_sdl "directive @sourcedFrom(system: String!) on OBJECT" schema.object_type "Campaign" do |t| t.field "id", "ID" t.directive "sourcedFrom", system: "campaigns" end end Parameters: name (String) — name of the directive arguments (Hash) (defaults to: {}) — arguments for the directive #directives ⇒ Array Returns directives attached to this schema element. (Array) — directives attached to this schema element #directives_sdl(suffix_with: "", prefix_with: "") ⇒ String Helper method designed for use by including classes to get the formatted directive SDL. Parameters: suffix_with (String) (defaults to: "") — suffix to add on the end of the SDL prefix_with (String) (defaults to: "") — prefix to add to the beginning of the SDL (String) — SDL string for the directives Note: If you’re using a custom directive rather than a standard GraphQL directive like @deprecated, you’ll also need to use API#raw_sdl to define the custom directive. This method returns an undefined value.Adds a GraphQL directive to the current schema element. Returns directives attached to this schema element. Helper method designed for use by including classes to get the formatted directive SDL. ### API Documentation - Module: ElasticGraph::SchemaDefinition::Mixins::HasDocumentation Index (H) » ElasticGraph » SchemaDefinition » Mixins » HasDocumentation Module: ElasticGraph::SchemaDefinition::Mixins::HasDocumentation Included in: SchemaElements::Argument, SchemaElements::EnumType, SchemaElements::EnumValue, SchemaElements::Field, SchemaElements::ScalarType, SchemaElements::TypeWithSubfields, SchemaElements::UnionType elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_documentation.rb Supports GraphQL documentation. Instance Attribute Summary collapse #doc_comment ⇒ String? Current documentation string for the schema element. Instance Method Summary collapse #append_to_documentation(comment) ⇒ void Appends some additional documentation to the existing documentation string. #derived_documentation(intro, outro = nil) ⇒ String Generates a documentation string that is derived from the schema elements existing documentation. #documentation(comment) ⇒ void Sets the documentation of the schema element. #formatted_documentation ⇒ String Formats the documentation using GraphQL SDL syntax. Instance Attribute Details #doc_comment ⇒ String? Returns current documentation string for the schema element. (String, nil) — current documentation string for the schema element Instance Method Details #append_to_documentation(comment) ⇒ void This method returns an undefined value.Appends some additional documentation to the existing documentation string. Parameters: comment (String) — additional documentation #derived_documentation(intro, outro = nil) ⇒ String Generates a documentation string that is derived from the schema elements existing documentation. Parameters: intro (String) — string that goes before the schema element’s existing documentation outro (String, nil) (defaults to: nil) — string that goes after the schema element’s existing documentation (String) #documentation(comment) ⇒ void This method returns an undefined value.Sets the documentation of the schema element. Examples: Define documentation on an object type and on a field ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.documentation "A marketing campaign." t.field "id", "ID" do |f| f.documentation <<~EOS The identifier of the campaign. Note: this is randomly generated. EOS end end end Parameters: comment (String) — the documentation string #formatted_documentation ⇒ String Formats the documentation using GraphQL SDL syntax. (String) — formatted documentation string Returns current documentation string for the schema element. This method returns an undefined value.Appends some additional documentation to the existing documentation string. Generates a documentation string that is derived from the schema elements existing documentation. This method returns an undefined value.Sets the documentation of the schema element. Formats the documentation using GraphQL SDL syntax. ### API Documentation - Module: ElasticGraph::SchemaDefinition::Mixins::HasIndices Index (H) » ElasticGraph » SchemaDefinition » Mixins » HasIndices Module: ElasticGraph::SchemaDefinition::Mixins::HasIndices Included in: SchemaElements::InterfaceType, SchemaElements::ObjectType, SchemaElements::UnionType elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_indices.rb Provides APIs for defining datastore indices. Instance Method Summary collapse #derive_indexed_type_fields(name, from_id:, route_with: nil, rollover_with: nil) {|Indexing::DerivedIndexedType| ... } ⇒ void Configures the ElasticGraph indexer to derive another type from this indexed type, using the from_id field as the source of the id of the derived type, and the provided block for the definitions of the derived fields. #derived_indexed_types ⇒ Array List of derived types for this source type. #index(name, **settings) {|Indexing::Index| ... } ⇒ void Converts the current type from being an embedded type (that is, a type that is embedded within another indexed type) to an indexed type that resides in the named index definition. #indexed? ⇒ Boolean True if this type has an index. #plural_root_query_field_name ⇒ String The plural name of the entity; used for the root Query field that queries documents of this indexed type. #root_query_fields(plural:, singular: nil) {|SchemaElements::Field| ... } ⇒ void Determines what the root Query fields will be to query this indexed type. #singular_root_query_field_name ⇒ String The singular name of the entity; used for the root Query field (with an Aggregations suffix) that queries aggregations of this indexed type. Instance Method Details #derive_indexed_type_fields(name, from_id:, route_with: nil, rollover_with: nil) {|Indexing::DerivedIndexedType| ... } ⇒ void This method returns an undefined value.Configures the ElasticGraph indexer to derive another type from this indexed type, using the from_id field as the source of the id of the derived type, and the provided block for the definitions of the derived fields. Examples: Derive a Course type from StudentCourseEnrollment events ElasticGraph.define_schema do |schema| # `StudentCourseEnrollment` is a directly indexed type. schema.object_type "StudentCourseEnrollment" do |t| t.field "id", "ID" t.field "courseId", "ID" t.field "courseName", "String" t.field "studentName", "String" t.field "courseStartDate", "Date" t.index "student_course_enrollments" # Here we define how the `Course` indexed type is derived when we index `StudentCourseEnrollment` events. t.derive_indexed_type_fields "Course", from_id: "courseId" do |derive| # `derive` is an instance of `DerivedIndexedType`. derive.immutable_value "name", from: "courseName" derive.append_only_set "students", from: "studentName" derive.min_value "firstOfferedDate", from: "courseStartDate" derive.max_value "mostRecentlyOfferedDate", from: "courseStartDate" end end # `Course` is an indexed type that is derived entirely from `StudentCourseEnrollment` events. schema.object_type "Course" do |t| t.field "id", "ID" t.field "name", "String" t.field "students", "[String!]!" t.field "firstOfferedDate", "Date" t.field "mostRecentlyOfferedDate", "Date" t.index "courses" end end Parameters: name (String) — name of the derived type from_id (String) — path to the source type field with id values for the derived type route_with (String, nil) (defaults to: nil) — path to the source type field with values for shard routing on the derived type rollover_with (String, nil) (defaults to: nil) — path to the source type field with values for index rollover on the derived type Yields: (Indexing::DerivedIndexedType) — configuration object for field derivations #derived_indexed_types ⇒ Array Returns list of derived types for this source type. (Array) — list of derived types for this source type #index(name, **settings) {|Indexing::Index| ... } ⇒ void Note: Use #root_query_fields on indexed types to name the field that will be exposed on Query. Note: Indexed types must also define an id field, which ElasticGraph will use as the primary key. Note: Datastore index settings can also be defined (or overridden) in an environment-specific settings YAML file. Index settings that you want to configure differently for different environments (such as index.number_of_shards—-production and staging will probably need different numbers!) should be configured in the per-environment YAML configuration files rather than here. This method returns an undefined value.Converts the current type from being an embedded type (that is, a type that is embedded within another indexed type) to an indexed type that resides in the named index definition. Indexed types are directly indexed into the datastore, and will be queryable from the root Query type. Examples: Define a campaigns index ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.field "id", "ID" t.index( "campaigns", # Configure `index.refresh_interval`. refresh_interval: "1s", # Use `index.search` to log warnings for any search query that take more than five seconds. search: {slowlog: {level: "WARN", threshold: {query: {warn: "5s"}}}} ) do |i| # The index can be customized further here. end end end Parameters: name (String) — name of the index. See the Elasticsearch docs for restrictions. settings (Hash) — datastore index settings you want applied to every environment. See the Elasticsearch docs for a list of valid settings, but be sure to omit the index. prefix here. Yields: (Indexing::Index) — the index, so it can be customized further #indexed? ⇒ Boolean Returns true if this type has an index. (Boolean) — true if this type has an index #plural_root_query_field_name ⇒ String Returns the plural name of the entity; used for the root Query field that queries documents of this indexed type. (String) — the plural name of the entity; used for the root Query field that queries documents of this indexed type #root_query_fields(plural:, singular: nil) {|SchemaElements::Field| ... } ⇒ void This method returns an undefined value.Determines what the root Query fields will be to query this indexed type. In addition, this method accepts a block, which you can use to customize the root query field (such as adding a GraphQL directive to it). Examples: Set plural and singular names ElasticGraph.define_schema do |schema| schema.object_type "Person" do |t| t.field "id", "ID" # Results in `Query.people` and `Query.personAggregations`. t.root_query_fields plural: "people", singular: "person" t.index "people" end end Customize Query fields ElasticGraph.define_schema do |schema| schema.object_type "Person" do |t| t.field "id", "ID" t.root_query_fields plural: "people", singular: "person" do |f| # Marks `Query.people` and `Query.personAggregations` as deprecated. f.directive "deprecated" end t.index "people" end end Parameters: plural (String) — the plural name of the entity; used for the root Query field that queries documents of this indexed type singular (String, nil) (defaults to: nil) — the singular name of the entity; used for the root Query field (with an Aggregations suffix) that queries aggregations of this indexed type. If not provided, will derive it from the type name (e.g. converting it to camelCase or snake_case, depending on configuration). Yields: (SchemaElements::Field) — field on the root Query type used to query this indexed type, to support customization #singular_root_query_field_name ⇒ String Returns the singular name of the entity; used for the root Query field (with an Aggregations suffix) that queries aggregations of this indexed type. If not provided, will derive it from the type name (e.g. converting it to camelCase or snake_case, depending on configuration). (String) — the singular name of the entity; used for the root Query field (with an Aggregations suffix) that queries aggregations of this indexed type. If not provided, will derive it from the type name (e.g. converting it to camelCase or snake_case, depending on configuration). This method returns an undefined value.Configures the ElasticGraph indexer to derive another type from this indexed type, using the from_id field as the source of the id of the derived type, and the provided block for the definitions of the derived fields. Returns list of derived types for this source type. Note: Use #root_query_fields on indexed types to name the field that will be exposed on Query. Note: Indexed types must also define an id field, which ElasticGraph will use as the primary key. Note: Datastore index settings can also be defined (or overridden) in an environment-specific settings YAML file. Index settings that you want to configure differently for different environments (such as index.number_of_shards—-production and staging will probably need different numbers!) should be configured in the per-environment YAML configuration files rather than here. This method returns an undefined value.Converts the current type from being an embedded type (that is, a type that is embedded within another indexed type) to an indexed type that resides in the named index definition. Indexed types are directly indexed into the datastore, and will be queryable from the root Query type. Returns true if this type has an index. Returns the plural name of the entity; used for the root Query field that queries documents of this indexed type. This method returns an undefined value.Determines what the root Query fields will be to query this indexed type. In addition, this method accepts a block, which you can use to customize the root query field (such as adding a GraphQL directive to it). Returns the singular name of the entity; used for the root Query field (with an Aggregations suffix) that queries aggregations of this indexed type. If not provided, will derive it from the type name (e.g. converting it to camelCase or snake_case, depending on configuration). ### API Documentation - Module: ElasticGraph::SchemaDefinition::Mixins::HasTypeInfo Index (H) » ElasticGraph » SchemaDefinition » Mixins » HasTypeInfo Module: ElasticGraph::SchemaDefinition::Mixins::HasTypeInfo Included in: SchemaElements::Field, SchemaElements::ScalarType, SchemaElements::TypeWithSubfields elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_type_info.rb Mixin used to specify non-GraphQL type info (datastore index and JSON schema type info). Exists as a mixin so we can apply the same consistent API to every place we need to use this. Currently it’s used in 3 places: SchemaElements::ScalarType: allows specification of how scalars are represented in JSON schema and the index. SchemaElements::TypeWithSubfields: allows customization of how an object type is represented in JSON schema and the index. SchemaElements::Field: allows customization of a specific field over the field type’s standard JSON schema and the index mapping. Constant Summary collapse CUSTOMIZABLE_DATASTORE_PARAMS = Set of mapping parameters that it makes sense to allow customization of, based on the Elasticsearch docs. Set[ :analyzer, :eager_global_ordinals, :enabled, :fields, :format, :index, :meta, # not actually in the doc above. Added to support some `index_configurator` tests on 7.9+. :norms, :null_value, :search_analyzer, :type, ] Instance Method Summary collapse #json_schema(**options) ⇒ void Defines the JSON schema validations for this field or type. #json_schema_options ⇒ Hash JSON schema options. #mapping(**options) ⇒ void Defines the Elasticsearch/OpenSearch field mapping type and mapping parameters for a field or type. #mapping_options ⇒ Hash Datastore mapping options. Instance Method Details #json_schema(**options) ⇒ void Note: We recommend using JSON schema validations in a limited fashion. Validations that are appropriate to apply when data is entering the system-of-record are often not appropriate on a secondary index like ElasticGraph. Events that violate a JSON schema validation will fail to index (typically they will be sent to the dead letter queue and page an oncall engineer). If an ElasticGraph instance is meant to contain all the data of some source system, you probably don’t want it applying stricter validations than the source system itself has. We recommend limiting your JSON schema validations to situations where violations would prevent ElasticGraph from operating correctly. This method returns an undefined value.Defines the JSON schema validations for this field or type. Validations defined here will be included in the generated json_schemas.yaml artifact, which is used by the ElasticGraph indexer to validate events before indexing their data in the datastore. In addition, the publisher may use json_schemas.yaml for code generation and to apply validation before publishing an event to ElasticGraph. Can be called multiple times; each time, the options will be merged into the existing options. This is required on a SchemaElements::ScalarType (since we don’t know how a custom scalar type should be represented in JSON!). On a SchemaElements::Field, this is optional, but can be used to make the JSON schema validation stricter then it would otherwise be. For example, you could use json_schema maxLength: 30 on a String field to limit the length. You can use any of the JSON schema validation keywords here. In addition, nullable: false is supported to configure the generated JSON schema to disallow null values for the field. Note that if you define a field with a non-nullable GraphQL type (e.g. Int!), the JSON schema will automatically disallow nulls. However, as explained in the SchemaElements::TypeWithSubfields#field documentation, we generally recommend against defining non-nullable GraphQL fields. json_schema nullable: false will disallow null values from being indexed, while still keeping the field nullable in the GraphQL schema. If you think you might want to make a field non-nullable in the GraphQL schema some day, it’s a good idea to use json_schema nullable: false now to ensure every indexed record has a non-null value for the field. Examples: Define the JSON schema validations of a custom scalar type ElasticGraph.define_schema do |schema| schema.scalar_type "URL" do |t| t.mapping type: "keyword" # JSON schema has a built-in URI format validator: # https://json-schema.org/understanding-json-schema/reference/string.html#resource-identifiers t.json_schema type: "string", format: "uri" end end Define additional validations on a field ElasticGraph.define_schema do |schema| schema.object_type "Card" do |t| t.field "id", "ID!" t.field "expYear", "Int" do |f| # Use JSON schema to ensure the publisher is sending us 4 digit years, not 2 digit years. f.json_schema minimum: 2000, maximum: 2099 end t.field "expMonth", "Int" do |f| f.json_schema minimum: 1, maximum: 12 end t.index "cards" end end Parameters: options (Hash) — JSON schema options #json_schema_options ⇒ Hash Returns JSON schema options. (Hash) — JSON schema options #mapping(**options) ⇒ void This method returns an undefined value.Defines the Elasticsearch/OpenSearch field mapping type and mapping parameters for a field or type. The options passed here will be included in the generated datastore_config.yaml artifact that ElasticGraph uses to configure Elasticsearch/OpenSearch. Can be called multiple times; each time, the options will be merged into the existing options. This is required on a SchemaElements::ScalarType; without it, ElasticGraph would have no way to know how the datatype should be indexed in the datastore. On a SchemaElements::Field, this can be used to customize how a field is indexed. For example, String fields are normally indexed as keywords; to instead index a String field for full text search, you’d need to configure mapping type: "text". On a SchemaElements::ObjectType, this can be used to use a specific Elasticsearch/OpenSearch data type for something that is modeled as an object in GraphQL. For example, we use it for the GeoLocation type so they get indexed in Elasticsearch using the geo_point type. Examples: Define the mapping of a custom scalar type ElasticGraph.define_schema do |schema| schema.scalar_type "URL" do |t| t.mapping type: "keyword" t.json_schema type: "string", format: "uri" end end Customize the mapping of a field ElasticGraph.define_schema do |schema| schema.object_type "Card" do |t| t.field "id", "ID!" t.field "cardholderName", "String" do |f| # index this field for full text search f.mapping type: "text" end t.field "expYear", "Int" do |f| # Use a smaller numeric type to save space in the datastore f.mapping type: "short" f.json_schema minimum: 2000, maximum: 2099 end t.field "expMonth", "Int" do |f| # Use a smaller numeric type to save space in the datastore f.mapping type: "byte" f.json_schema minimum: 1, maximum: 12 end t.index "cards" end end Parameters: options (Hash) — mapping options–must be limited to CUSTOMIZABLE_DATASTORE_PARAMS #mapping_options ⇒ Hash Returns datastore mapping options. (Hash) — datastore mapping options Note: We recommend using JSON schema validations in a limited fashion. Validations that are appropriate to apply when data is entering the system-of-record are often not appropriate on a secondary index like ElasticGraph. Events that violate a JSON schema validation will fail to index (typically they will be sent to the dead letter queue and page an oncall engineer). If an ElasticGraph instance is meant to contain all the data of some source system, you probably don’t want it applying stricter validations than the source system itself has. We recommend limiting your JSON schema validations to situations where violations would prevent ElasticGraph from operating correctly. This method returns an undefined value.Defines the JSON schema validations for this field or type. Validations defined here will be included in the generated json_schemas.yaml artifact, which is used by the ElasticGraph indexer to validate events before indexing their data in the datastore. In addition, the publisher may use json_schemas.yaml for code generation and to apply validation before publishing an event to ElasticGraph. Can be called multiple times; each time, the options will be merged into the existing options. This is required on a SchemaElements::ScalarType (since we don’t know how a custom scalar type should be represented in JSON!). On a SchemaElements::Field, this is optional, but can be used to make the JSON schema validation stricter then it would otherwise be. For example, you could use json_schema maxLength: 30 on a String field to limit the length. You can use any of the JSON schema validation keywords here. In addition, nullable: false is supported to configure the generated JSON schema to disallow null values for the field. Note that if you define a field with a non-nullable GraphQL type (e.g. Int!), the JSON schema will automatically disallow nulls. However, as explained in the SchemaElements::TypeWithSubfields#field documentation, we generally recommend against defining non-nullable GraphQL fields. json_schema nullable: false will disallow null values from being indexed, while still keeping the field nullable in the GraphQL schema. If you think you might want to make a field non-nullable in the GraphQL schema some day, it’s a good idea to use json_schema nullable: false now to ensure every indexed record has a non-null value for the field. Returns JSON schema options. This method returns an undefined value.Defines the Elasticsearch/OpenSearch field mapping type and mapping parameters for a field or type. The options passed here will be included in the generated datastore_config.yaml artifact that ElasticGraph uses to configure Elasticsearch/OpenSearch. Can be called multiple times; each time, the options will be merged into the existing options. This is required on a SchemaElements::ScalarType; without it, ElasticGraph would have no way to know how the datatype should be indexed in the datastore. On a SchemaElements::Field, this can be used to customize how a field is indexed. For example, String fields are normally indexed as keywords; to instead index a String field for full text search, you’d need to configure mapping type: "text". On a SchemaElements::ObjectType, this can be used to use a specific Elasticsearch/OpenSearch data type for something that is modeled as an object in GraphQL. For example, we use it for the GeoLocation type so they get indexed in Elasticsearch using the geo_point type. Returns datastore mapping options. ### API Documentation - Module: ElasticGraph::SchemaDefinition::Mixins::ImplementsInterfaces Index (I) » ElasticGraph » SchemaDefinition » Mixins » ImplementsInterfaces Module: ElasticGraph::SchemaDefinition::Mixins::ImplementsInterfaces Included in: SchemaElements::InterfaceType, SchemaElements::ObjectType elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/implements_interfaces.rb Mixin for types that can implement interfaces (SchemaElements::ObjectType and SchemaElements::InterfaceType). Instance Method Summary collapse #implemented_interfaces ⇒ Array List of type references for the interface types implemented by this type. #implements(*interface_names) ⇒ void Declares that the current type implements the specified interface, making the current type a subtype of the interface. #to_sdl {|SchemaElements::Argument| ... } ⇒ String SDL string of the type. Instance Method Details #implemented_interfaces ⇒ Array Returns list of type references for the interface types implemented by this type. (Array) — list of type references for the interface types implemented by this type #implements(*interface_names) ⇒ void This method returns an undefined value.Declares that the current type implements the specified interface, making the current type a subtype of the interface. The current type must define all of the fields of the named interface, with the exact same field types. Examples: Implement an interface ElasticGraph.define_schema do |schema| schema.interface_type "Athlete" do |t| t.field "name", "String" t.field "team", "String" end schema.object_type "BaseballPlayer" do |t| t.implements "Athlete" t.field "name", "String" t.field "team", "String" t.field "battingAvg", "Float" end schema.object_type "BasketballPlayer" do |t| t.implements "Athlete" t.field "name", "String" t.field "team", "String" t.field "pointsPerGame", "Float" end end Parameters: interface_names (Array) — names of interface types implemented by this type #to_sdl {|SchemaElements::Argument| ... } ⇒ String Returns SDL string of the type. Yields: (SchemaElements::Argument) — an argument Yield (Boolean) — whether or not to include the argument in the generated GraphQL SDL (String) — SDL string of the type Returns list of type references for the interface types implemented by this type. This method returns an undefined value.Declares that the current type implements the specified interface, making the current type a subtype of the interface. The current type must define all of the fields of the named interface, with the exact same field types. Returns SDL string of the type. ### API Documentation - Module: ElasticGraph::SchemaDefinition::Mixins::SupportsDefaultValue Index (S) » ElasticGraph » SchemaDefinition » Mixins » SupportsDefaultValue Module: ElasticGraph::SchemaDefinition::Mixins::SupportsDefaultValue Included in: SchemaElements::Argument elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/supports_default_value.rb A mixin designed to be included in a schema element class that supports default values. Designed to be prepended so that it can hook into initialize. Instance Method Summary collapse #default(default_value) ⇒ void Used to specify the default value for this field or argument. #default_value_sdl ⇒ String Generates SDL for the default value. Instance Method Details #default(default_value) ⇒ void This method returns an undefined value.Used to specify the default value for this field or argument. Parameters: default_value (Object) — default value for this field or argument #default_value_sdl ⇒ String Generates SDL for the default value. Suitable for inclusion in the schema elememnts #to_sdl. (String) This method returns an undefined value.Used to specify the default value for this field or argument. Generates SDL for the default value. Suitable for inclusion in the schema elememnts #to_sdl. ### API Documentation - Module: ElasticGraph::SchemaDefinition::Mixins::VerifiesGraphQLName Index (V) » ElasticGraph » SchemaDefinition » Mixins » VerifiesGraphQLName Module: ElasticGraph::SchemaDefinition::Mixins::VerifiesGraphQLName Included in: SchemaElements::Argument, SchemaElements::Directive, SchemaElements::EnumType, SchemaElements::EnumValue, SchemaElements::Field, SchemaElements::ScalarType, SchemaElements::TypeWithSubfields, SchemaElements::UnionType elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/verifies_graphql_name.rb Note: This mixin is designed to be used via prepend, so it can add a constructor override that enforces Used to verify the validity of the name of GraphQL schema elements. the GraphQL name pattern as the object is built. Class Method Summary collapse .verify_name!(name) ⇒ void Raises if the provided name is invalid. Class Method Details .verify_name!(name) ⇒ void This method returns an undefined value.Raises if the provided name is invalid. Parameters: name (String) — name of GraphQL schema element Raises: (Errors::InvalidGraphQLNameError) — if the name is invalid This method returns an undefined value.Raises if the provided name is invalid. ### API Documentation - Module: ElasticGraph::SchemaDefinition::Mixins Index (M) » ElasticGraph » SchemaDefinition » Mixins Module: ElasticGraph::SchemaDefinition::Mixins elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/can_be_graphql_only.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_indices.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_subtypes.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_type_info.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_directives.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_documentation.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/implements_interfaces.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/verifies_graphql_name.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/supports_default_value.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/supports_filtering_and_aggregation.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_derived_graphql_type_customizations.rb Namespace for modules that are used as mixins. Mixins are used to offer a consistent API for schema definition features that apply to multiple types of schema elements. Defined Under Namespace Modules: CanBeGraphQLOnly, HasDerivedGraphQLTypeCustomizations, HasDirectives, HasDocumentation, HasIndices, HasTypeInfo, ImplementsInterfaces, SupportsDefaultValue, VerifiesGraphQLName ### API Documentation - Class: ElasticGraph::SchemaDefinition::RakeTasks Index (R) » ElasticGraph » SchemaDefinition » RakeTasks Class: ElasticGraph::SchemaDefinition::RakeTasks Inherits: Rake::TaskLib Object Rake::TaskLib ElasticGraph::SchemaDefinition::RakeTasks show all elasticgraph-schema_definition/lib/elastic_graph/schema_definition/rake_tasks.rb Note: Local::RakeTasks wraps this and provides additional functionality. Most users will not need to interact with this class directly. Defines rake tasks for managing artifacts generated from a schema definition. Instance Method Summary collapse #initialize(index_document_sizes:, path_to_schema:, schema_artifacts_directory:, schema_element_name_form:, schema_element_name_overrides: {}, derived_type_name_formats: {}, type_name_overrides: {}, enum_value_overrides_by_type: {}, extension_modules: [], enforce_json_schema_version: true, output: $stdout) ⇒ RakeTasks constructor A new instance of RakeTasks. Constructor Details #initialize(index_document_sizes:, path_to_schema:, schema_artifacts_directory:, schema_element_name_form:, schema_element_name_overrides: {}, derived_type_name_formats: {}, type_name_overrides: {}, enum_value_overrides_by_type: {}, extension_modules: [], enforce_json_schema_version: true, output: $stdout) ⇒ RakeTasks Returns a new instance of RakeTasks. Examples: Minimal setup with defaults ElasticGraph::SchemaDefinition::RakeTasks.new( index_document_sizes: false, path_to_schema: "config/schema.rb", schema_artifacts_directory: "config/schema/artifacts", schema_element_name_form: :camelCase ) Spell out the full names of the gt/gte/lt/lte filter operators ElasticGraph::SchemaDefinition::RakeTasks.new( index_document_sizes: false, path_to_schema: "config/schema.rb", schema_artifacts_directory: "config/schema/artifacts", schema_element_name_form: :camelCase, schema_element_name_overrides: { gt: "greaterThan", gte: "greaterThanOrEqualTo", lt: "lessThan", lte: "lessThanOrEqualTo" } ) Change the AggregatedValues type suffix to Metrics ElasticGraph::SchemaDefinition::RakeTasks.new( index_document_sizes: false, path_to_schema: "config/schema.rb", schema_artifacts_directory: "config/schema/artifacts", schema_element_name_form: :camelCase, derived_type_name_formats: {AggregatedValues: "Metrics"} ) Rename JsonSafeLong to BigInt ElasticGraph::SchemaDefinition::RakeTasks.new( index_document_sizes: false, path_to_schema: "config/schema.rb", schema_artifacts_directory: "config/schema/artifacts", schema_element_name_form: :camelCase, type_name_overrides: {JsonSafeLong: "BigInt"} ) Shorten the names of the DayOfWeek enum values ElasticGraph::SchemaDefinition::RakeTasks.new( index_document_sizes: false, path_to_schema: "config/schema.rb", schema_artifacts_directory: "config/schema/artifacts", schema_element_name_form: :camelCase, enum_value_overrides_by_type: { DayOfWeek: { MONDAY: "MON", TUESDAY: "TUE", WEDNESDAY: "WED", THURSDAY: "THU", FRIDAY: "FRI", SATURDAY: "SAT", SUNDAY: "SUN" } } ) Parameters: index_document_sizes (Boolean) — When enabled, ElasticGraph will configure the index mappings so that the datastore indexes a _size field in each document. ElasticGraph itself does not do anything with this field, but it will be available for your use in any direct queries (e.g. via Kibana). Important note: this requires the mapper-size plugin to be installed on your datastore cluster. You are responsible for ensuring that is installed if you enable this feature. If you enable this and the plugin is not installed, you will get errors! path_to_schema (String, Pathname) — path to the main (or only) schema definition file schema_artifacts_directory (String, Pathname) — Directory to dump the schema artifacts in schema_element_name_form (:camelCase, :snake_case) — the form of names for schema elements (fields, arguments, directives) generated by ElasticGraph. schema_element_name_overrides (Hash) (defaults to: {}) — overrides for specific names of schema elements (fields, arguments, directives) generated by ElasticGraph. For example, to rename the gt filter field to greaterThan, pass {gt: "greaterThan"}. derived_type_name_formats (Hash) (defaults to: {}) — overrides for the naming formats used by ElasticGraph for derived GraphQL type names. For example, to use Metrics instead of AggregatedValues as the suffix for the generated types supporting getting aggregated metrid values, pass {AggregatedValues: "%{base}Metrics"}. See SchemaElements::TypeNamer::DEFAULT_FORMATS for the available formats. type_name_overrides (Hash) (defaults to: {}) — overrides for the names of specific GraphQL types. For example, to rename the DateTime scalar to Timestamp, pass {DateTime: "Timestamp}. enum_value_overrides_by_type (Hash>) (defaults to: {}) — overrides for the names of specific enum values for specific enum types. For example, to rename the DayOfWeek.MONDAY enum to DayOfWeek.MON, pass {DayOfWeek: {MONDAY: "MON"}}. extension_modules (Array) (defaults to: []) — List of Ruby modules to extend onto the SchemaDefinition::API instance. Designed to support ElasticGraph extension gems (such as elasticgraph-apollo). enforce_json_schema_version (Boolean) (defaults to: true) — Whether or not to enforce the requirement that the JSON schema version is incremented every time dumping the JSON schemas results in a changed artifact. Generally speaking, you will want this to be true for any ElasticGraph application that is in production as the versioning of JSON schemas is what supports safe schema evolution as it allows ElasticGraph to identify which version of the JSON schema the publishing system was operating on when it published an event. It can be useful to set it to false before your application is in production, as you do not want to be forced to bump the version after every single schema change while you are building an initial prototype. output (IO) (defaults to: $stdout) — used for printing task output Returns a new instance of RakeTasks. ### API Documentation - Class: ElasticGraph::SchemaDefinition::Results Index (R) » ElasticGraph » SchemaDefinition » Results Class: ElasticGraph::SchemaDefinition::Results Inherits: Object Object ElasticGraph::SchemaDefinition::Results show all Includes: SchemaArtifacts::ArtifactsHelperMethods elasticgraph-schema_definition/lib/elastic_graph/schema_definition/results.rb Note: This class is designed to implement the same interface as ElasticGraph::SchemaArtifacts::FromDisk, so that it can be used Provides the results of defining a schema. interchangeably with schema artifacts loaded from disk. This allows the artifacts to be used in tests without having to dump them or reload them. Instance Method Summary collapse #available_json_schema_versions ⇒ Set Set of available JSON schema versions. #datastore_config ⇒ Hash The Elasticsearch/OpenSearch configuration dumped as datastore_config.yaml. #graphql_schema_string ⇒ String The generated GraphQL SDL schema string dumped as schema.graphql. #json_schemas_for(version) ⇒ Hash The JSON schema for the requested version, if available. #latest_json_schema_version ⇒ Hash The newly generated JSON schema. #runtime_metadata ⇒ Hash Runtime metadata used by other parts of ElasticGraph and dumped as runtime_metadata.yaml. Instance Method Details #available_json_schema_versions ⇒ Set Returns set of available JSON schema versions. (Set) — set of available JSON schema versions #datastore_config ⇒ Hash Returns the Elasticsearch/OpenSearch configuration dumped as datastore_config.yaml. (Hash) — the Elasticsearch/OpenSearch configuration dumped as datastore_config.yaml #graphql_schema_string ⇒ String Returns the generated GraphQL SDL schema string dumped as schema.graphql. (String) — the generated GraphQL SDL schema string dumped as schema.graphql #json_schemas_for(version) ⇒ Hash Returns the JSON schema for the requested version, if available. Parameters: version (Integer) — desired JSON schema version (Hash) — the JSON schema for the requested version, if available Raises: (Errors::NotFoundError) — if the requested JSON schema version is not available #latest_json_schema_version ⇒ Hash Returns the newly generated JSON schema. (Hash) — the newly generated JSON schema #runtime_metadata ⇒ Hash Returns runtime metadata used by other parts of ElasticGraph and dumped as runtime_metadata.yaml. (Hash) — runtime metadata used by other parts of ElasticGraph and dumped as runtime_metadata.yaml Returns set of available JSON schema versions. Returns the Elasticsearch/OpenSearch configuration dumped as datastore_config.yaml. Returns the generated GraphQL SDL schema string dumped as schema.graphql. Returns the JSON schema for the requested version, if available. Returns the newly generated JSON schema. Returns runtime metadata used by other parts of ElasticGraph and dumped as runtime_metadata.yaml. ### API Documentation - Class: ElasticGraph::SchemaDefinition::SchemaElements::Argument Index (A) » ElasticGraph » SchemaDefinition » SchemaElements » Argument Class: ElasticGraph::SchemaDefinition::SchemaElements::Argument Inherits: Struct Object Struct ElasticGraph::SchemaDefinition::SchemaElements::Argument show all Includes: Mixins::HasDirectives, Mixins::HasDocumentation, Mixins::SupportsDefaultValue, Mixins::VerifiesGraphQLName elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/argument.rb Represents a GraphQL argument. Instance Attribute Summary collapse #name ⇒ String readonly Name of the argument. #original_value_type ⇒ TypeReference readonly Type of the argument, as originally provided. #parent_field ⇒ Field readonly Field which has this argument. #schema_def_state ⇒ State readonly State of the schema. Attributes included from Mixins::HasDocumentation #doc_comment Instance Method Summary collapse #to_sdl ⇒ String GraphQL SDL form of the argument. #value_type ⇒ TypeReference When the argument type is an enum, and we’re configured with different naming for input vs output enums, we need to convert the value type to its input form. 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 verify_name! Methods included from Mixins::SupportsDefaultValue #default, #default_value_sdl Instance Attribute Details #name ⇒ String (readonly) Returns name of the argument. (String) — name of the argument #original_value_type ⇒ TypeReference (readonly) Returns type of the argument, as originally provided. (TypeReference) — type of the argument, as originally provided See Also: #value_type #parent_field ⇒ Field (readonly) Returns field which has this argument. (Field) — field which has this argument #schema_def_state ⇒ State (readonly) Returns state of the schema. (State) — state of the schema Instance Method Details #to_sdl ⇒ String Returns GraphQL SDL form of the argument. (String) — GraphQL SDL form of the argument #value_type ⇒ TypeReference When the argument type is an enum, and we’re configured with different naming for input vs output enums, we need to convert the value type to its input form. Note that this intentionally happens lazily (rather than doing this when Argument is instantiated), because the referenced type need not exist when the argument is defined, and we may not be able to figure out if it’s an enum until the type has been defined. So, we apply this lazily. (TypeReference) — the type of the argument See Also: #original_value_type Returns name of the argument. Returns type of the argument, as originally provided. Returns field which has this argument. Returns state of the schema. Returns GraphQL SDL form of the argument. When the argument type is an enum, and we’re configured with different naming for input vs output enums, we need to convert the value type to its input form. Note that this intentionally happens lazily (rather than doing this when Argument is instantiated), because the referenced type need not exist when the argument is defined, and we may not be able to figure out if it’s an enum until the type has been defined. So, we apply this lazily. ### API Documentation - Class: ElasticGraph::SchemaDefinition::SchemaElements::BuiltInTypes Index (B) » ElasticGraph » SchemaDefinition » SchemaElements » BuiltInTypes Class: ElasticGraph::SchemaDefinition::SchemaElements::BuiltInTypes Inherits: Object Object ElasticGraph::SchemaDefinition::SchemaElements::BuiltInTypes show all elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/built_in_types.rb Defines all built-in GraphQL types provided by ElasticGraph. Scalar Types Standard GraphQL Scalars These are defined by the GraphQL spec. Boolean Represents true or false values. Float Represents signed double-precision fractional values as specified by IEEE 754. ID Represents a unique identifier that is Base64 obfuscated. It is often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as "VXNlci0xMA==") or integer (such as 4) input value will be accepted as an ID. Int Represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1. String Represents textual data as UTF-8 character sequences. This type is most often used by GraphQL to represent free-form human-readable text. Additional ElasticGraph Scalars ElasticGraph defines these additional scalar types. Cursor An opaque string value representing a specific location in a paginated connection type. Returned cursors can be passed back in the next query via the before or after arguments to continue paginating from that point. Date A date, represented as an ISO 8601 date string. DateTime A timestamp, represented as an ISO 8601 time string. JsonSafeLong A numeric type for large integer values that can serialize safely as JSON. While JSON itself has no hard limit on the size of integers, the RFC-7159 spec mentions that values outside of the range -9,007,199,254,740,991 (-(2^53) + 1) to 9,007,199,254,740,991 (2^53 - 1) may not be interopable with all JSON implementations. As it turns out, the number implementation used by JavaScript has this issue. When you parse a JSON string that contains a numeric value like 4693522397653681111, the parsed result will contain a rounded value like 4693522397653681000. While this is entirely a client-side problem, we want to preserve maximum compatibility with common client languages. Given the ubiquity of GraphiQL as a GraphQL client, we want to avoid this problem. Our solution is to support two separate types: This type (JsonSafeLong) is serialized as a number, but limits values to the safely serializable range. The LongString type supports long values that use all 64 bits, but serializes as a string rather than a number, avoiding the JavaScript compatibility problems. For more background, see the JavaScript Number.MAX_SAFE_INTEGER docs. LocalTime A local time such as "23:59:33" or "07:20:47.454" without a time zone or offset, formatted based on the partial-time portion of RFC3339. LongString A numeric type for large integer values in the inclusive range -2^63 (-9,223,372,036,854,775,808) to (2^63 - 1) (9,223,372,036,854,775,807). Note that LongString values are serialized as strings within JSON, to avoid interopability problems with JavaScript. If you want a large integer type that serializes within JSON as a number, use JsonSafeLong. TimeZone An IANA time zone identifier, such as America/Los_Angeles or UTC. For a full list of valid identifiers, see the wikipedia article. Untyped A custom scalar type that allows any type of data, including: strings numbers objects and arrays (nested as deeply as you like) booleans Note: fields of this type are effectively untyped. We recommend it only be used for parts of your schema that can’t be statically typed. Enum Types ElasticGraph defines these enum types. Most of these are intended for usage as an input argument, but they could be used as a return type in your schema if they meet your needs. DateGroupingGranularity Enumerates the supported granularities of a Date. DateGroupingTruncationUnit Enumerates the supported truncation units of a Date. DateTimeGroupingGranularity Enumerates the supported granularities of a DateTime. DateTimeGroupingTruncationUnit Enumerates the supported truncation units of a DateTime. DateTimeUnit Enumeration of DateTime units. DateUnit Enumeration of Date units. DayOfWeek Indicates the specific day of the week. DistanceUnit Enumerates the supported distance units. LocalTimeGroupingTruncationUnit Enumerates the supported truncation units of a LocalTime. LocalTimeUnit Enumeration of LocalTime units. MatchesQueryAllowedEditsPerTerm Enumeration of allowed values for the matchesQuery: {allowedEditsPerTerm: ...} filter option. Object Types ElasticGraph defines these object types. AggregationCountDetail Provides detail about an aggregation count. GeoLocation Geographic coordinates representing a location on the Earth’s surface. PageInfo Provides information about the specific fetched page. This implements the PageInfo specification from the Relay GraphQL Cursor Connections Specification. ### API Documentation - Class: ElasticGraph::SchemaDefinition::SchemaElements::Directive Index (D) » ElasticGraph » SchemaDefinition » SchemaElements » Directive Class: ElasticGraph::SchemaDefinition::SchemaElements::Directive Inherits: Data Object Data ElasticGraph::SchemaDefinition::SchemaElements::Directive show all Includes: Mixins::VerifiesGraphQLName elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/directive.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/directive.rb Represents a GraphQL directive. Instance Attribute Summary collapse #arguments ⇒ Hash readonly Directive arguments. #name ⇒ String readonly Name of the directive. Instance Method Summary collapse #duplicate_on(element) ⇒ void Duplicates this directive on another GraphQL schema element. #to_sdl ⇒ String GraphQL SDL form of the directive. Methods included from Mixins::VerifiesGraphQLName verify_name! Instance Attribute Details #arguments ⇒ Hash (readonly) Returns directive arguments. (Hash) — directive arguments #name ⇒ String (readonly) Returns name of the directive. (String) — name of the directive Instance Method Details #duplicate_on(element) ⇒ void This method returns an undefined value.Duplicates this directive on another GraphQL schema element. Parameters: element (Argument, EnumType, EnumValue, Field, ScalarType, TypeWithSubfields, UnionType) — schema element #to_sdl ⇒ String Returns GraphQL SDL form of the directive. (String) — GraphQL SDL form of the directive Returns directive arguments. Returns name of the directive. This method returns an undefined value.Duplicates this directive on another GraphQL schema element. Returns GraphQL SDL form of the directive. ### API Documentation - Class: ElasticGraph::SchemaDefinition::SchemaElements::EnumType Index (E) » ElasticGraph » SchemaDefinition » SchemaElements » EnumType Class: ElasticGraph::SchemaDefinition::SchemaElements::EnumType Inherits: Struct Object Struct ElasticGraph::SchemaDefinition::SchemaElements::EnumType show all Includes: Mixins::CanBeGraphQLOnly, Mixins::HasDerivedGraphQLTypeCustomizations, Mixins::HasDirectives, Mixins::HasDocumentation, Mixins::VerifiesGraphQLName elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/enum_type.rb Defines a GraphQL enum type. The type is restricted to an enumerated set of values, each with a unique name. Use value or values to define the enum values in the passed block. Note: if required by your configuration, this may generate a pair of Enum types (an input enum and an output enum). Examples: Define an enum type ElasticGraph.define_schema do |schema| schema.enum_type "Currency" do |t| # in the block, `t` is an EnumType t.value "USD" end end Instance Attribute Summary collapse #for_output ⇒ Boolean true if this enum is used for both input and output; false if it is for input only. #schema_def_state ⇒ State readonly State of the schema. #values_by_name ⇒ Hash readonly Map of enum values, keyed by name. Attributes included from Mixins::HasDocumentation #doc_comment Instance Method Summary collapse #aggregated_values_type ⇒ TypeReference Reference to AggregatedValues type to use for this enum. #as_input ⇒ EnumType Converts the enum type to its input form for when different naming is used for input vs output enums. #indexed? ⇒ false Enum types are never directly indexed. #name ⇒ String Name of the enum type. #runtime_metadata ⇒ SchemaArtifacts::RuntimeMetadata::Enum::Type Runtime metadata for this enum type. #to_indexing_field_type ⇒ Indexing::FieldType::Enum Indexing representation of this enum type. #to_sdl ⇒ String GraphQL SDL form of the enum type. #value(value_name) {|EnumValue| ... } ⇒ void Defines an enum value for the current enum type. #values(*value_names) ⇒ void Defines multiple enum values. Methods included from Mixins::HasDerivedGraphQLTypeCustomizations #customize_derived_type_fields, #customize_derived_types 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::CanBeGraphQLOnly #graphql_only, #graphql_only? Methods included from Mixins::VerifiesGraphQLName verify_name! Instance Attribute Details #for_output ⇒ Boolean Returns true if this enum is used for both input and output; false if it is for input only. (Boolean) — true if this enum is used for both input and output; false if it is for input only #schema_def_state ⇒ State (readonly) Returns state of the schema. (State) — state of the schema #values_by_name ⇒ Hash (readonly) Returns map of enum values, keyed by name. (Hash) — map of enum values, keyed by name Instance Method Details #aggregated_values_type ⇒ TypeReference Returns reference to AggregatedValues type to use for this enum. (TypeReference) — reference to AggregatedValues type to use for this enum. #as_input ⇒ EnumType Returns converts the enum type to its input form for when different naming is used for input vs output enums. (EnumType) — converts the enum type to its input form for when different naming is used for input vs output enums. #indexed? ⇒ false Returns enum types are never directly indexed. (false) — enum types are never directly indexed #name ⇒ String Returns name of the enum type. (String) — name of the enum type #runtime_metadata ⇒ SchemaArtifacts::RuntimeMetadata::Enum::Type Returns runtime metadata for this enum type. (SchemaArtifacts::RuntimeMetadata::Enum::Type) — runtime metadata for this enum type #to_indexing_field_type ⇒ Indexing::FieldType::Enum Returns indexing representation of this enum type. (Indexing::FieldType::Enum) — indexing representation of this enum type #to_sdl ⇒ String Returns GraphQL SDL form of the enum type. (String) — GraphQL SDL form of the enum type #value(value_name) {|EnumValue| ... } ⇒ void This method returns an undefined value.Defines an enum value for the current enum type. Examples: Define an enum type with multiple enum values ElasticGraph.define_schema do |schema| schema.enum_type "Currency" do |t| t.value "USD" do |v| v.documentation "US Dollars." end t.value "JPY" do |v| v.documentation "Japanese Yen." end end end Parameters: value_name (String) — name of the enum value Yields: (EnumValue) — enum value so it can be further customized #values(*value_names) ⇒ void This method returns an undefined value.Defines multiple enum values. In contrast to #value, the enum values cannot be customized further via a block. Examples: Define an enum type with multiple enum values ElasticGraph.define_schema do |schema| schema.enum_type "Currency" do |t| t.values "USD", "JPY", "CAD", "GBP" end end Parameters: value_names (Array) — names of the enum values Returns true if this enum is used for both input and output; false if it is for input only. Returns state of the schema. Returns map of enum values, keyed by name. Returns reference to AggregatedValues type to use for this enum. Returns converts the enum type to its input form for when different naming is used for input vs output enums. Returns enum types are never directly indexed. Returns name of the enum type. Returns runtime metadata for this enum type. Returns indexing representation of this enum type. Returns GraphQL SDL form of the enum type. This method returns an undefined value.Defines an enum value for the current enum type. This method returns an undefined value.Defines multiple enum values. In contrast to #value, the enum values cannot be customized further via a block. ### API Documentation - Class: ElasticGraph::SchemaDefinition::SchemaElements::EnumValue Index (E) » ElasticGraph » SchemaDefinition » SchemaElements » EnumValue Class: ElasticGraph::SchemaDefinition::SchemaElements::EnumValue Inherits: Struct Object Struct ElasticGraph::SchemaDefinition::SchemaElements::EnumValue show all Includes: Mixins::HasDirectives, Mixins::HasDocumentation, Mixins::VerifiesGraphQLName elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/enum_value.rb Represents a value of a GraphQL enum type. Direct Known Subclasses SortOrderEnumValue Instance Attribute Summary collapse #name ⇒ String readonly Name of the value. #runtime_metadata ⇒ SchemaElements::RuntimeMetadata::Enum::Value readonly Runtime metadata. #schema_def_state ⇒ State readonly State of the schema. Attributes included from Mixins::HasDocumentation #doc_comment Instance Method Summary collapse #duplicate_on(other_enum_type) ⇒ void Duplicates this enum value on another EnumType. #to_sdl ⇒ String GraphQL SDL form of the enum value. #update_runtime_metadata(**updates) ⇒ void Updates the runtime metadata. 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 verify_name! Instance Attribute Details #name ⇒ String (readonly) Returns name of the value. (String) — name of the value #runtime_metadata ⇒ SchemaElements::RuntimeMetadata::Enum::Value (readonly) Returns runtime metadata. (SchemaElements::RuntimeMetadata::Enum::Value) — runtime metadata #schema_def_state ⇒ State (readonly) Returns state of the schema. (State) — state of the schema Instance Method Details #duplicate_on(other_enum_type) ⇒ void This method returns an undefined value.Duplicates this enum value on another ElasticGraph::SchemaDefinition::SchemaElements::EnumType. Parameters: other_enum_type (EnumType) — enum type to duplicate this value onto #to_sdl ⇒ String Returns GraphQL SDL form of the enum value. (String) — GraphQL SDL form of the enum value #update_runtime_metadata(**updates) ⇒ void This method returns an undefined value.Updates the runtime metadata. Parameters: updates (Hash) — to apply to the runtime metadata Returns name of the value. Returns runtime metadata. Returns state of the schema. This method returns an undefined value.Duplicates this enum value on another ElasticGraph::SchemaDefinition::SchemaElements::EnumType. Returns GraphQL SDL form of the enum value. This method returns an undefined value.Updates the runtime metadata. ### API Documentation - Class: ElasticGraph::SchemaDefinition::SchemaElements::Field Index (F) » ElasticGraph » SchemaDefinition » SchemaElements » Field Class: ElasticGraph::SchemaDefinition::SchemaElements::Field Inherits: Struct Object Struct ElasticGraph::SchemaDefinition::SchemaElements::Field show all Includes: Mixins::HasDirectives, Mixins::HasDocumentation, Mixins::HasTypeInfo, Mixins::VerifiesGraphQLName elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/field.rb Represents a GraphQL field. Examples: Define a GraphQL field ElasticGraph.define_schema do |schema| schema.object_type "Widget" do |t| t.field "id", "ID" do |f| # `f` in this block is a Field object end end end Direct Known Subclasses Relationship Constant Summary Constants included from Mixins::HasTypeInfo Mixins::HasTypeInfo::CUSTOMIZABLE_DATASTORE_PARAMS Instance Attribute Summary collapse #graphql_only ⇒ Boolean readonly True if this field exists only in the GraphQL schema and is not indexed. #name ⇒ String readonly Name of the field. #name_in_index ⇒ String readonly The name of this field in the datastore index. #schema_def_state ⇒ State readonly Schema definition state. Attributes included from Mixins::HasDocumentation #doc_comment Instance Method Summary collapse #aggregatable? ⇒ Boolean Indicates if this field is aggregatable. #argument(name, value_type) {|Argument| ... } ⇒ Object Defines an argument on the field. #customize_aggregated_values_field {|Field| ... } ⇒ void Registers a customization callback that will be applied to the corresponding aggregatedValues field that will be generated for this field. #customize_filter_field {|Field| ... } ⇒ void Registers a customization callback that will be applied to the corresponding filtering field that will be generated for this field. #customize_grouped_by_field {|Field| ... } ⇒ void Registers a customization callback that will be applied to the corresponding groupedBy field that will be generated for this field. #customize_sort_order_enum_values {|SortOrderEnumValue| ... } ⇒ void Registers a customization callback that will be applied to the corresponding enum values that will be generated for this field on the derived SortOrder enum type. #customize_sub_aggregations_field {|Field| ... } ⇒ void a corresponding field will be created on the *AggregationSubAggregations type derived from the parent object type. #filterable? ⇒ Boolean Indicates if this field is filterable. #groupable? ⇒ Boolean Indicates if this field is groupable. #json_schema(nullable: nil, **options) ⇒ void Defines the JSON schema validations for this field or type. #mapping_type ⇒ String The index mapping type in effect for this field. #on_each_generated_schema_element {|Field, EnumValue| ... } ⇒ void When you define a Field on an ObjectType or InterfaceType, ElasticGraph generates up to 6 different GraphQL schema elements for it:. #renamed_from(old_name) ⇒ void Registers an old name that this field used to have in a prior version of the schema. #sortable? ⇒ Boolean Indicates if this field is sortable. #sourced_from(relationship, field_path) ⇒ void Configures ElasticGraph to source a field’s value from a related object. #sub_aggregatable? ⇒ Boolean Indicates if this field can be used as the basis for a sub-aggregation. #type ⇒ TypeReference The type of this field. Methods included from Mixins::HasTypeInfo #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 verify_name! Instance Attribute Details #graphql_only ⇒ Boolean (readonly) Returns true if this field exists only in the GraphQL schema and is not indexed. (Boolean) — true if this field exists only in the GraphQL schema and is not indexed #name ⇒ String (readonly) Returns name of the field. (String) — name of the field #name_in_index ⇒ String (readonly) Returns the name of this field in the datastore index. (String) — the name of this field in the datastore index #schema_def_state ⇒ State (readonly) Returns schema definition state. (State) — schema definition state Instance Method Details #aggregatable? ⇒ Boolean Indicates if this field is aggregatable. Aggregatable fields will be available under aggregatedValues for an aggregations query. Aggregatability is inferred based on the field type and mapping type, or you can use the aggregatable: true option to force it. (Boolean) #argument(name, value_type) {|Argument| ... } ⇒ Object Note: ElasticGraph takes care of defining arguments for all the query features it supports, so there is generally no need to use this API, and it has no way to interpret arbitrary arguments defined on a field. However, it can be useful for extensions that extend the GraphQL query engine. For example, Apollo uses this API to satisfy the Apollo federation subgraph spec. Defines an argument on the field. Examples: Define an argument on a field ElasticGraph.define_schema do |schema| schema.object_type "Product" do |t| t.field "name", "String" do |f| f.argument "language", "String" end end end Parameters: name (String) — name of the argument value_type (String) — type of the argument in GraphQL SDL syntax Yields: (Argument) — for further customization #customize_aggregated_values_field {|Field| ... } ⇒ void Note: For each field defined in your schema that is aggregatable, a corresponding aggregatedValues field will be created on the *AggregatedValues type derived from the parent object type. This method returns an undefined value.Registers a customization callback that will be applied to the corresponding aggregatedValues field that will be generated for this field. Examples: Mark CampaignAggregatedValues.adImpressions with @deprecated ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.field "id", "ID" t.field "adImpressions", "Int" do |f| f.customize_aggregated_values_field do |avf| avf.directive "deprecated" end end t.index "campaigns" end end Yields: (Field) — derived aggregated values field See Also: #customize_filter_field #customize_grouped_by_field #customize_sort_order_enum_values #customize_sub_aggregations_field #on_each_generated_schema_element #customize_filter_field {|Field| ... } ⇒ void Note: For each field defined in your schema that is filterable, a corresponding filtering field will be created on the *FilterInput type derived from the parent object type. This method returns an undefined value.Registers a customization callback that will be applied to the corresponding filtering field that will be generated for this field. Examples: Mark CampaignFilterInput.organizationId with @deprecated ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.field "id", "ID" t.field "organizationId", "ID" do |f| f.customize_filter_field do |ff| ff.directive "deprecated" end end t.index "campaigns" end end Yields: (Field) — derived filtering field See Also: #customize_aggregated_values_field #customize_grouped_by_field #customize_sort_order_enum_values #customize_sub_aggregations_field #on_each_generated_schema_element #customize_grouped_by_field {|Field| ... } ⇒ void Note: For each field defined in your schema that is groupable, a corresponding groupedBy field will be created on the *AggregationGroupedBy type derived from the parent object type. This method returns an undefined value.Registers a customization callback that will be applied to the corresponding groupedBy field that will be generated for this field. Examples: Mark CampaignGroupedBy.organizationId with @deprecated ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.field "id", "ID" t.field "organizationId", "ID" do |f| f.customize_grouped_by_field do |gbf| gbf.directive "deprecated" end end t.index "campaigns" end end Yields: (Field) — derived grouped by field See Also: #customize_aggregated_values_field #customize_filter_field #customize_sort_order_enum_values #customize_sub_aggregations_field #on_each_generated_schema_element #customize_sort_order_enum_values {|SortOrderEnumValue| ... } ⇒ void Note: for each sortable field, enum values will be generated on the derived sort order enum type allowing you to sort by the field ASC or DESC. This method returns an undefined value.Registers a customization callback that will be applied to the corresponding enum values that will be generated for this field on the derived SortOrder enum type. Examples: Mark CampaignSortOrder.organizationId_(ASC|DESC) with @deprecated ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.field "id", "ID" t.field "organizationId", "ID" do |f| f.customize_sort_order_enum_values do |soev| soev.directive "deprecated" end end t.index "campaigns" end end Yields: (SortOrderEnumValue) — derived sort order enum value See Also: #customize_aggregated_values_field #customize_filter_field #customize_grouped_by_field #customize_sub_aggregations_field #on_each_generated_schema_element #customize_sub_aggregations_field {|Field| ... } ⇒ void Note: For each field defined in your schema that is sub-aggregatable (e.g. list fields indexed using the nested mapping type), This method returns an undefined value.a corresponding field will be created on the *AggregationSubAggregations type derived from the parent object type. Registers a customization callback that will be applied to the corresponding subAggregations field that will be generated for this field. Examples: Mark TransactionAggregationSubAggregations.fees with @deprecated ElasticGraph.define_schema do |schema| schema.object_type "Transaction" do |t| t.field "id", "ID" t.field "fees", "[Money!]!" do |f| f.mapping type: "nested" f.customize_sub_aggregations_field do |saf| # Adds a `@deprecated` directive to the `PaymentAggregationSubAggregations.fees` # field without also adding it to the `Payment.fees` field. saf.directive "deprecated" end end t.index "transactions" end schema.object_type "Money" do |t| t.field "amount", "Int" t.field "currency", "String" end end Yields: (Field) — derived sub-aggregations field See Also: #customize_aggregated_values_field #customize_filter_field #customize_grouped_by_field #customize_sort_order_enum_values #on_each_generated_schema_element #filterable? ⇒ Boolean Indicates if this field is filterable. Filterable fields will be available in the GraphQL schema under the filter argument. Most fields are filterable, except when: It’s a relation. Relation fields require us to load the related data from another index and can’t be filtered on. The field is an object type that isn’t itself filterable (e.g. due to having no filterable fields or whatever). Explicitly disabled with filterable: false. (Boolean) #groupable? ⇒ Boolean Indicates if this field is groupable. Groupable fields will be available under groupedBy for an aggregations query. Groupability is inferred based on the field type and mapping type, or you can use the groupable: true option to force it. (Boolean) #json_schema(nullable: nil, **options) ⇒ void Note: We recommend using JSON schema validations in a limited fashion. Validations that are appropriate to apply when data is entering the system-of-record are often not appropriate on a secondary index like ElasticGraph. Events that violate a JSON schema validation will fail to index (typically they will be sent to the dead letter queue and page an oncall engineer). If an ElasticGraph instance is meant to contain all the data of some source system, you probably don’t want it applying stricter validations than the source system itself has. We recommend limiting your JSON schema validations to situations where violations would prevent ElasticGraph from operating correctly. This method returns an undefined value.Defines the JSON schema validations for this field or type. Validations defined here will be included in the generated json_schemas.yaml artifact, which is used by the ElasticGraph indexer to validate events before indexing their data in the datastore. In addition, the publisher may use json_schemas.yaml for code generation and to apply validation before publishing an event to ElasticGraph. Can be called multiple times; each time, the options will be merged into the existing options. This is required on a ScalarType (since we don’t know how a custom scalar type should be represented in JSON!). On a ElasticGraph::SchemaDefinition::SchemaElements::Field, this is optional, but can be used to make the JSON schema validation stricter then it would otherwise be. For example, you could use json_schema maxLength: 30 on a String field to limit the length. You can use any of the JSON schema validation keywords here. In addition, nullable: false is supported to configure the generated JSON schema to disallow null values for the field. Note that if you define a field with a non-nullable GraphQL type (e.g. Int!), the JSON schema will automatically disallow nulls. However, as explained in the TypeWithSubfields#field documentation, we generally recommend against defining non-nullable GraphQL fields. json_schema nullable: false will disallow null values from being indexed, while still keeping the field nullable in the GraphQL schema. If you think you might want to make a field non-nullable in the GraphQL schema some day, it’s a good idea to use json_schema nullable: false now to ensure every indexed record has a non-null value for the field. Examples: Define the JSON schema validations of a custom scalar type ElasticGraph.define_schema do |schema| schema.scalar_type "URL" do |t| t.mapping type: "keyword" # JSON schema has a built-in URI format validator: # https://json-schema.org/understanding-json-schema/reference/string.html#resource-identifiers t.json_schema type: "string", format: "uri" end end Define additional validations on a field ElasticGraph.define_schema do |schema| schema.object_type "Card" do |t| t.field "id", "ID!" t.field "expYear", "Int" do |f| # Use JSON schema to ensure the publisher is sending us 4 digit years, not 2 digit years. f.json_schema minimum: 2000, maximum: 2099 end t.field "expMonth", "Int" do |f| f.json_schema minimum: 1, maximum: 12 end t.index "cards" end end Parameters: options (Hash) — JSON schema options #mapping_type ⇒ String The index mapping type in effect for this field. This could come from either the field definition or from the type definition. (String) #on_each_generated_schema_element {|Field, EnumValue| ... } ⇒ void This method returns an undefined value.When you define a ElasticGraph::SchemaDefinition::SchemaElements::Field on an ObjectType or InterfaceType, ElasticGraph generates up to 6 different GraphQL schema elements for it: A ElasticGraph::SchemaDefinition::SchemaElements::Field is generated on the parent ObjectType or InterfaceType (that is, this field itself). This is used by clients to ask for values for the field in a response. A ElasticGraph::SchemaDefinition::SchemaElements::Field may be generated on the *FilterInput InputType derived from the parent ObjectType or InterfaceType. This is used by clients to specify how the query should filter. A ElasticGraph::SchemaDefinition::SchemaElements::Field may be generated on the *AggregationGroupedBy ObjectType derived from the parent ObjectType or InterfaceType. This is used by clients to specify how aggregations should be grouped. A ElasticGraph::SchemaDefinition::SchemaElements::Field may be generated on the *AggregatedValues ObjectType derived from the parent ObjectType or InterfaceType. This is used by clients to apply aggregation functions (e.g. sum, max, min, etc) to a set of field values for a group. A ElasticGraph::SchemaDefinition::SchemaElements::Field may be generated on the *AggregationSubAggregations ObjectType derived from the parent ObjectType or InterfaceType. This is used by clients to perform sub-aggregations on list fields indexed using the nested mapping type. Multiple EnumValues (both *_ASC and *_DESC) are generated on the *SortOrder EnumType derived from the parent indexed ObjectType. This is used by clients to sort by a field. This method registers a customization callback which is applied to every element that is generated for this field. Examples: ElasticGraph.define_schema do |schema| schema.object_type "Transaction" do |t| t.field "id", "ID" t.field "amount", "Int" do |f| f.on_each_generated_schema_element do |element| # Adds a `@deprecated` directive to every GraphQL schema element generated for `amount`: # # - The `Transaction.amount` field. # - The `TransactionFilterInput.amount` field. # - The `TransactionAggregationGroupedBy.amount` field. # - The `TransactionAggregatedValues.amount` field. # - The `TransactionSortOrder.amount_ASC` and`TransactionSortOrder.amount_DESC` enum values. element.directive "deprecated" end end t.index "transactions" end end Yields: (Field, EnumValue) — the schema element See Also: #customize_aggregated_values_field #customize_filter_field #customize_grouped_by_field #customize_sort_order_enum_values #customize_sub_aggregations_field #renamed_from(old_name) ⇒ void Note: In situations where this API applies, ElasticGraph will give you an error message indicating that you need to use this API or TypeWithSubfields#deleted_field. Likewise, when ElasticGraph no longer needs to know about this, it’ll give you a warning indicating the call to this method can be removed. This method returns an undefined value.Registers an old name that this field used to have in a prior version of the schema. Examples: Indicate that Widget.description used to be called Widget.notes. ElasticGraph.define_schema do |schema| schema.object_type "Widget" do |t| t.field "description", "String" do |f| f.renamed_from "notes" end end end Parameters: old_name (String) — old name this field used to have in a prior version of the schema #sortable? ⇒ Boolean Indicates if this field is sortable. Sortable fields will have corresponding _ASC and _DESC values generated in the sort order EnumType of the parent indexed type. By default, the sortability is inferred by the field type and mapping. For example, list fields are not sortable, and fields mapped as text are not sortable either. Fields are sortable in most other cases. The sortable: true option can be used to force a field to be sortable. (Boolean) — true if this field is sortable #sourced_from(relationship, field_path) ⇒ void This method returns an undefined value.Configures ElasticGraph to source a field’s value from a related object. This can be used to denormalize data at ingestion time to support filtering, grouping, sorting, or aggregating data on a field from a related object. Examples: Source City.currency from Country.currency ElasticGraph.define_schema do |schema| schema.object_type "Country" do |t| t.field "id", "ID" t.field "name", "String" t.field "currency", "String" t.relates_to_one "capitalCity", "City", via: "capitalCityId", dir: :out t.index "countries" end schema.object_type "City" do |t| t.field "id", "ID" t.field "name", "String" t.relates_to_one "capitalOf", "Country", via: "capitalCityId", dir: :in t.field "currency", "String" do |f| f.sourced_from "capitalOf", "currency" end t.index "cities" end end Parameters: relationship (String) — name of a relationship defined with TypeWithSubfields#relates_to_one using an inbound foreign key which contains the the field you wish to source values from field_path (String) — dot-separated path to the field on the related type containing values that should be copied to this field #sub_aggregatable? ⇒ Boolean Indicates if this field can be used as the basis for a sub-aggregation. Sub-aggregatable fields will be available under subAggregations for an aggregations query. Only nested fields, and object fields which have nested fields, can be sub-aggregated. (Boolean) #type ⇒ TypeReference Returns the type of this field. (TypeReference) — the type of this field Returns true if this field exists only in the GraphQL schema and is not indexed. Returns name of the field. Returns the name of this field in the datastore index. Returns schema definition state. Indicates if this field is aggregatable. Aggregatable fields will be available under aggregatedValues for an aggregations query. Aggregatability is inferred based on the field type and mapping type, or you can use the aggregatable: true option to force it. Note: ElasticGraph takes care of defining arguments for all the query features it supports, so there is generally no need to use this API, and it has no way to interpret arbitrary arguments defined on a field. However, it can be useful for extensions that extend the GraphQL query engine. For example, Apollo uses this API to satisfy the Apollo federation subgraph spec. Defines an argument on the field. Note: For each field defined in your schema that is aggregatable, a corresponding aggregatedValues field will be created on the *AggregatedValues type derived from the parent object type. This method returns an undefined value.Registers a customization callback that will be applied to the corresponding aggregatedValues field that will be generated for this field. Note: For each field defined in your schema that is filterable, a corresponding filtering field will be created on the *FilterInput type derived from the parent object type. This method returns an undefined value.Registers a customization callback that will be applied to the corresponding filtering field that will be generated for this field. Note: For each field defined in your schema that is groupable, a corresponding groupedBy field will be created on the *AggregationGroupedBy type derived from the parent object type. This method returns an undefined value.Registers a customization callback that will be applied to the corresponding groupedBy field that will be generated for this field. Note: for each sortable field, enum values will be generated on the derived sort order enum type allowing you to sort by the field ASC or DESC. This method returns an undefined value.Registers a customization callback that will be applied to the corresponding enum values that will be generated for this field on the derived SortOrder enum type. Note: For each field defined in your schema that is sub-aggregatable (e.g. list fields indexed using the nested mapping type), This method returns an undefined value.a corresponding field will be created on the *AggregationSubAggregations type derived from the parent object type. Registers a customization callback that will be applied to the corresponding subAggregations field that will be generated for this field. Indicates if this field is filterable. Filterable fields will be available in the GraphQL schema under the filter argument. Most fields are filterable, except when: It’s a relation. Relation fields require us to load the related data from another index and can’t be filtered on. The field is an object type that isn’t itself filterable (e.g. due to having no filterable fields or whatever). Explicitly disabled with filterable: false. Indicates if this field is groupable. Groupable fields will be available under groupedBy for an aggregations query. Groupability is inferred based on the field type and mapping type, or you can use the groupable: true option to force it. Note: We recommend using JSON schema validations in a limited fashion. Validations that are appropriate to apply when data is entering the system-of-record are often not appropriate on a secondary index like ElasticGraph. Events that violate a JSON schema validation will fail to index (typically they will be sent to the dead letter queue and page an oncall engineer). If an ElasticGraph instance is meant to contain all the data of some source system, you probably don’t want it applying stricter validations than the source system itself has. We recommend limiting your JSON schema validations to situations where violations would prevent ElasticGraph from operating correctly. This method returns an undefined value.Defines the JSON schema validations for this field or type. Validations defined here will be included in the generated json_schemas.yaml artifact, which is used by the ElasticGraph indexer to validate events before indexing their data in the datastore. In addition, the publisher may use json_schemas.yaml for code generation and to apply validation before publishing an event to ElasticGraph. Can be called multiple times; each time, the options will be merged into the existing options. This is required on a ScalarType (since we don’t know how a custom scalar type should be represented in JSON!). On a ElasticGraph::SchemaDefinition::SchemaElements::Field, this is optional, but can be used to make the JSON schema validation stricter then it would otherwise be. For example, you could use json_schema maxLength: 30 on a String field to limit the length. You can use any of the JSON schema validation keywords here. In addition, nullable: false is supported to configure the generated JSON schema to disallow null values for the field. Note that if you define a field with a non-nullable GraphQL type (e.g. Int!), the JSON schema will automatically disallow nulls. However, as explained in the TypeWithSubfields#field documentation, we generally recommend against defining non-nullable GraphQL fields. json_schema nullable: false will disallow null values from being indexed, while still keeping the field nullable in the GraphQL schema. If you think you might want to make a field non-nullable in the GraphQL schema some day, it’s a good idea to use json_schema nullable: false now to ensure every indexed record has a non-null value for the field. The index mapping type in effect for this field. This could come from either the field definition or from the type definition. This method returns an undefined value.When you define a ElasticGraph::SchemaDefinition::SchemaElements::Field on an ObjectType or InterfaceType, ElasticGraph generates up to 6 different GraphQL schema elements for it: A ElasticGraph::SchemaDefinition::SchemaElements::Field is generated on the parent ObjectType or InterfaceType (that is, this field itself). This is used by clients to ask for values for the field in a response. A ElasticGraph::SchemaDefinition::SchemaElements::Field may be generated on the *FilterInput InputType derived from the parent ObjectType or InterfaceType. This is used by clients to specify how the query should filter. A ElasticGraph::SchemaDefinition::SchemaElements::Field may be generated on the *AggregationGroupedBy ObjectType derived from the parent ObjectType or InterfaceType. This is used by clients to specify how aggregations should be grouped. A ElasticGraph::SchemaDefinition::SchemaElements::Field may be generated on the *AggregatedValues ObjectType derived from the parent ObjectType or InterfaceType. This is used by clients to apply aggregation functions (e.g. sum, max, min, etc) to a set of field values for a group. A ElasticGraph::SchemaDefinition::SchemaElements::Field may be generated on the *AggregationSubAggregations ObjectType derived from the parent ObjectType or InterfaceType. This is used by clients to perform sub-aggregations on list fields indexed using the nested mapping type. Multiple EnumValues (both *_ASC and *_DESC) are generated on the *SortOrder EnumType derived from the parent indexed ObjectType. This is used by clients to sort by a field. This method registers a customization callback which is applied to every element that is generated for this field. Note: In situations where this API applies, ElasticGraph will give you an error message indicating that you need to use this API or TypeWithSubfields#deleted_field. Likewise, when ElasticGraph no longer needs to know about this, it’ll give you a warning indicating the call to this method can be removed. This method returns an undefined value.Registers an old name that this field used to have in a prior version of the schema. Indicates if this field is sortable. Sortable fields will have corresponding _ASC and _DESC values generated in the sort order EnumType of the parent indexed type. By default, the sortability is inferred by the field type and mapping. For example, list fields are not sortable, and fields mapped as text are not sortable either. Fields are sortable in most other cases. The sortable: true option can be used to force a field to be sortable. This method returns an undefined value.Configures ElasticGraph to source a field’s value from a related object. This can be used to denormalize data at ingestion time to support filtering, grouping, sorting, or aggregating data on a field from a related object. Indicates if this field can be used as the basis for a sub-aggregation. Sub-aggregatable fields will be available under subAggregations for an aggregations query. Only nested fields, and object fields which have nested fields, can be sub-aggregated. Returns the type of this field. ### API Documentation - Class: ElasticGraph::SchemaDefinition::SchemaElements::InterfaceType Index (I) » ElasticGraph » SchemaDefinition » SchemaElements » InterfaceType Class: ElasticGraph::SchemaDefinition::SchemaElements::InterfaceType Inherits: TypeWithSubfields Object Struct TypeWithSubfields ElasticGraph::SchemaDefinition::SchemaElements::InterfaceType show all Includes: Mixins::HasIndices, Mixins::ImplementsInterfaces elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/interface_type.rb Defines a GraphQL interface. Use it to define an abstract supertype with one or more fields that concrete implementations of the interface must also define. Each implementation can be an ObjectType or InterfaceType. Examples: Define an interface ElasticGraph.define_schema do |schema| schema.interface_type "Athlete" do |t| # in the block, `t` is an InterfaceType end end Constant Summary Constants included from Mixins::HasTypeInfo Mixins::HasTypeInfo::CUSTOMIZABLE_DATASTORE_PARAMS Instance Attribute Summary Attributes included from Mixins::HasDocumentation #doc_comment Method Summary Methods included from Mixins::HasIndices #derive_indexed_type_fields, #derived_indexed_types, #index, #indexed?, #plural_root_query_field_name, #root_query_fields, #singular_root_query_field_name Methods included from Mixins::ImplementsInterfaces #implemented_interfaces, #implements, #to_sdl Methods inherited from TypeWithSubfields #deleted_field, #field, #name, #paginated_collection_field, #relates_to_many, #relates_to_one, #renamed_from Methods included from Mixins::HasTypeInfo #json_schema, #json_schema_options, #mapping, #mapping_options Methods included from Mixins::HasDerivedGraphQLTypeCustomizations #customize_derived_type_fields, #customize_derived_types 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::CanBeGraphQLOnly #graphql_only, #graphql_only? Methods included from Mixins::VerifiesGraphQLName verify_name! ### API Documentation - Class: ElasticGraph::SchemaDefinition::SchemaElements::ObjectType Index (O) » ElasticGraph » SchemaDefinition » SchemaElements » ObjectType Class: ElasticGraph::SchemaDefinition::SchemaElements::ObjectType Inherits: TypeWithSubfields Object Struct TypeWithSubfields ElasticGraph::SchemaDefinition::SchemaElements::ObjectType show all Includes: Mixins::HasIndices, Mixins::ImplementsInterfaces elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/object_type.rb Defines a GraphQL object type Use it to define a concrete type that has subfields. Object types can either be indexed (e.g. directly indexed in the datastore, and available to query from the root Query object) or embedded in other indexed types. Examples: Define an object type ElasticGraph.define_schema do |schema| schema.object_type "Money" do |t| # in the block, `t` is an ObjectType end end Constant Summary Constants included from Mixins::HasTypeInfo Mixins::HasTypeInfo::CUSTOMIZABLE_DATASTORE_PARAMS Instance Attribute Summary Attributes included from Mixins::HasDocumentation #doc_comment Method Summary Methods included from Mixins::ImplementsInterfaces #implemented_interfaces, #implements, #to_sdl Methods included from Mixins::HasIndices #derive_indexed_type_fields, #derived_indexed_types, #index, #indexed?, #plural_root_query_field_name, #root_query_fields, #singular_root_query_field_name Methods inherited from TypeWithSubfields #deleted_field, #field, #name, #paginated_collection_field, #relates_to_many, #relates_to_one, #renamed_from Methods included from Mixins::HasTypeInfo #json_schema, #json_schema_options, #mapping, #mapping_options Methods included from Mixins::HasDerivedGraphQLTypeCustomizations #customize_derived_type_fields, #customize_derived_types 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::CanBeGraphQLOnly #graphql_only, #graphql_only? Methods included from Mixins::VerifiesGraphQLName verify_name! ### API Documentation - Class: ElasticGraph::SchemaDefinition::SchemaElements::Relationship Index (R) » ElasticGraph » SchemaDefinition » SchemaElements » Relationship Class: ElasticGraph::SchemaDefinition::SchemaElements::Relationship Inherits: Field Object Struct Field ElasticGraph::SchemaDefinition::SchemaElements::Relationship show all elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/relationship.rb Wraps a Field to provide additional relationship-specific functionality when defining a field via TypeWithSubfields#relates_to_one or TypeWithSubfields#relates_to_many. Examples: Define relationships between two types ElasticGraph.define_schema do |schema| schema.object_type "Orchestra" do |t| t.field "id", "ID" t.relates_to_many "musicians", "Musician", via: "orchestraId", dir: :in, singular: "musician" do |r| # In this block, `r` is a `Relationship`. end t.index "orchestras" end schema.object_type "Musician" do |t| t.field "id", "ID" t.field "instrument", "String" t.relates_to_one "orchestra", "Orchestra", via: "orchestraId", dir: :out do |r| # In this block, `r` is a `Relationship`. end t.index "musicians" end end 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 #doc_comment 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 of locally_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 verify_name! Instance Attribute Details #related_type ⇒ ObjectType, ... (readonly) Returns the type this relationship relates to. (ObjectType, InterfaceType, UnionType) — the type this relationship relates to Instance Method Details #additional_filter(filter) ⇒ void This method returns an undefined value.Adds additional filter conditions to a relationship beyond the foreign key. Examples: Define additional filter conditions on a relates_to_one relationship ElasticGraph.define_schema do |schema| schema.object_type "Orchestra" do |t| t.field "id", "ID" t.relates_to_many "musicians", "Musician", via: "orchestraId", dir: :in, singular: "musician" t.relates_to_one "firstViolin", "Musician", via: "orchestraId", dir: :in do |r| r.additional_filter isFirstViolon: true end t.index "orchestras" end schema.object_type "Musician" do |t| t.field "id", "ID" t.field "instrument", "String" t.field "isFirstViolon", "Boolean" t.relates_to_one "orchestra", "Orchestra", via: "orchestraId", dir: :out t.index "musicians" end end Parameters: filter (Hash, Hash) — additional filter conditions for this relationship #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. Examples: ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.field "id", "ID!" t.field "name", "String" t.field "createdAt", "DateTime" t.relates_to_one "launchPlan", "CampaignLaunchPlan", via: "campaignId", dir: :in do |r| r.equivalent_field "campaignCreatedAt", locally_named: "createdAt" end t.field "launchDate", "Date" do |f| f.sourced_from "launchPlan", "launchDate" end t.index "campaigns"do |i| i.rollover :yearly, "createdAt" end end schema.object_type "CampaignLaunchPlan" do |t| t.field "id", "ID" t.field "campaignId", "ID" t.field "campaignCreatedAt", "DateTime" t.field "launchDate", "Date" t.index "campaign_launch_plans" end end Parameters: path (String) — path to a routing or rollover field on the related type locally_named (String) (defaults to: path) — path on the local type to the equivalent field Returns the type this relationship relates to. This method returns an undefined value.Adds additional filter conditions to a relationship beyond the foreign key. 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. ### API Documentation - Class: ElasticGraph::SchemaDefinition::SchemaElements::ScalarType Index (S) » ElasticGraph » SchemaDefinition » SchemaElements » ScalarType Class: ElasticGraph::SchemaDefinition::SchemaElements::ScalarType Inherits: Struct Object Struct ElasticGraph::SchemaDefinition::SchemaElements::ScalarType show all Includes: Mixins::CanBeGraphQLOnly, Mixins::HasDerivedGraphQLTypeCustomizations, Mixins::HasDirectives, Mixins::HasDocumentation, Mixins::HasTypeInfo, Mixins::VerifiesGraphQLName elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/scalar_type.rb Defines a GraphQL scalar type. ElasticGraph itself uses this to define a few common scalar types (e.g. Date and DateTime), but it is also available to you to use to define your own custom scalar types. Examples: Define a scalar type ElasticGraph.define_schema do |schema| schema.scalar_type "URL" do |t| t.mapping type: "keyword" t.json_schema type: "string", format: "uri" end end Constant Summary Constants included from Mixins::HasTypeInfo Mixins::HasTypeInfo::CUSTOMIZABLE_DATASTORE_PARAMS Instance Attribute Summary collapse #schema_def_state ⇒ State readonly Schema definition state. Attributes included from Mixins::HasDocumentation #doc_comment Instance Method Summary collapse #coerce_with(adapter_name, defined_at:) ⇒ void Specifies the scalar coercion adapter that should be used for this scalar type. #mapping(**options) ⇒ void Defines the Elasticsearch/OpenSearch field mapping type and mapping parameters for a field or type. #name ⇒ String Name of the scalar type. #prepare_for_indexing_with(preparer_name, defined_at:) ⇒ void Specifies an indexing preparer that should be used for this scalar type. #to_sdl ⇒ String The GraphQL SDL form of this scalar. Methods included from Mixins::HasTypeInfo #json_schema, #json_schema_options, #mapping_options Methods included from Mixins::HasDerivedGraphQLTypeCustomizations #customize_derived_type_fields, #customize_derived_types 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::CanBeGraphQLOnly #graphql_only, #graphql_only? Methods included from Mixins::VerifiesGraphQLName verify_name! Instance Attribute Details #schema_def_state ⇒ State (readonly) Returns schema definition state. (State) — schema definition state Instance Method Details #coerce_with(adapter_name, defined_at:) ⇒ void Note: For examples of scalar coercion adapters, see ElasticGraph::GraphQL::ScalarCoercionAdapters. Note: If the defined_at require path requires any directories be put on the Ruby $LOAD_PATH, you are responsible for doing that before booting GraphQL. This method returns an undefined value.Specifies the scalar coercion adapter that should be used for this scalar type. The scalar coercion adapter is responsible for validating and coercing scalar input values, and converting scalar return values to a form suitable for JSON serialization. Examples: Register a coercion adapter ElasticGraph.define_schema do |schema| schema.scalar_type "PhoneNumber" do |t| t.mapping type: "keyword" t.json_schema type: "string", pattern: "^\\+[1-9][0-9]{1,14}$" t.coerce_with "CoercionAdapters::PhoneNumber", defined_at: "./coercion_adapters/phone_number" end end Parameters: adapter_name (String) — fully qualified Ruby class name of the adapter defined_at (String) — the require path of the adapter #mapping(**options) ⇒ void This method returns an undefined value.Defines the Elasticsearch/OpenSearch field mapping type and mapping parameters for a field or type. The options passed here will be included in the generated datastore_config.yaml artifact that ElasticGraph uses to configure Elasticsearch/OpenSearch. Can be called multiple times; each time, the options will be merged into the existing options. This is required on a ElasticGraph::SchemaDefinition::SchemaElements::ScalarType; without it, ElasticGraph would have no way to know how the datatype should be indexed in the datastore. On a Field, this can be used to customize how a field is indexed. For example, String fields are normally indexed as keywords; to instead index a String field for full text search, you’d need to configure mapping type: "text". On a ObjectType, this can be used to use a specific Elasticsearch/OpenSearch data type for something that is modeled as an object in GraphQL. For example, we use it for the GeoLocation type so they get indexed in Elasticsearch using the geo_point type. Examples: Define the mapping of a custom scalar type ElasticGraph.define_schema do |schema| schema.scalar_type "URL" do |t| t.mapping type: "keyword" t.json_schema type: "string", format: "uri" end end Customize the mapping of a field ElasticGraph.define_schema do |schema| schema.object_type "Card" do |t| t.field "id", "ID!" t.field "cardholderName", "String" do |f| # index this field for full text search f.mapping type: "text" end t.field "expYear", "Int" do |f| # Use a smaller numeric type to save space in the datastore f.mapping type: "short" f.json_schema minimum: 2000, maximum: 2099 end t.field "expMonth", "Int" do |f| # Use a smaller numeric type to save space in the datastore f.mapping type: "byte" f.json_schema minimum: 1, maximum: 12 end t.index "cards" end end Parameters: options (Hash) — mapping options–must be limited to Mixins::HasTypeInfo::CUSTOMIZABLE_DATASTORE_PARAMS #name ⇒ String Returns name of the scalar type. (String) — name of the scalar type #prepare_for_indexing_with(preparer_name, defined_at:) ⇒ void Note: For examples of scalar coercion adapters, see ElasticGraph::Indexer::IndexingPreparers. Note: If the defined_at require path requires any directories be put on the Ruby $LOAD_PATH, you are responsible for doing that before booting GraphQL. This method returns an undefined value.Specifies an indexing preparer that should be used for this scalar type. The indexing preparer is responsible for preparing scalar values before indexing them, performing any desired formatting or normalization. Examples: Register an indexing preparer ElasticGraph.define_schema do |schema| schema.scalar_type "PhoneNumber" do |t| t.mapping type: "keyword" t.json_schema type: "string", pattern: "^\\+[1-9][0-9]{1,14}$" t.prepare_for_indexing_with "IndexingPreparers::PhoneNumber", defined_at: "./indexing_preparers/phone_number" end end Parameters: preparer_name (String) — fully qualified Ruby class name of the indexing preparer defined_at (String) — the require path of the preparer #to_sdl ⇒ String Returns the GraphQL SDL form of this scalar. (String) — the GraphQL SDL form of this scalar Returns schema definition state. Note: For examples of scalar coercion adapters, see ElasticGraph::GraphQL::ScalarCoercionAdapters. Note: If the defined_at require path requires any directories be put on the Ruby $LOAD_PATH, you are responsible for doing that before booting GraphQL. This method returns an undefined value.Specifies the scalar coercion adapter that should be used for this scalar type. The scalar coercion adapter is responsible for validating and coercing scalar input values, and converting scalar return values to a form suitable for JSON serialization. This method returns an undefined value.Defines the Elasticsearch/OpenSearch field mapping type and mapping parameters for a field or type. The options passed here will be included in the generated datastore_config.yaml artifact that ElasticGraph uses to configure Elasticsearch/OpenSearch. Can be called multiple times; each time, the options will be merged into the existing options. This is required on a ElasticGraph::SchemaDefinition::SchemaElements::ScalarType; without it, ElasticGraph would have no way to know how the datatype should be indexed in the datastore. On a Field, this can be used to customize how a field is indexed. For example, String fields are normally indexed as keywords; to instead index a String field for full text search, you’d need to configure mapping type: "text". On a ObjectType, this can be used to use a specific Elasticsearch/OpenSearch data type for something that is modeled as an object in GraphQL. For example, we use it for the GeoLocation type so they get indexed in Elasticsearch using the geo_point type. Returns name of the scalar type. Note: For examples of scalar coercion adapters, see ElasticGraph::Indexer::IndexingPreparers. Note: If the defined_at require path requires any directories be put on the Ruby $LOAD_PATH, you are responsible for doing that before booting GraphQL. This method returns an undefined value.Specifies an indexing preparer that should be used for this scalar type. The indexing preparer is responsible for preparing scalar values before indexing them, performing any desired formatting or normalization. Returns the GraphQL SDL form of this scalar. ### API Documentation - Class: ElasticGraph::SchemaDefinition::SchemaElements::SortOrderEnumValue Index (S) » ElasticGraph » SchemaDefinition » SchemaElements » SortOrderEnumValue Class: ElasticGraph::SchemaDefinition::SchemaElements::SortOrderEnumValue Inherits: EnumValue Object Struct EnumValue ElasticGraph::SchemaDefinition::SchemaElements::SortOrderEnumValue show all elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/sort_order_enum_value.rb Simple wrapper around an EnumValue so that we can expose the sort_order_field_path to Field customization callbacks. Instance Attribute Summary collapse #sort_order_field_path ⇒ Array readonly Path to the field from the root of the indexed ObjectType. Attributes inherited from EnumValue #name, #runtime_metadata, #schema_def_state Attributes included from Mixins::HasDocumentation #doc_comment Method Summary Methods inherited from EnumValue #duplicate_on, #to_sdl, #update_runtime_metadata 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 verify_name! Instance Attribute Details #sort_order_field_path ⇒ Array (readonly) Returns path to the field from the root of the indexed ObjectType. (Array) — path to the field from the root of the indexed ObjectType Returns path to the field from the root of the indexed ObjectType. ### API Documentation - Class: ElasticGraph::SchemaDefinition::SchemaElements::TypeNamer Index (T) » ElasticGraph » SchemaDefinition » SchemaElements » TypeNamer Class: ElasticGraph::SchemaDefinition::SchemaElements::TypeNamer Inherits: Object Object ElasticGraph::SchemaDefinition::SchemaElements::TypeNamer show all elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/type_namer.rb Abstraction for generating derived GraphQL type names based on a collection of formats. A default set of formats is included, and overrides can be provided to customize the format we use for naming derived types. Constant Summary collapse DEFAULT_FORMATS = The default formats used for derived GraphQL type names. These formats can be customized by providing derived_type_name_formats to RakeTasks or Local::RakeTasks. (Hash) { AggregatedValues: "%{base}AggregatedValues", Aggregation: "%{base}Aggregation", Connection: "%{base}Connection", Edge: "%{base}Edge", FieldsListFilterInput: "%{base}FieldsListFilterInput", FilterInput: "%{base}FilterInput", GroupedBy: "%{base}GroupedBy", InputEnum: "%{base}Input", ListElementFilterInput: "%{base}ListElementFilterInput", ListFilterInput: "%{base}ListFilterInput", SortOrder: "%{base}SortOrder", SubAggregation: "%{parent_types}%{base}SubAggregation", SubAggregations: "%{parent_agg_type}%{field_path}SubAggregations" }.freeze ### API Documentation - Class: ElasticGraph::SchemaDefinition::SchemaElements::TypeWithSubfields Index (T) » ElasticGraph » SchemaDefinition » SchemaElements » TypeWithSubfields Class: ElasticGraph::SchemaDefinition::SchemaElements::TypeWithSubfields Abstract Inherits: Struct Object Struct ElasticGraph::SchemaDefinition::SchemaElements::TypeWithSubfields show all Includes: Mixins::CanBeGraphQLOnly, Mixins::HasDerivedGraphQLTypeCustomizations, Mixins::HasDirectives, Mixins::HasDocumentation, Mixins::HasTypeInfo, Mixins::VerifiesGraphQLName elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/type_with_subfields.rb This class is abstract. Defines common functionality for all GraphQL types that have subfields: InputType InterfaceType ObjectType Direct Known Subclasses InterfaceType, ObjectType Constant Summary Constants included from Mixins::HasTypeInfo Mixins::HasTypeInfo::CUSTOMIZABLE_DATASTORE_PARAMS Instance Attribute Summary Attributes included from Mixins::HasDocumentation #doc_comment Instance Method Summary collapse #deleted_field(field_name) ⇒ void Registers the name of a field that existed in a prior version of the schema but has been deleted. #field(name, type, graphql_only: false, indexing_only: false, **options) {|Field| ... } ⇒ void Defines a GraphQL field on this type. #name ⇒ String The name of this GraphQL type. #paginated_collection_field(name, element_type, name_in_index: name, singular: nil) {|Field| ... } ⇒ void An alternative to #field for when you have a list field that you want exposed as a paginated Relay connection rather than as a simple list. #relates_to_many(field_name, type, via:, dir:, singular:) {|Relationship| ... } ⇒ void Defines a “has many” relationship between the current indexed type and another indexed type by defining a pair of fields clients can use to navigate across indexed types in a single GraphQL query. #relates_to_one(field_name, type, via:, dir:) {|Relationship| ... } ⇒ void Defines a “has one” relationship between the current indexed type and another indexed type by defining a field clients can use to navigate across indexed types in a single GraphQL query. #renamed_from(old_name) ⇒ void Registers an old name that this type used to have in a prior version of the schema. Methods included from Mixins::HasTypeInfo #json_schema, #json_schema_options, #mapping, #mapping_options Methods included from Mixins::HasDerivedGraphQLTypeCustomizations #customize_derived_type_fields, #customize_derived_types 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::CanBeGraphQLOnly #graphql_only, #graphql_only? Methods included from Mixins::VerifiesGraphQLName verify_name! Instance Method Details #deleted_field(field_name) ⇒ void Note: In situations where this API applies, ElasticGraph will give you an error message indicating that you need to use this API or Field#renamed_from. Likewise, when ElasticGraph no longer needs to know about this, it’ll give you a warning indicating the call to this method can be removed. This method returns an undefined value.Registers the name of a field that existed in a prior version of the schema but has been deleted. Examples: Indicate that Widget.description has been deleted ElasticGraph.define_schema do |schema| schema.object_type "Widget" do |t| t.deleted_field "description" end end Parameters: field_name (String) — name of field that used to exist but has been deleted #field(name, type, graphql_only: false, indexing_only: false, **options) {|Field| ... } ⇒ void Note: Be careful about defining non-nullable fields. Changing a field’s type from non-nullable (e.g. Int!) to nullable (e.g. Int) is a breaking change for clients. Making a field non-nullable may also prevent you from applying permissioning to a field via an AuthZ layer (as such a layer would have no way to force a field value to null when for a client denied field access). Therefore, we recommend limiting your use of ! to only a few situations such as defining a type’s primary key (e.g. t.field "id", "ID!") or defining a list field (e.g. t.field "authors", "[String!]!") since empty lists already provide a “no data” representation. You can still configure the ElasticGraph indexer to require a non-null value for a field using f.json_schema nullable: false. Note: ElasticGraph’s understanding of datastore capabilities may override your configured aggregatable/filterable/groupable/sortable options. For example, a field indexed as text for full text search will not be sortable or groupable even if you pass sortable: true, groupable: true when defining the field, because text fields cannot be efficiently sorted by or grouped on. This method returns an undefined value.Defines a GraphQL field on this type. Examples: Define a field with documentation ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.field "id", "ID" do |f| f.documentation "The Campaign's identifier." end end end Omit a new field from the GraphQL schema until its data has been backfilled ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.field "id", "ID" # TODO: remove `indexing_only: true` once the data for this field has been fully backfilled t.field "endDate", "Date", indexing_only: true end end Use graphql_only to introduce a new name for an existing field ElasticGraph.define_schema do |schema| schema.object_type "Campaign" do |t| t.field "id", "ID" t.field "endOn", "Date" do |f| f.directive "deprecated", reason: "Use `endDate` instead." end # We've decided we want to call the field `endDate` instead of `endOn`, but the data # for this field is currently indexed in `endOn`, so we can use `graphql_only` and # `name_in_index` to expose the existing data under a new field name. t.field "endDate", "Date", name_in_index: "endOn", graphql_only: true end end Parameters: name (String) — name of the field type (String) — type of the field as a type reference. The named type must be one of ElasticGraph’s built-in types or a type that has been defined in your schema. graphql_only (Boolean) (defaults to: false) — if true, ElasticGraph will define the field as a GraphQL field but omit it from the indexing artifacts (json_schemas.yaml and datastore_config.yaml). This can be used along with name_in_index to support careful schema evolution. indexing_only (Boolean) (defaults to: false) — if true, ElasticGraph will define the field for indexing (in the json_schemas.yaml and datastore_config.yaml schema artifact) but will omit it from the GraphQL schema. This can be useful to begin indexing a field before you expose it in GraphQL so that you can fully backfill it first. options (Hash) — a customizable set of options Options Hash (**options): name_in_index (String) — the name of the field in the datastore index. Can be used to back a GraphQL field with a differently named field in the index. singular (String) — can be used on a list field (e.g. t.field "tags", "[String!]!", singular: "tag") to tell ElasticGraph what the singular form of a field’s name is. When provided, ElasticGraph will define a groupedBy field (using the singular form) allowing clients to group by individual values from the field. aggregatable (Boolean) — force-enables or disables the ability for aggregation queries to aggregate over this field. When not provided, ElasticGraph will infer field aggregatability based on the field’s GraphQL type and mapping type. filterable (Boolean) — force-enables or disables the ability for queries to filter by this field. When not provided, ElasticGraph will infer field filterability based on the field’s GraphQL type and mapping type. groupable (Boolean) — force-enables or disables the ability for aggregation queries to group by this field. When not provided, ElasticGraph will infer field groupability based on the field’s GraphQL type and mapping type. sortable (Boolean) — force-enables or disables the ability for queries to sort by this field. When not provided, ElasticGraph will infer field sortability based on the field’s GraphQL type and mapping type. Yields: (Field) — the field for further customization See Also: #paginated_collection_field #relates_to_many #relates_to_one #name ⇒ String Returns the name of this GraphQL type. (String) — the name of this GraphQL type #paginated_collection_field(name, element_type, name_in_index: name, singular: nil) {|Field| ... } ⇒ void Note: Bear in mind that pagination does not have much efficiency benefit in this case: all elements of the collection will be retrieved when fetching this field from the datastore. The pagination implementation will just trim down the collection before returning it. This method returns an undefined value.An alternative to #field for when you have a list field that you want exposed as a paginated Relay connection rather than as a simple list. Examples: Define Author.books as a paginated collection field ElasticGraph.define_schema do |schema| schema.object_type "Author" do |t| t.field "id", "ID" t.field "name", "String" t.paginated_collection_field "books", "String" t.index "authors" end end Parameters: name (String) — name of the field element_type (String) — name of the type of element in the collection name_in_index (String) (defaults to: name) — the name of the field in the datastore index. Can be used to back a GraphQL field with a differently named field in the index. singular (String) (defaults to: nil) — indicates what the singular form of a field’s name is. When provided, ElasticGraph will define a groupedBy field (using the singular form) allowing clients to group by individual values from the field. Yields: (Field) — the field for further customization See Also: #field #relates_to_many #relates_to_one #relates_to_many(field_name, type, via:, dir:, singular:) {|Relationship| ... } ⇒ void This method returns an undefined value.Defines a “has many” relationship between the current indexed type and another indexed type by defining a pair of fields clients can use to navigate across indexed types in a single GraphQL query. The pair of generated fields will be Relay Connection types allowing you to filter, sort, paginate, and aggregated the related data. Examples: Use relates_to_many to define Team.players and Team.playerAggregations ElasticGraph.define_schema do |schema| schema.object_type "Team" do |t| t.field "id", "ID" t.field "name", "String" t.field "homeCity", "String" t.relates_to_many "players", "Player", via: "teamId", dir: :in, singular: "player" t.index "teams" end schema.object_type "Player" do |t| t.field "id", "ID" t.field "name", "String" t.field "teamId", "ID" t.index "players" end end Parameters: field_name (String) — name of the relationship field type (String) — name of the related type via (String) — name of the foreign key field dir (:in, :out) — direction of the foreign key. Use :in for an inbound foreign key that resides on the related type and references the id of this type. Use :out for an outbound foreign key that resides on this type and references the id of the related type. singular (String) — singular form of the field_name; will be used (along with an Aggregations suffix) for the name of the generated aggregations field Yields: (Relationship) — the generated relationship fields, for further customization See Also: #field #paginated_collection_field #relates_to_one #relates_to_one(field_name, type, via:, dir:) {|Relationship| ... } ⇒ void This method returns an undefined value.Defines a “has one” relationship between the current indexed type and another indexed type by defining a field clients can use to navigate across indexed types in a single GraphQL query. Examples: Use relates_to_one to define Player.team ElasticGraph.define_schema do |schema| schema.object_type "Team" do |t| t.field "id", "ID" t.field "name", "String" t.field "homeCity", "String" t.index "teams" end schema.object_type "Player" do |t| t.field "id", "ID" t.field "name", "String" t.relates_to_one "team", "Team", via: "teamId", dir: :out t.index "players" end end Parameters: field_name (String) — name of the relationship field type (String) — name of the related type via (String) — name of the foreign key field dir (:in, :out) — direction of the foreign key. Use :in for an inbound foreign key that resides on the related type and references the id of this type. Use :out for an outbound foreign key that resides on this type and references the id of the related type. Yields: (Relationship) — the generated relationship fields, for further customization See Also: #field #relates_to_many #renamed_from(old_name) ⇒ void Note: In situations where this API applies, ElasticGraph will give you an error message indicating that you need to use this API or API#deleted_type. Likewise, when ElasticGraph no longer needs to know about this, it’ll give you a warning indicating the call to this method can be removed. This method returns an undefined value.Registers an old name that this type used to have in a prior version of the schema. Examples: Indicate that Widget used to be called Component. ElasticGraph.define_schema do |schema| schema.object_type "Widget" do |t| t.renamed_from "Component" end end Parameters: old_name (String) — old name this field used to have in a prior version of the schema Note: In situations where this API applies, ElasticGraph will give you an error message indicating that you need to use this API or Field#renamed_from. Likewise, when ElasticGraph no longer needs to know about this, it’ll give you a warning indicating the call to this method can be removed. This method returns an undefined value.Registers the name of a field that existed in a prior version of the schema but has been deleted. Note: Be careful about defining non-nullable fields. Changing a field’s type from non-nullable (e.g. Int!) to nullable (e.g. Int) is a breaking change for clients. Making a field non-nullable may also prevent you from applying permissioning to a field via an AuthZ layer (as such a layer would have no way to force a field value to null when for a client denied field access). Therefore, we recommend limiting your use of ! to only a few situations such as defining a type’s primary key (e.g. t.field "id", "ID!") or defining a list field (e.g. t.field "authors", "[String!]!") since empty lists already provide a “no data” representation. You can still configure the ElasticGraph indexer to require a non-null value for a field using f.json_schema nullable: false. Note: ElasticGraph’s understanding of datastore capabilities may override your configured aggregatable/filterable/groupable/sortable options. For example, a field indexed as text for full text search will not be sortable or groupable even if you pass sortable: true, groupable: true when defining the field, because text fields cannot be efficiently sorted by or grouped on. This method returns an undefined value.Defines a GraphQL field on this type. Returns the name of this GraphQL type. Note: Bear in mind that pagination does not have much efficiency benefit in this case: all elements of the collection will be retrieved when fetching this field from the datastore. The pagination implementation will just trim down the collection before returning it. This method returns an undefined value.An alternative to #field for when you have a list field that you want exposed as a paginated Relay connection rather than as a simple list. This method returns an undefined value.Defines a “has many” relationship between the current indexed type and another indexed type by defining a pair of fields clients can use to navigate across indexed types in a single GraphQL query. The pair of generated fields will be Relay Connection types allowing you to filter, sort, paginate, and aggregated the related data. This method returns an undefined value.Defines a “has one” relationship between the current indexed type and another indexed type by defining a field clients can use to navigate across indexed types in a single GraphQL query. Note: In situations where this API applies, ElasticGraph will give you an error message indicating that you need to use this API or API#deleted_type. Likewise, when ElasticGraph no longer needs to know about this, it’ll give you a warning indicating the call to this method can be removed. This method returns an undefined value.Registers an old name that this type used to have in a prior version of the schema. ### API Documentation - Class: ElasticGraph::SchemaDefinition::SchemaElements::UnionType Index (U) » ElasticGraph » SchemaDefinition » SchemaElements » UnionType Class: ElasticGraph::SchemaDefinition::SchemaElements::UnionType Inherits: Struct Object Struct ElasticGraph::SchemaDefinition::SchemaElements::UnionType show all Includes: Mixins::CanBeGraphQLOnly, Mixins::HasDerivedGraphQLTypeCustomizations, Mixins::HasDirectives, Mixins::HasDocumentation, Mixins::HasIndices, Mixins::VerifiesGraphQLName elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/union_type.rb Defines a GraphQL union type. Use it to define an abstract supertype with one or more concrete subtypes. Each subtype must be an ObjectType, but they do not have to share any fields in common. Examples: Define a union type ElasticGraph.define_schema do |schema| schema.object_type "Card" do |t| # ... end schema.object_type "BankAccount" do |t| # ... end schema.object_type "BitcoinWallet" do |t| # ... end schema.union_type "FundingSource" do |t| t.subtype "Card" t.subtypes "BankAccount", "BitcoinWallet" end end Instance Attribute Summary collapse #schema_def_state ⇒ State readonly State of the schema. Attributes included from Mixins::HasDocumentation #doc_comment Instance Method Summary collapse #name ⇒ String The name of the union type. #subtype(name) ⇒ void Defines a subtype of this union type. #subtypes(*names) ⇒ void Defines multiple subtypes of this union type. #to_sdl ⇒ String The formatted GraphQL SDL of the union type. Methods included from Mixins::HasDerivedGraphQLTypeCustomizations #customize_derived_type_fields, #customize_derived_types Methods included from Mixins::HasIndices #derive_indexed_type_fields, #derived_indexed_types, #index, #indexed?, #plural_root_query_field_name, #root_query_fields, #singular_root_query_field_name 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::CanBeGraphQLOnly #graphql_only, #graphql_only? Methods included from Mixins::VerifiesGraphQLName verify_name! Instance Attribute Details #schema_def_state ⇒ State (readonly) Returns state of the schema. (State) — state of the schema Instance Method Details #name ⇒ String Returns the name of the union type. (String) — the name of the union type #subtype(name) ⇒ void This method returns an undefined value.Defines a subtype of this union type. Examples: ElasticGraph.define_schema do |schema| schema.object_type "Card" do |t| # ... end schema.union_type "FundingSource" do |t| t.subtype "Card" end end Parameters: name (String) — the name of an object type which is a member of this union type #subtypes(*names) ⇒ void This method returns an undefined value.Defines multiple subtypes of this union type. Examples: Define a union type ElasticGraph.define_schema do |schema| schema.object_type "BankAccount" do |t| # ... end schema.object_type "BitcoinWallet" do |t| # ... end schema.union_type "FundingSource" do |t| t.subtypes "BankAccount", "BitcoinWallet" end end Parameters: names (Array) — names of object types which are members of this union type #to_sdl ⇒ String Returns the formatted GraphQL SDL of the union type. (String) — the formatted GraphQL SDL of the union type Returns state of the schema. Returns the name of the union type. This method returns an undefined value.Defines a subtype of this union type. This method returns an undefined value.Defines multiple subtypes of this union type. Returns the formatted GraphQL SDL of the union type. ### API Documentation - Module: ElasticGraph::SchemaDefinition::SchemaElements Index (S) » ElasticGraph » SchemaDefinition » SchemaElements Module: ElasticGraph::SchemaDefinition::SchemaElements elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/argument.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/field.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/directive.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/enum_type.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/enum_value.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/field_path.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/input_type.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/type_namer.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/union_type.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/input_field.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/object_type.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/scalar_type.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/field_source.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/relationship.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/built_in_types.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/interface_type.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/type_reference.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/enum_value_namer.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/list_counts_state.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/deprecated_element.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/type_with_subfields.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/sub_aggregation_path.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/sort_order_enum_value.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/graphql_sdl_enumerator.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/enums_for_indexed_types.rb Namespace for classes which represent GraphQL schema elements. Defined Under Namespace Classes: Argument, BuiltInTypes, Directive, EnumType, EnumValue, Field, InterfaceType, ObjectType, Relationship, ScalarType, SortOrderEnumValue, TypeNamer, TypeWithSubfields, UnionType ### API Documentation - Module: ElasticGraph::SchemaDefinition Index (S) » ElasticGraph » SchemaDefinition Module: ElasticGraph::SchemaDefinition elasticgraph-schema_definition/lib/elastic_graph/schema_definition/api.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/state.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/factory.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/results.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/rake_tasks.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/test_support.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/index.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/scripting/script.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/json_schema_pruner.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_indices.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_subtypes.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_type_info.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_directives.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/field.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/event_envelope.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_artifact_manager.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_reference.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/enum.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/rollover_config.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_documentation.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/argument.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/union.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/directive.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/enum_type.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/object.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/scalar.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/can_be_graphql_only.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/enum_value.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/field_path.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/input_type.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/type_namer.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/union_type.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/input_field.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/object_type.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/scalar_type.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/list_counts_mapping.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/implements_interfaces.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/verifies_graphql_name.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/field_source.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/relationship.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_indexed_type.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/supports_default_value.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/relationship_resolver.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/update_target_factory.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/built_in_types.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/interface_type.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/type_reference.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/update_target_resolver.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/enum_value_namer.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/scripting/file_system_repository.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/list_counts_state.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/json_schema_with_metadata.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/deprecated_element.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/json_schema_field_metadata.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/type_with_subfields.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/sub_aggregation_path.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/sort_order_enum_value.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/graphql_sdl_enumerator.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_fields/append_only_set.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_fields/immutable_value.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/enums_for_indexed_types.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_fields/min_or_max_value.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/supports_filtering_and_aggregation.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_derived_graphql_type_customizations.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_fields/field_initializer_support.rb Provides the ElasticGraph schema definition API. The primary entry point is define_schema. Defined Under Namespace Modules: Indexing, Mixins, SchemaElements Classes: API, RakeTasks, Results ### API Documentation - Module: ElasticGraph::Support Index (S) » ElasticGraph » Support Module: ElasticGraph::Support elasticgraph-support/lib/elastic_graph/support/from_yaml_file.rb, elasticgraph-support/lib/elastic_graph/support/logger.rb, elasticgraph-support/lib/elastic_graph/support/time_set.rb, elasticgraph-support/lib/elastic_graph/support/hash_util.rb, elasticgraph-support/lib/elastic_graph/support/threading.rb, elasticgraph-support/lib/elastic_graph/support/time_util.rb, elasticgraph-support/lib/elastic_graph/support/memoizable_data.rb, elasticgraph-support/lib/elastic_graph/support/monotonic_clock.rb, elasticgraph-support/lib/elastic_graph/support/untyped_encoder.rb, elasticgraph-support/lib/elastic_graph/support/graphql_formatter.rb, elasticgraph-support/lib/elastic_graph/support/faraday_middleware/support_timeouts.rb, elasticgraph-support/lib/elastic_graph/support/faraday_middleware/msearch_using_get_instead_of_post.rb Provides support utilities for the rest of the ElasticGraph gems. As such, it is not intended to provide public APIs for ElasticGraph users. ### API Documentation - Module: ElasticGraph Index (E) » ElasticGraph Module: ElasticGraph elasticgraph-apollo/lib/elastic_graph/apollo/graphql/engine_extension.rb, elasticgraph-admin_lambda/lib/elastic_graph/admin_lambda.rb, elasticgraph-admin_lambda/lib/elastic_graph/admin_lambda/rake_adapter.rb, elasticgraph-admin_lambda/lib/elastic_graph/admin_lambda/lambda_function.rb, elasticgraph-apollo/lib/elastic_graph/apollo/graphql/service_field_resolver.rb, elasticgraph-apollo/lib/elastic_graph/apollo/graphql/entities_field_resolver.rb, elasticgraph-apollo/lib/elastic_graph/apollo/graphql/http_endpoint_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/api_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/field_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/state_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/apollo_directives.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/factory_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/argument_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/enum_type_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/enum_value_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/input_type_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/union_type_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/entity_type_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/object_type_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/scalar_type_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/interface_type_extension.rb, elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/graphql_sdl_enumerator_extension.rb, elasticgraph-elasticsearch/lib/elastic_graph/elasticsearch/client.rb, elasticgraph-graphql_lambda/lib/elastic_graph/graphql_lambda.rb, elasticgraph-graphql_lambda/lib/elastic_graph/graphql_lambda/lambda_function.rb, elasticgraph-graphql_lambda/lib/elastic_graph/graphql_lambda/graphql_endpoint.rb, elasticgraph-indexer_autoscaler_lambda/lib/elastic_graph/indexer_autoscaler_lambda.rb, elasticgraph-indexer_autoscaler_lambda/lib/elastic_graph/indexer_autoscaler_lambda/details_logger.rb, elasticgraph-indexer_autoscaler_lambda/lib/elastic_graph/indexer_autoscaler_lambda/lambda_function.rb, elasticgraph-indexer_autoscaler_lambda/lib/elastic_graph/indexer_autoscaler_lambda/concurrency_scaler.rb, elasticgraph-indexer_lambda/lib/elastic_graph/indexer_lambda.rb, elasticgraph-indexer_lambda/lib/elastic_graph/indexer_lambda/sqs_processor.rb, elasticgraph-indexer_lambda/lib/elastic_graph/indexer_lambda/lambda_function.rb, elasticgraph-json_schema/lib/elastic_graph/json_schema/validator.rb, elasticgraph-json_schema/lib/elastic_graph/json_schema/validator_factory.rb, elasticgraph-json_schema/lib/elastic_graph/json_schema/meta_schema_validator.rb, elasticgraph-local/lib/elastic_graph/local/rake_tasks.rb, elasticgraph-local/lib/elastic_graph/local/docker_runner.rb, elasticgraph-local/lib/elastic_graph/local/local_indexer.rb, elasticgraph-local/lib/elastic_graph/local/indexing_coordinator.rb, elasticgraph-opensearch/lib/elastic_graph/opensearch/client.rb, elasticgraph-rack/lib/elastic_graph/rack.rb, elasticgraph-rack/lib/elastic_graph/rack/graphiql.rb, elasticgraph-rack/lib/elastic_graph/rack/graphql_endpoint.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/api.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/state.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/factory.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/results.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/rake_tasks.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/test_support.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/index.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/scripting/script.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/json_schema_pruner.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_indices.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_subtypes.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_type_info.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_directives.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/field.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/event_envelope.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_artifact_manager.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_reference.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/enum.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/rollover_config.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_documentation.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/argument.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/union.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/directive.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/enum_type.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/object.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/scalar.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/can_be_graphql_only.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/enum_value.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/field_path.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/input_type.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/type_namer.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/union_type.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/input_field.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/object_type.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/scalar_type.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/list_counts_mapping.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/implements_interfaces.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/verifies_graphql_name.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/field_source.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/relationship.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_indexed_type.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/supports_default_value.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/relationship_resolver.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/update_target_factory.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/built_in_types.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/interface_type.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/type_reference.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/update_target_resolver.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/enum_value_namer.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/scripting/file_system_repository.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/list_counts_state.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/json_schema_with_metadata.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/deprecated_element.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/json_schema_field_metadata.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/type_with_subfields.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/sub_aggregation_path.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/sort_order_enum_value.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/graphql_sdl_enumerator.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_fields/append_only_set.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_fields/immutable_value.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/enums_for_indexed_types.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_fields/min_or_max_value.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/supports_filtering_and_aggregation.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_derived_graphql_type_customizations.rb, elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_fields/field_initializer_support.rb, elasticgraph-support/lib/elastic_graph/errors.rb, elasticgraph-support/lib/elastic_graph/version.rb, elasticgraph-support/lib/elastic_graph/constants.rb, elasticgraph-support/lib/elastic_graph/support/logger.rb, elasticgraph-support/lib/elastic_graph/support/time_set.rb, elasticgraph-support/lib/elastic_graph/support/hash_util.rb, elasticgraph-support/lib/elastic_graph/support/threading.rb, elasticgraph-support/lib/elastic_graph/support/time_util.rb, elasticgraph-support/lib/elastic_graph/support/from_yaml_file.rb, elasticgraph-support/lib/elastic_graph/support/memoizable_data.rb, elasticgraph-support/lib/elastic_graph/support/monotonic_clock.rb, elasticgraph-support/lib/elastic_graph/support/untyped_encoder.rb, elasticgraph-support/lib/elastic_graph/support/graphql_formatter.rb, elasticgraph-support/lib/elastic_graph/support/faraday_middleware/support_timeouts.rb, elasticgraph-support/lib/elastic_graph/support/faraday_middleware/msearch_using_get_instead_of_post.rb Copyright 2024 Block, Inc. Use of this source code is governed by an MIT-style license that can be found in the LICENSE file or at https://opensource.org/licenses/MIT. frozen_string_literal: true Defined Under Namespace Modules: Apollo, JSONSchema, Local, Rack, SchemaDefinition, Support Constant Summary collapse VERSION = The version of all ElasticGraph gems. "0.19.1.1" Class Method Summary collapse .define_schema ⇒ Object The main entry point for schema definition from ElasticGraph applications. Class Method Details .define_schema ⇒ Object The main entry point for schema definition from ElasticGraph applications. Call this API from a Ruby file configured as the path_to_schema (or from a Ruby file loaded from the path_to_schema file). Examples: ElasticGraph.define_schema do |schema| # The `schema` object provides the schema definition API. Use it in this block. end The main entry point for schema definition from ElasticGraph applications. Call this API from a Ruby file configured as the path_to_schema (or from a Ruby file loaded from the path_to_schema file). ### API Documentation - Documentation by YARD 0.9.37 Documentation by YARD 0.9.37 Alphabetic Index File Listing README Namespace Listing A-Z A API (ElasticGraph::SchemaDefinition) APIExtension (ElasticGraph::Apollo::SchemaDefinition) Apollo (ElasticGraph) ApolloDirectives (ElasticGraph::Apollo::SchemaDefinition) AppendOnlySet (ElasticGraph::SchemaDefinition::Indexing::DerivedFields) Argument (ElasticGraph::SchemaDefinition::SchemaElements) ArgumentExtension (ElasticGraph::Apollo::SchemaDefinition) Authenticated (ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives) B BuiltInTypes (ElasticGraph::SchemaDefinition::SchemaElements) C CanBeGraphQLOnly (ElasticGraph::SchemaDefinition::Mixins) D DerivedFields (ElasticGraph::SchemaDefinition::Indexing) DerivedIndexedType (ElasticGraph::SchemaDefinition::Indexing) Directive (ElasticGraph::SchemaDefinition::SchemaElements) E ElasticGraph Enum (ElasticGraph::SchemaDefinition::Indexing::FieldType) EnumType (ElasticGraph::SchemaDefinition::SchemaElements) EnumTypeExtension (ElasticGraph::Apollo::SchemaDefinition) EnumValue (ElasticGraph::SchemaDefinition::SchemaElements) EnumValueExtension (ElasticGraph::Apollo::SchemaDefinition) EventEnvelope (ElasticGraph::SchemaDefinition::Indexing) Extends (ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives) External (ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives) F Field (ElasticGraph::SchemaDefinition::Indexing) Field (ElasticGraph::SchemaDefinition::SchemaElements) FieldExtension (ElasticGraph::Apollo::SchemaDefinition) FieldInitializerSupport (ElasticGraph::SchemaDefinition::Indexing::DerivedFields) FieldReference (ElasticGraph::SchemaDefinition::Indexing) FieldType (ElasticGraph::SchemaDefinition::Indexing) G GraphQL (ElasticGraph::Apollo) GraphQLEndpoint (ElasticGraph::Rack) GraphiQL (ElasticGraph::Rack) H HasDerivedGraphQLTypeCustomizations (ElasticGraph::SchemaDefinition::Mixins) HasDirectives (ElasticGraph::SchemaDefinition::Mixins) HasDocumentation (ElasticGraph::SchemaDefinition::Mixins) HasIndices (ElasticGraph::SchemaDefinition::Mixins) HasTypeInfo (ElasticGraph::SchemaDefinition::Mixins) I ImmutableValue (ElasticGraph::SchemaDefinition::Indexing::DerivedFields) ImplementsInterfaces (ElasticGraph::SchemaDefinition::Mixins) Inaccessible (ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives) Index (ElasticGraph::SchemaDefinition::Indexing) Indexing (ElasticGraph::SchemaDefinition) InputTypeExtension (ElasticGraph::Apollo::SchemaDefinition) InterfaceObject (ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives) InterfaceType (ElasticGraph::SchemaDefinition::SchemaElements) InterfaceTypeExtension (ElasticGraph::Apollo::SchemaDefinition) J JSONSchema (ElasticGraph) JSONSchemaFieldMetadata (ElasticGraph::SchemaDefinition::Indexing) K Key (ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives) L Local (ElasticGraph) M MetaSchemaLoader (ElasticGraph::JSONSchema) MinOrMaxValue (ElasticGraph::SchemaDefinition::Indexing::DerivedFields) Mixins (ElasticGraph::SchemaDefinition) O Object (ElasticGraph::SchemaDefinition::Indexing::FieldType) ObjectType (ElasticGraph::SchemaDefinition::SchemaElements) ObjectTypeExtension (ElasticGraph::Apollo::SchemaDefinition) Override (ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives) P Policy (ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives) Provides (ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives) R Rack (ElasticGraph) RakeTasks (ElasticGraph::Local) RakeTasks (ElasticGraph::SchemaDefinition) Relationship (ElasticGraph::SchemaDefinition::SchemaElements) Requires (ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives) RequiresScopes (ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives) Results (ElasticGraph::SchemaDefinition) S Scalar (ElasticGraph::SchemaDefinition::Indexing::FieldType) ScalarType (ElasticGraph::SchemaDefinition::SchemaElements) ScalarTypeExtension (ElasticGraph::Apollo::SchemaDefinition) SchemaDefinition (ElasticGraph) SchemaDefinition (ElasticGraph::Apollo) SchemaElements (ElasticGraph::SchemaDefinition) Shareable (ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives) SortOrderEnumValue (ElasticGraph::SchemaDefinition::SchemaElements) Support (ElasticGraph) SupportsDefaultValue (ElasticGraph::SchemaDefinition::Mixins) T Tag (ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives) TypeNamer (ElasticGraph::SchemaDefinition::SchemaElements) TypeWithSubfields (ElasticGraph::SchemaDefinition::SchemaElements) U Union (ElasticGraph::SchemaDefinition::Indexing::FieldType) UnionType (ElasticGraph::SchemaDefinition::SchemaElements) UnionTypeExtension (ElasticGraph::Apollo::SchemaDefinition) V Validator (ElasticGraph::JSONSchema) ValidatorFactory (ElasticGraph::JSONSchema) VerifiesGraphQLName (ElasticGraph::SchemaDefinition::Mixins) ### API Documentation - File: README Index » README ElasticGraph ElasticGraph is a general purpose, near real-time data query and search platform that is scalable and performant, serves rich interactive queries, and dramatically simplifies the creation of complex reports. The platform combines the power of indexing and search of Elasticsearch or OpenSearch with the query flexibility of GraphQL language. Optimized for AWS cloud, it also offers scale and reliability. ElasticGraph is a naturally flexible framework with many different possible applications. However, the main motivation we have for building it is to power various data APIs, UIs and reports. These modern reports require filtering and aggregations across a body of ever growing data sets. Modern APIs allow us to: Minimize network trips to retrieve your data Get exactly what you want in a single query. No over- or under-serving the data. Push filtering complex calculations to the backend. Versioning Policy ElasticGraph does not strictly follow the SemVer spec. We followed that early in the project’s life cycle and realized that it obscures some important compatibility information. ElasticGraph’s versioning policy is designed to communicate compatibility information related to the following stakeholders: Application maintainers: engineers that define an ElasticGraph schema, maintain project configuration, and perform upgrades. Data publishers: systems that publish data into an ElasticGraph application for ingestion by an ElasticGraph indexer. GraphQL clients: clients of the GraphQL API of an ElasticGraph application. We use the following versioning scheme: Version numbers are in a 0.MAJOR.MINOR.PATCH format. (The 0. prefix is there in order to reserve 1.0.0 and all later versions for after ElasticGraph has been open-sourced). Increments to the PATCH version indicate that the new release contains no backwards incompatibilities for any stakeholders. It may contain bug fixes, new features, internal refactorings, and dependency upgrades, among other things. You can expect that PATCH level upgrades are always safe–just update the version in your bundle, generate new schema artifacts, and you should be done. Increments to the MINOR version indicate that the new release contains some backwards incompatibilities that may impact the application maintainers of some ElasticGraph applications. MINOR releases may include renames to configuration settings, changes to the schema definition API, and new schema definition requirements, among other things. You can expect that MINOR level upgrades can usually be done in 30 minutes or less (usually in a single commit!), with release notes and clear errors from ElasticGraph command line tasks providing guidance on how to upgrade. Increments to the MAJOR version indicate that the new release contains some backwards incompatibilities that may impact the data publishers or GraphQL clients of some ElasticGraph applications. MAJOR releases may include changes to the GraphQL schema that require careful migration of GraphQL clients or changes to how indexing is done that require a dataset to be re-indexed from scratch (e.g. by having data publishers republish their data into an ElasticGraph indexer running the new version). You can expect that the release notes will include detailed instructions on how to perform a MAJOR version upgrade. Deprecation warnings may be included at any of these levels–for example, a PATCH release may contain a deprecation warning for a breaking change that may impact application maintainers in an upcoming MINOR release, and a MINOR release may contain deprecation warnings for breaking changes that may impact data publishers or GraphQL clients in an upcoming MAJOR release. Each version level is cumulative over the prior levels. That is, a MINOR release may include PATCH-level changes in addition to backwards incompatibilities that may impact application maintainers. A MAJOR release may include PATCH-level or MINOR-level changes in addition to backwards incompatibilities that may impact data publishers or GraphQL clients. Note that this policy was first adopted in the v0.15.1.0 release. All prior releases aimed (with some occasional mistakes!) to follow SemVer with a 0.MAJOR.MINOR.PATCH versioning scheme. Note that all gems in this repository share the same version number. Every time we cut a release, we increment the version for all gems and release all gems, even if a gem has had no changes since the last release. This is simpler to work with than the alternatives. License ElasticGraph is released under the MIT License. Part of the distributed code comes from the GraphiQL project, also licensed under the MIT License, Copyright (c) GraphQL Contributors. ### API Documentation - File: README Index » README ElasticGraph ElasticGraph is a general purpose, near real-time data query and search platform that is scalable and performant, serves rich interactive queries, and dramatically simplifies the creation of complex reports. The platform combines the power of indexing and search of Elasticsearch or OpenSearch with the query flexibility of GraphQL language. Optimized for AWS cloud, it also offers scale and reliability. ElasticGraph is a naturally flexible framework with many different possible applications. However, the main motivation we have for building it is to power various data APIs, UIs and reports. These modern reports require filtering and aggregations across a body of ever growing data sets. Modern APIs allow us to: Minimize network trips to retrieve your data Get exactly what you want in a single query. No over- or under-serving the data. Push filtering complex calculations to the backend. Versioning Policy ElasticGraph does not strictly follow the SemVer spec. We followed that early in the project’s life cycle and realized that it obscures some important compatibility information. ElasticGraph’s versioning policy is designed to communicate compatibility information related to the following stakeholders: Application maintainers: engineers that define an ElasticGraph schema, maintain project configuration, and perform upgrades. Data publishers: systems that publish data into an ElasticGraph application for ingestion by an ElasticGraph indexer. GraphQL clients: clients of the GraphQL API of an ElasticGraph application. We use the following versioning scheme: Version numbers are in a 0.MAJOR.MINOR.PATCH format. (The 0. prefix is there in order to reserve 1.0.0 and all later versions for after ElasticGraph has been open-sourced). Increments to the PATCH version indicate that the new release contains no backwards incompatibilities for any stakeholders. It may contain bug fixes, new features, internal refactorings, and dependency upgrades, among other things. You can expect that PATCH level upgrades are always safe–just update the version in your bundle, generate new schema artifacts, and you should be done. Increments to the MINOR version indicate that the new release contains some backwards incompatibilities that may impact the application maintainers of some ElasticGraph applications. MINOR releases may include renames to configuration settings, changes to the schema definition API, and new schema definition requirements, among other things. You can expect that MINOR level upgrades can usually be done in 30 minutes or less (usually in a single commit!), with release notes and clear errors from ElasticGraph command line tasks providing guidance on how to upgrade. Increments to the MAJOR version indicate that the new release contains some backwards incompatibilities that may impact the data publishers or GraphQL clients of some ElasticGraph applications. MAJOR releases may include changes to the GraphQL schema that require careful migration of GraphQL clients or changes to how indexing is done that require a dataset to be re-indexed from scratch (e.g. by having data publishers republish their data into an ElasticGraph indexer running the new version). You can expect that the release notes will include detailed instructions on how to perform a MAJOR version upgrade. Deprecation warnings may be included at any of these levels–for example, a PATCH release may contain a deprecation warning for a breaking change that may impact application maintainers in an upcoming MINOR release, and a MINOR release may contain deprecation warnings for breaking changes that may impact data publishers or GraphQL clients in an upcoming MAJOR release. Each version level is cumulative over the prior levels. That is, a MINOR release may include PATCH-level changes in addition to backwards incompatibilities that may impact application maintainers. A MAJOR release may include PATCH-level or MINOR-level changes in addition to backwards incompatibilities that may impact data publishers or GraphQL clients. Note that this policy was first adopted in the v0.15.1.0 release. All prior releases aimed (with some occasional mistakes!) to follow SemVer with a 0.MAJOR.MINOR.PATCH versioning scheme. Note that all gems in this repository share the same version number. Every time we cut a release, we increment the version for all gems and release all gems, even if a gem has had no changes since the last release. This is simpler to work with than the alternatives. License ElasticGraph is released under the MIT License. Part of the distributed code comes from the GraphiQL project, also licensed under the MIT License, Copyright (c) GraphQL Contributors. ### API Documentation - Top Level Namespace Index » Top Level Namespace Top Level Namespace Defined Under Namespace Modules: ElasticGraph Constant Summary collapse HandleAdminRequest = Lambda handler for elasticgraph-admin_lambda. ElasticGraph::AdminLambda::LambdaFunction.new ExecuteGraphQLQuery = Lambda handler for elasticgraph-graphql_lambda. ElasticGraph::GraphQLLambda::LambdaFunction.new AutoscaleIndexer = Lambda handler for elasticgraph-indexer_autoscaler_lambda. ElasticGraph::IndexerAutoscalerLambda::LambdaFunction.new ProcessEventStreamEvent = Lambda handler for elasticgraph-indexer_lambda. ElasticGraph::IndexerLambda::LambdaFunction.new ## Site Documentation ### What is ElasticGraph? What is ElasticGraph? ElasticGraph is a general purpose, near real-time data query and search platform that is scalable and performant, serves rich interactive queries, and dramatically simplifies the creation of complex reports. The platform combines the power of indexing and search of Elasticsearch or OpenSearch with the query flexibility of GraphQL language. Optimized for AWS cloud, it also offers scale and reliability. ElasticGraph is a naturally flexible framework with many different possible applications. However, the main motivation we have for building it is to power various data APIs, UIs and reports. These modern reports require filtering and aggregations across a body of ever growing data sets. Modern APIs allow us to: Minimize network trips to retrieve your data Get exactly what you want in a single query. No over- or under-serving the data. Push filtering complex calculations to the backend. What can I do with it? The ElasticGraph platform will allow you to query your data in many different configurations. To do so requires defining a schema which ElasticGraph will use to both index data and also query it. Besides all basic GraphQL query features, ElasticGraph also supports: Real-time indexing and data querying Filtering, sorting, pagination, grouping, aggregations, and sub-aggregations Navigating across data sets in a single query Robust, safe schema evolution support via Query Registry mechanism Derived indexes to power commonly accessed queries and aggregations Client and Publisher libraries Get started Our Getting Started guide will help you get up and running in about 10 minutes. ### Getting Started with ElasticGraph Getting Started with ElasticGraph Welcome to ElasticGraph! This guide will help you set up ElasticGraph locally, run queries using GraphiQL, and evolve an example schema. By the end of this tutorial, you’ll have a working ElasticGraph instance running on your machine. Estimated Time to Complete: 10 minutes Prerequisites Before you begin, ensure you have the following installed on your system: Docker and Docker Compose Ruby (version 3.3 or higher) Git Confirm these are installed using your terminal: Copy code Copied! $ ruby -v ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [arm64-darwin24] $ docker compose version Docker Compose version v2.32.4-desktop.1 $ git -v git version 2.46.0 Note You don’t need these exact versions (these are just examples). Your Ruby version does need to be 3.3.x or greater, though. Step 1: Bootstrap a new ElasticGraph Project Run one of the following commands in your terminal: Copy code Copied! $ gem exec elasticgraph new path/to/project --datastore elasticsearch Copy code Copied! $ gem exec elasticgraph new path/to/project --datastore opensearch Note Not sure whether to use Elasticsearch or OpenSearch? We recommend using whichever has better support in your organization. ElasticGraph works identically with both, and the choice makes no difference in the tutorial that follows. This will: Generate a project skeleton with an example schema Install dependencies including the latest version of ElasticGraph itself Dump schema artifacts Run the build tasks (including your new project’s test suite) Initialize the project as a git repository Commit the initial setup Step 2: Boot Locally The initial project skeleton comes with everything you need to run ElasticGraph locally. Confirm it works by running the following: Copy code Copied! $ cd path/to/project && bundle exec rake boot_locally This will: Boot the datastore (Elasticsearch or OpenSearch) using Docker Configure the datastore using the dumped datastore_config.yaml schema artifact Index some randomly generated artists/albums/tours/shows/venues data Boot ElasticGraph and a GraphiQL UI Open the local GraphiQL UI in your browser Run some example queries in GraphiQL to confirm it’s working. Here’s an example query to get you started: Copy code Copied! query FindArtistsFormedIn90s { artists(filter: { bio: {yearFormed: {gte: 1990, lt: 2000}} }) { nodes { name bio { yearFormed } albums { name } } } } Visit the Query API docs for other example queries that work against the example schema. Step 3: Add a new field to the Schema If this is your first ElasticGraph project, we recommend you add a new field to the example schema to get a feel for how it works. (Feel free to skip this step if you’ve worked in an ElasticGraph project before). Let’s add a Venue.yearOpened field to our schema. Here’s a git diff showing what to change: Copy code Copied! diff --git a/config/schema/artists.rb b/config/schema/artists.rb index 77e63de..7999fe4 100644 --- a/config/schema/artists.rb +++ b/config/schema/artists.rb @@ -56,6 +56,9 @@ ElasticGraph.define_schema do |schema| schema.object_type "Venue" do |t| t.field "id", "ID" t.field "name", "String" + t.field "yearOpened", "Int" do |f| + f.json_schema minimum: 1900, maximum: 2100 + end t.field "location", "GeoLocation" t.field "capacity", "Int" t.relates_to_many "featuredArtists", "Artist", via: "tours.shows.venueId", dir: :in, singular: "featuredArtist" Next, rebuild the project: Copy code Copied! $ bundle exec rake build This will re-generate the schema artifacts, run the test suite, and fail. The failing test will indicate that the :venue factory is missing the new field. To fix it, define yearOpened on the :venue factory in the factories.rb file under lib: Copy code Copied! diff --git a/lib/my_eg_project/factories.rb b/lib/my_eg_project/factories.rb index 0d8659c..509f274 100644 --- a/lib/my_eg_project/factories.rb +++ b/lib/my_eg_project/factories.rb @@ -95,6 +95,7 @@ FactoryBot.define do "#{city_name} #{venue_type}" end + yearOpened { Faker::Number.between(from: 1900, to: 2025) } location { build(:geo_location) } capacity { Faker::Number.between(from: 200, to: 100_000) } end Re-run bundle exec rake build and everything should pass. You can also run bundle exec rake boot_locally and query your new field to confirm the fake values being generated for it. Next Steps Congratulations! You’ve set up ElasticGraph locally and run your first queries. Here are some next steps you can take. Replace the Example Schema Delete the artist schema definition: Copy code Copied! $ rm config/schema/artists.rb Then define your own schema in a Ruby file under config/schema. Use the schema definition API docs as a reference. Use our AI Tools together with an LLM such as Goose to translate a schema from an existing format such as protocol buffers, JSON schema, or SQL. Run bundle exec rake build and deal with any errors that are reported. Hint: search the project codebase for TODO comments to find things that need updating. Setup a CI Build Your ElasticGraph project includes a command that’s designed to be run on CI: Copy code Copied! $ bundle exec rake check This should be run on every commit (ideally before merging a pull request) using a CI system such as Buildkite, Circle CI, GitHub Actions, or Jenkins. Deploy ElasticGraph can be deployed in two different ways: As a standard Ruby Rack application using elasticgraph-rack. Similar to a Rails or Sinatra app, you can serve ElasticGraph from any of the webservers that support the Rack spec. Or you could mount your ElasticGraph GraphQL endpoint inside an existing Rails or Sinatra application! As a serverless application in AWS using elasticgraph-graphql_lambda. Connect a Real Data Source Finally, you’ll want to publish into your deployed ElasticGraph project from a real data source. The generated json_schemas.yaml artifact can be used in your publishing system to validate the indexing payloads or for code generation (using a project like json-kotlin-schema-codegen). Resources GraphQL Introduction ElasticGraph Query API Documentation ElasticGraph Guides ElasticGraph Ruby API Documentation Feedback We’d love to hear your feedback. If you encounter any issues or have suggestions, please start a discussion in our discord channel or on GitHub. Happy coding with ElasticGraph! ```shell $ ruby -v ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [arm64-darwin24] $ docker compose version Docker Compose version v2.32.4-desktop.1 $ git -v git version 2.46.0 ``` ```shell $ gem exec elasticgraph new path/to/project --datastore elasticsearch ``` ```shell $ gem exec elasticgraph new path/to/project --datastore opensearch ``` ```shell $ cd path/to/project && bundle exec rake boot_locally ``` ```graphql query FindArtistsFormedIn90s { artists(filter: { bio: {yearFormed: {gte: 1990, lt: 2000}} }) { nodes { name bio { yearFormed } albums { name } } } } ``` ```diff diff --git a/config/schema/artists.rb b/config/schema/artists.rb index 77e63de..7999fe4 100644 --- a/config/schema/artists.rb +++ b/config/schema/artists.rb @@ -56,6 +56,9 @@ ElasticGraph.define_schema do |schema| schema.object_type "Venue" do |t| t.field "id", "ID" t.field "name", "String" + t.field "yearOpened", "Int" do |f| + f.json_schema minimum: 1900, maximum: 2100 + end t.field "location", "GeoLocation" t.field "capacity", "Int" t.relates_to_many "featuredArtists", "Artist", via: "tours.shows.venueId", dir: :in, singular: "featuredArtist" ``` ```shell $ bundle exec rake build ``` ```diff diff --git a/lib/my_eg_project/factories.rb b/lib/my_eg_project/factories.rb index 0d8659c..509f274 100644 --- a/lib/my_eg_project/factories.rb +++ b/lib/my_eg_project/factories.rb @@ -95,6 +95,7 @@ FactoryBot.define do "#{city_name} #{venue_type}" end + yearOpened { Faker::Number.between(from: 1900, to: 2025) } location { build(:geo_location) } capacity { Faker::Number.between(from: 200, to: 100_000) } end ``` ```shell $ rm config/schema/artists.rb ``` ```shell $ bundle exec rake check ``` ### AI Tools AI Tools Build faster with ElasticGraph using AI tools. Here’s how to get started with ChatGPT, Claude, or your preferred LLM. Quick Start Get the docs llms-full.txt contains our documentation optimized for LLMs. Copy the prompt I'm building with ElasticGraph. Here's the documentation: [the contents of llms-full.txt go here] Copy this prompt Start building Ask your favorite LLM about: Defining your schema Configuring Elasticsearch/OpenSearch Writing ElasticGraph GraphQL queries Searching and aggregating your data ElasticGraph MCP Server The elasticgraph-mcp-server enables AI agents to interact with your ElasticGraph projects through the Model Context Protocol. This allows AI tools to: Access ElasticGraph documentation Write schema definitions or GraphQL queries grounded in the full ElasticGraph docs Run common ElasticGraph commands Installation Install and run the MCP server, for example as a Goose extension, using: Copy code Copied! $ uvx elasticgraph-mcp-server Full documentation for elasticgraph-mcp-server. Compatible AI Tools You can use the ElasticGraph MCP server with: Goose - as an extension Claude - in the desktop app as an MCP server Cursor - as an MCP tool ```text I'm building with ElasticGraph. Here's the documentation: [the contents of llms-full.txt go here] ``` ```shell $ uvx elasticgraph-mcp-server ``` ### Guides Guides Learn how to build and scale your ElasticGraph applications with our comprehensive guides. Available Guides AI Tools Versioning Policy Getting Started Don’t miss Getting Started to set up your first ElasticGraph project. ### Versioning Policy Versioning Policy ElasticGraph does not strictly follow the SemVer spec. We followed that early in the project’s life cycle and realized that it obscures some important compatibility information. ElasticGraph’s versioning policy is designed to communicate compatibility information related to the following stakeholders: Application maintainers: engineers that define an ElasticGraph schema, maintain project configuration, and perform upgrades. Data publishers: systems that publish data into an ElasticGraph application for ingestion by an ElasticGraph indexer. GraphQL clients: clients of the GraphQL API of an ElasticGraph application. We use the following versioning scheme: Version numbers are in a MAJOR.MINOR.PATCH format. Increments to the PATCH version indicate that the new release contains no backwards incompatibilities for any stakeholders. It may contain bug fixes, new features, internal refactorings, and dependency upgrades, among other things. You can expect that PATCH level upgrades are always safe–just update the version in your bundle, generate new schema artifacts, and you should be done. Increments to the MINOR version indicate that the new release contains some backwards incompatibilities that may impact the application maintainers of some ElasticGraph applications. MINOR releases may include renames to configuration settings, changes to the schema definition API, and new schema definition requirements, among other things. You can expect that MINOR level upgrades can usually be done in 30 minutes or less (usually in a single commit!), with release notes and clear errors from ElasticGraph command line tasks providing guidance on how to upgrade. Increments to the MAJOR version indicate that the new release contains some backwards incompatibilities that may impact the data publishers or GraphQL clients of some ElasticGraph applications. MAJOR releases may include changes to the GraphQL schema that require careful migration of GraphQL clients or changes to how indexing is done that require a dataset to be re-indexed from scratch (e.g. by having data publishers republish their data into an ElasticGraph indexer running the new version). You can expect that the release notes will include detailed instructions on how to perform a MAJOR version upgrade. Deprecation warnings may be included at any of these levels–for example, a PATCH release may contain a deprecation warning for a breaking change that may impact application maintainers in an upcoming MINOR release, and a MINOR release may contain deprecation warnings for breaking changes that may impact data publishers or GraphQL clients in an upcoming MAJOR release. Each version level is cumulative over the prior levels. That is, a MINOR release may include PATCH-level changes in addition to backwards incompatibilities that may impact application maintainers. A MAJOR release may include PATCH-level or MINOR-level changes in addition to backwards incompatibilities that may impact data publishers or GraphQL clients. Note that all gems in this repository share the same version number. Every time we cut a release, we increment the version for all gems and release all gems, even if a gem has had no changes since the last release. This is simpler to work with than the alternatives. Note We’ll be releasing 1.0.0 soon! Before then, this same versioning policy applies, but our version numbers use a 0.MAJOR.MINOR.PATCH format. ### ElasticGraph Query API: Aggregated Values ElasticGraph Query API: Aggregated Values Try these example queries by visiting the GraphiQL UI after booting locally. Copy code Copied! $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always Aggregated values can be computed from all values of a particular field from all documents backing an aggregation node. Here’s an example: Copy code Copied! query BluegrassArtistLifetimeSales { artistAggregations( filter: {genres: {anySatisfy: {equalToAnyOf: [BLUEGRASS]}}} ) { nodes { groupedBy { bio { yearFormed } } aggregatedValues { lifetimeSales { exactMin exactMax exactSum approximateSum approximateAvg } } } } } This example query aggregates the values of the Artist.lifetimeSales field using all 4 of the standard numeric aggregated values: min, max, avg, and sum. These are qualified with approximate or exact to indicate the level of precision they offer. The documentation for approximateSum and exactSum provide more detail: approximateSum The (approximate) sum of the field values within this grouping. Sums of large Int values can result in overflow, where the exact sum cannot fit in a JsonSafeLong return value. This field, as a double-precision Float, can represent larger sums, but the value may only be approximate. exactSum The exact sum of the field values within this grouping, if it fits in a JsonSafeLong. Sums of large Int values can result in overflow, where the exact sum cannot fit in a JsonSafeLong. In that case, null will be returned, and approximateSum can be used to get an approximate value. Besides these standard numeric aggregated values, ElasticGraph offers one more: Copy code Copied! query SkaArtistHomeCountries { artistAggregations( filter: {genres: {anySatisfy: {equalToAnyOf: [SKA]}}} ) { nodes { groupedBy { bio { yearFormed } } aggregatedValues { bio { homeCountry { approximateDistinctValueCount } } } } } } The approximateDistinctValueCount field uses the HyperLogLog++ algorithm to provide an approximate count of distinct values for the field. In this case, it can give us an idea of how many countries ska bands were formed in, in each year. ```shell $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always ``` ```graphql query BluegrassArtistLifetimeSales { artistAggregations( filter: {genres: {anySatisfy: {equalToAnyOf: [BLUEGRASS]}}} ) { nodes { groupedBy { bio { yearFormed } } aggregatedValues { lifetimeSales { exactMin exactMax exactSum approximateSum approximateAvg } } } } } ``` ```graphql query SkaArtistHomeCountries { artistAggregations( filter: {genres: {anySatisfy: {equalToAnyOf: [SKA]}}} ) { nodes { groupedBy { bio { yearFormed } } aggregatedValues { bio { homeCountry { approximateDistinctValueCount } } } } } } ``` ### ElasticGraph Query API: Aggregation Counts ElasticGraph Query API: Aggregation Counts Try these example queries by visiting the GraphiQL UI after booting locally. Copy code Copied! $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always The aggregations API allows you to count documents within a grouping: Copy code Copied! query ArtistCountsByCountry { artistAggregations { nodes { groupedBy { bio { homeCountry } } count } } } This query, for example, returns a grouping for each country, and provides a count of how many artists call each country home. ```shell $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always ``` ```graphql query ArtistCountsByCountry { artistAggregations { nodes { groupedBy { bio { homeCountry } } count } } } ``` ### ElasticGraph Query API: Aggregation Grouping ElasticGraph Query API: Aggregation Grouping Try these example queries by visiting the GraphiQL UI after booting locally. Copy code Copied! $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always When aggregating documents, the groupings are defined by groupedBy. Here’s an example: Copy code Copied! query ArtistCountsByYearFormedAndHomeCountry { artistAggregations { nodes { groupedBy { bio { yearFormed homeCountry } } count } } } In this case, we’re grouping by multiple fields; a grouping will be returned for each combination of Artist.bio.yearFormed and Artist.bio.homeCountry found in the data. Date Grouping In the example above, the grouping was performed on the raw values of the groupedBy fields. However, for Date fields it’s generally more useful to group by truncated values. Here’s an example: Copy code Copied! query AlbumSalesByReleaseYear { artistAggregations { nodes { subAggregations { albums { nodes { groupedBy { releasedOn { asDate(truncationUnit: YEAR) } } aggregatedValues { soldUnits { exactSum } } } } } } } } In this case, we’re truncating the Album.releaseOn dates to the year to give us one grouping per year rather than one grouping per distinct date. The truncationUnit argument supports DAY, MONTH, QUARTER, WEEK and YEAR values. In addition, an offset argument is supported, which can be used to shift what grouping a Date falls into. This is particularly useful when using WEEK: Copy code Copied! query AlbumSalesByReleaseWeek { artistAggregations { nodes { subAggregations { albums { nodes { groupedBy { releasedOn { asDate(truncationUnit: WEEK, offset: {amount: -1, unit: DAY}) } } aggregatedValues { soldUnits { exactSum } } } } } } } } With no offset, grouped weeks run Monday to Sunday, but we can shift it using offset. In this case, the weeks have been shifted to run Sunday to Saturday. Finally, we can also group Date fields by what day of week they fall into using asDayOfWeek instead of asDate: Copy code Copied! query AlbumSalesByReleaseDayOfWeek { artistAggregations { nodes { subAggregations { albums { nodes { groupedBy { releasedOn { asDayOfWeek } } aggregatedValues { soldUnits { exactSum } } } } } } } } DateTime Grouping DateTime fields offer a similar grouping API. asDate and asDayOfWeek work the same, but they accept an optional timeZone argument (default is “UTC”): Copy code Copied! query TourAttendanceByYear { artistAggregations { nodes { subAggregations { tours { nodes { subAggregations { shows { nodes { groupedBy { startedAt { asDate( truncationUnit: YEAR timeZone: "America/Los_Angeles" ) } } aggregatedValues { attendance { exactSum } } } } } } } } } } } Sub-day granualarities (HOUR, MINUTE, SECOND) are supported when you use asDateTime instead of asDate: Copy code Copied! query TourAttendanceByHour { artistAggregations { nodes { subAggregations { tours { nodes { subAggregations { shows { nodes { groupedBy { startedAt { asDateTime(truncationUnit: HOUR) } } aggregatedValues { attendance { exactSum } } } } } } } } } } } Finally, you can group by the time of day (while ignoring the date) by using asTimeOfDay: Copy code Copied! query TourAttendanceByHourOfDay { artistAggregations { nodes { subAggregations { tours { nodes { subAggregations { shows { nodes { groupedBy { startedAt { asTimeOfDay(truncationUnit: HOUR) } } aggregatedValues { attendance { exactSum } } } } } } } } } } } ```shell $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always ``` ```graphql query ArtistCountsByYearFormedAndHomeCountry { artistAggregations { nodes { groupedBy { bio { yearFormed homeCountry } } count } } } ``` ```graphql query AlbumSalesByReleaseYear { artistAggregations { nodes { subAggregations { albums { nodes { groupedBy { releasedOn { asDate(truncationUnit: YEAR) } } aggregatedValues { soldUnits { exactSum } } } } } } } } ``` ```graphql query AlbumSalesByReleaseWeek { artistAggregations { nodes { subAggregations { albums { nodes { groupedBy { releasedOn { asDate(truncationUnit: WEEK, offset: {amount: -1, unit: DAY}) } } aggregatedValues { soldUnits { exactSum } } } } } } } } ``` ```graphql query AlbumSalesByReleaseDayOfWeek { artistAggregations { nodes { subAggregations { albums { nodes { groupedBy { releasedOn { asDayOfWeek } } aggregatedValues { soldUnits { exactSum } } } } } } } } ``` ```graphql query TourAttendanceByYear { artistAggregations { nodes { subAggregations { tours { nodes { subAggregations { shows { nodes { groupedBy { startedAt { asDate( truncationUnit: YEAR timeZone: "America/Los_Angeles" ) } } aggregatedValues { attendance { exactSum } } } } } } } } } } } ``` ```graphql query TourAttendanceByHour { artistAggregations { nodes { subAggregations { tours { nodes { subAggregations { shows { nodes { groupedBy { startedAt { asDateTime(truncationUnit: HOUR) } } aggregatedValues { attendance { exactSum } } } } } } } } } } } ``` ```graphql query TourAttendanceByHourOfDay { artistAggregations { nodes { subAggregations { tours { nodes { subAggregations { shows { nodes { groupedBy { startedAt { asTimeOfDay(truncationUnit: HOUR) } } aggregatedValues { attendance { exactSum } } } } } } } } } } } ``` ### ElasticGraph Query API: Aggregations ElasticGraph Query API: Aggregations Try these example queries by visiting the GraphiQL UI after booting locally. Copy code Copied! $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always ElasticGraph offers a powerful aggregations API. Each indexed type gets a corresponding *Aggregations field. Here’s a complete example: Copy code Copied! query BluegrassArtistAggregations($cursor: Cursor) { artistAggregations( first: 10 after: $cursor filter: {genres: {anySatisfy: {equalToAnyOf: [BLUEGRASS]}}} ) { pageInfo { hasNextPage endCursor } nodes { groupedBy { bio { yearFormed } } aggregatedValues { lifetimeSales { approximateAvg exactMin exactMax } } count subAggregations { albums( first: 3 filter: {tracks: {count: {gt: 10}}} ) { nodes { countDetail { approximateValue } } } } } } } Aggregation fields support filtering and pagination but do not support client-specified sorting1. Under an aggregations field, each node represents a grouping of documents. When groupedBy fields have been requested, each node represents the grouping of documents that have the groupedBy values. When no groupedBy fields have been requested, a single node will be returned containing a grouping for all documents matched by the filter. Aggregation nodes in turn offer 4 different aggregation features: Aggregated Values Counts Grouping Sub-Aggregations Aggregation sorting is implicitly controlled by the groupings–the nodes will sort ascending by each of the grouping fields. ↩ ```shell $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always ``` ```graphql query BluegrassArtistAggregations($cursor: Cursor) { artistAggregations( first: 10 after: $cursor filter: {genres: {anySatisfy: {equalToAnyOf: [BLUEGRASS]}}} ) { pageInfo { hasNextPage endCursor } nodes { groupedBy { bio { yearFormed } } aggregatedValues { lifetimeSales { approximateAvg exactMin exactMax } } count subAggregations { albums( first: 3 filter: {tracks: {count: {gt: 10}}} ) { nodes { countDetail { approximateValue } } } } } } } ``` ### ElasticGraph Query API: Sub-Aggregations ElasticGraph Query API: Sub-Aggregations Try these example queries by visiting the GraphiQL UI after booting locally. Copy code Copied! $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always The example schema used throughout this guide has a number of lists-of-object fields nested within the overall Artist type: Artist.albums Artist.albums[].tracks Artist.tours Artist.tours[].shows ElasticGraph supports aggregations on these nested fields via subAggregations. This can be used to aggregate directly on the data of one of these fields. For example, this query returns the total sales for all albums of all artists: Copy code Copied! query TotalAlbumSales { artistAggregations { nodes { subAggregations { albums { nodes { aggregatedValues { soldUnits { exactSum } } } } } } } } Sub-aggregations can also be performed under the groupings of an outer aggregation. For example, this query returns the total album sales grouped by the home country of the artist: Copy code Copied! query TotalAlbumSalesByArtistHomeCountry { artistAggregations { nodes { groupedBy { bio { homeCountry } } subAggregations { albums { nodes { aggregatedValues { soldUnits { exactSum } } } } } } } } Sub-aggregation nodes offer the standard set of aggregation operations: Aggregated Values Counts Grouping Sub-aggregations Filtering Sub-Aggregations The data included in a sub-aggregation can be filtered. For example, this query gets the total sales of all albums released in the 21st century: Copy code Copied! query TwentyFirstCenturyAlbumSales { artistAggregations { nodes { subAggregations { albums(filter: { releasedOn: {gte: "2000-01-01"} }) { nodes { aggregatedValues { soldUnits { exactSum } } } } } } } } Sub-Aggregation Limitations Sub-aggregation pagination support is limited. You can use first to request how many nodes are returned, but there is no pageInfo and you cannot request the next page of data: Copy code Copied! query AlbumSalesByReleaseMonth { artistAggregations { nodes { subAggregations { albums(first: 100) { nodes { groupedBy { releasedOn { asDate(truncationUnit: MONTH) } } aggregatedValues { soldUnits { exactSum } } } } } } } } Sub-aggregation counts are approximate. Instead of count, ElasticGraph offers countDetail with multiple subfields: Copy code Copied! query AlbumCount { artistAggregations { nodes { subAggregations { albums { nodes { countDetail { approximateValue exactValue upperBound } } } } } } } approximateValue The (approximate) count of documents in this aggregation bucket. When documents in an aggregation bucket are sourced from multiple shards, the count may be only approximate. The upperBound indicates the maximum value of the true count, but usually the true count is much closer to this approximate value (which also provides a lower bound on the true count). When this approximation is known to be exact, the same value will be available from exactValue and upperBound. exactValue The exact count of documents in this aggregation bucket, if an exact value can be determined. When documents in an aggregation bucket are sourced from multiple shards, it may not be possible to efficiently determine an exact value. When no exact value can be determined, this field will be null. The approximateValue field–which will never be null–can be used to get an approximation for the count. upperBound An upper bound on how large the true count of documents in this aggregation bucket could be. When documents in an aggregation bucket are sourced from multiple shards, it may not be possible to efficiently determine an exact value. The approximateValue field provides an approximation, and this field puts an upper bound on the true count. ```shell $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always ``` ```graphql query TotalAlbumSales { artistAggregations { nodes { subAggregations { albums { nodes { aggregatedValues { soldUnits { exactSum } } } } } } } } ``` ```graphql query TotalAlbumSalesByArtistHomeCountry { artistAggregations { nodes { groupedBy { bio { homeCountry } } subAggregations { albums { nodes { aggregatedValues { soldUnits { exactSum } } } } } } } } ``` ```graphql query TwentyFirstCenturyAlbumSales { artistAggregations { nodes { subAggregations { albums(filter: { releasedOn: {gte: "2000-01-01"} }) { nodes { aggregatedValues { soldUnits { exactSum } } } } } } } } ``` ```graphql query AlbumSalesByReleaseMonth { artistAggregations { nodes { subAggregations { albums(first: 100) { nodes { groupedBy { releasedOn { asDate(truncationUnit: MONTH) } } aggregatedValues { soldUnits { exactSum } } } } } } } } ``` ```graphql query AlbumCount { artistAggregations { nodes { subAggregations { albums { nodes { countDetail { approximateValue exactValue upperBound } } } } } } } ``` ### ElasticGraph Query API: Available Filter Predicates ElasticGraph Query API: Available Filter Predicates ElasticGraph offers a variety of filtering predicates: allOf Matches records where all of the provided sub-filters evaluate to true. This works just like an AND operator in SQL. Note: multiple filters are automatically ANDed together. This is only needed when you have multiple filters that can’t be provided on a single filter input because of collisions between key names. For example, if you want to provide multiple anySatisfy: ... filters, you could do allOf: [{anySatisfy: ...}, {anySatisfy: ...}]. When null or an empty list is passed, matches all documents. anyOf Matches records where any of the provided sub-filters evaluate to true. This works just like an OR operator in SQL. When null is passed, matches all documents. When an empty list is passed, this part of the filter matches no documents. anySatisfy Matches records where any of the list elements match the provided sub-filter. When null or an empty object is passed, matches all documents. count Used to filter on the number of non-null elements in this list field. When null or an empty object is passed, matches all documents. equalToAnyOf Matches records where the field value is equal to any of the provided values. This works just like an IN operator in SQL. When null is passed, matches all documents. When an empty list is passed, this part of the filter matches no documents. When null is passed in the list, this part of the filter matches records where the field value is null. gt Matches records where the field value is greater than (>) the provided value. When null is passed, matches all documents. gte Matches records where the field value is greater than or equal to (>=) the provided value. When null is passed, matches all documents. lt Matches records where the field value is less than (<) the provided value. When null is passed, matches all documents. lte Matches records where the field value is less than or equal to (<=) the provided value. When null is passed, matches all documents. matchesPhrase Matches records where the field value has a phrase matching the provided phrase using full text search. This is stricter than matchesQuery: all terms must match and be in the same order as the provided phrase. When null is passed, matches all documents. matchesQuery Matches records where the field value matches the provided query using full text search. This is more lenient than matchesPhrase: the order of terms is ignored, and, by default, only one search term is required to be in the field value. When null is passed, matches all documents. near Matches records where the field’s geographic location is within a specified distance from the location identified by latitude and longitude. When null or an empty object is passed, matches all documents. not Matches records where the provided sub-filter evaluates to false. This works just like a NOT operator in SQL. When null or an empty object is passed, matches no documents. timeOfDay Matches records based on the time-of-day of the DateTime values. When null or an empty object is passed, matches no documents. ### ElasticGraph Query API: Comparison Filtering ElasticGraph Query API: Comparison Filtering Try these example queries by visiting the GraphiQL UI after booting locally. Copy code Copied! $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always ElasticGraph offers a standard set of comparison filter predicates: gt Matches records where the field value is greater than (>) the provided value. When null is passed, matches all documents. gte Matches records where the field value is greater than or equal to (>=) the provided value. When null is passed, matches all documents. lt Matches records where the field value is less than (<) the provided value. When null is passed, matches all documents. lte Matches records where the field value is less than or equal to (<=) the provided value. When null is passed, matches all documents. Here’s an example: Copy code Copied! query FindArtistsFormedIn90s { artists(filter: { bio: {yearFormed: {gte: 1990, lt: 2000}} }) { nodes { name bio { yearFormed } albums { name } } } } ```shell $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always ``` ```graphql query FindArtistsFormedIn90s { artists(filter: { bio: {yearFormed: {gte: 1990, lt: 2000}} }) { nodes { name bio { yearFormed } albums { name } } } } ``` ### ElasticGraph Query API: Filter Conjunctions ElasticGraph Query API: Filter Conjunctions Try these example queries by visiting the GraphiQL UI after booting locally. Copy code Copied! $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always ElasticGraph supports two conjunction predicates: allOf Matches records where all of the provided sub-filters evaluate to true. This works just like an AND operator in SQL. Note: multiple filters are automatically ANDed together. This is only needed when you have multiple filters that can’t be provided on a single filter input because of collisions between key names. For example, if you want to provide multiple anySatisfy: ... filters, you could do allOf: [{anySatisfy: ...}, {anySatisfy: ...}]. When null or an empty list is passed, matches all documents. anyOf Matches records where any of the provided sub-filters evaluate to true. This works just like an OR operator in SQL. When null is passed, matches all documents. When an empty list is passed, this part of the filter matches no documents. By default, multiple filters are ANDed together. For example, this query finds artists formed after the year 2000 with BLUES as one of their genres: Copy code Copied! query FindModernBluesArtists { artists(filter: { bio: {yearFormed: {gt: 2000}} genres: {anySatisfy: {equalToAnyOf: [BLUES]}} }) { nodes { name bio { yearFormed description } } } } ORing subfilters with anyOf To instead find artists who were formed after the year 2000 OR play BLUES music, you can pass the sub-filters as a list-of-objects to anyOf: Copy code Copied! query FindModernOrBluesArtists { artists(filter: { anyOf: [ {bio: {yearFormed: {gt: 2000}}} {genres: {anySatisfy: {equalToAnyOf: [BLUES]}}} ] }) { nodes { name bio { yearFormed description } } } } anyOf is available at all levels of the filtering structure so that you can OR sub-filters anywhere you like. ANDing subfilters with allOf allOf is rarely needed since multiple filters are ANDed together by default. But it can come in handy when you’d otherwise have a duplicate key collision on a filter input. One case where this comes in handy is when using anySatisfy to filter on a list. Consider this query: Copy code Copied! query ArtistsWithPlatinum90sAlbum { artists(filter: { albums: { anySatisfy: { soldUnits: {gte: 1000000} releasedOn: {gte: "1990-01-01", lt: "2000-01-01"} } } }) { nodes { name albums { name releasedOn soldUnits } } } } This query finds artists who released an album in the 90’s that sold more than million copies. If you wanted to broaden the query to find artists with at least one 90’s album and at least one platinum-selling album–without requiring it to be the same album–you could do this: Copy code Copied! query ArtistsWith90sAlbumAndPlatinumAlbum { artists(filter: { albums: { allOf: [ {anySatisfy: {soldUnits: {gte: 1000000}}} {anySatisfy: {releasedOn: {gte: "1990-01-01", lt: "2000-01-01"}}} ] } }) { nodes { name albums { name releasedOn soldUnits } } } } GraphQL input objects don’t allow duplicate keys, so albums: {anySatisfy: {...}, anySatisfy: {...}} isn’t supported, but allOf enables this use case. Warning: Always Pass a List When using allOf or anyOf, be sure to pass the sub-filters as a list. If you instead pass them as an object, it won’t work as expected. Consider this query: Copy code Copied! query AnyOfGotcha { artists(filter: { bio: { anyOf: { yearFormed: {gt: 2000} description: {matchesQuery: {query: "accordion"}} } } }) { nodes { name bio { yearFormed description } } } } While this query will return results, it doesn’t behave as it appears. The GraphQL spec mandates that list inputs coerce non-list values into a list of one value. In this case, that means that the anyOf expression is coerced into this: Copy code Copied! query AnyOfGotcha { artists(filter: { bio: { anyOf: [{ yearFormed: {gt: 2000} description: {matchesQuery: {query: "accordion"}} }] } }) { # ... } } Using anyOf with only a single sub-expression, as we have here, doesn’t do anything; the query is equivalent to: Copy code Copied! query AnyOfGotcha { artists(filter: { bio: { yearFormed: {gt: 2000} description: {matchesQuery: {query: "accordion"}} } }) { # ... } } ```shell $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always ``` ```graphql query FindModernBluesArtists { artists(filter: { bio: {yearFormed: {gt: 2000}} genres: {anySatisfy: {equalToAnyOf: [BLUES]}} }) { nodes { name bio { yearFormed description } } } } ``` ```graphql query FindModernOrBluesArtists { artists(filter: { anyOf: [ {bio: {yearFormed: {gt: 2000}}} {genres: {anySatisfy: {equalToAnyOf: [BLUES]}}} ] }) { nodes { name bio { yearFormed description } } } } ``` ```graphql query ArtistsWithPlatinum90sAlbum { artists(filter: { albums: { anySatisfy: { soldUnits: {gte: 1000000} releasedOn: {gte: "1990-01-01", lt: "2000-01-01"} } } }) { nodes { name albums { name releasedOn soldUnits } } } } ``` ```graphql query ArtistsWith90sAlbumAndPlatinumAlbum { artists(filter: { albums: { allOf: [ {anySatisfy: {soldUnits: {gte: 1000000}}} {anySatisfy: {releasedOn: {gte: "1990-01-01", lt: "2000-01-01"}}} ] } }) { nodes { name albums { name releasedOn soldUnits } } } } ``` ```graphql query AnyOfGotcha { artists(filter: { bio: { anyOf: { yearFormed: {gt: 2000} description: {matchesQuery: {query: "accordion"}} } } }) { nodes { name bio { yearFormed description } } } } ``` ```graphql query AnyOfGotcha { artists(filter: { bio: { anyOf: [{ yearFormed: {gt: 2000} description: {matchesQuery: {query: "accordion"}} }] } }) { # ... } } ``` ```graphql query AnyOfGotcha { artists(filter: { bio: { yearFormed: {gt: 2000} description: {matchesQuery: {query: "accordion"}} } }) { # ... } } ``` ### ElasticGraph Query API: DateTime Filtering ElasticGraph Query API: DateTime Filtering Try these example queries by visiting the GraphiQL UI after booting locally. Copy code Copied! $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always ElasticGraph supports three different date/time types: Date A date, represented as an ISO 8601 date string. Example: "2024-10-15". DateTime A timestamp, represented as an ISO 8601 time string. Example: "2024-10-15T07:23:15Z". LocalTime A local time such as "23:59:33" or "07:20:47.454" without a time zone or offset, formatted based on the partial-time portion of RFC3339. All three support the standard set of equality and comparison predicates. When using comparison predicates to cover a range, it’s usually simplest to pair gte with lt: Copy code Copied! query Find2024Shows { artists(filter: { tours: {anySatisfy: {shows: {anySatisfy: { startedAt: { gte: "2024-01-01T00:00:00Z" lt: "2025-01-01T00:00:00Z" # Using gte/lt to fully cover the range is simpler than gte/lte: # gte: "2024-01-01T00:00:00Z" # lte: "2024-12-31T23:59:99.999Z" # ...and simpler than gt/lt: # gt: "2023-12-31T23:59:99.999Z" # lt: "2025-01-01T00:00:00Z" } }}}} }) { nodes { name tours { shows { venue { id } startedAt } } } } } In addition, DateTime fields support one more filtering operator: timeOfDay Matches records based on the time-of-day of the DateTime values. When null or an empty object is passed, matches no documents. For example, you could use it to find shows that started between noon and 3 pm on any date: Copy code Copied! query FindEarlyAfternoonShows { artists(filter: { tours: {anySatisfy: {shows: {anySatisfy: { startedAt: { timeOfDay: { timeZone: "America/Los_Angeles" gte: "12:00:00" lt: "15:00:00" } } }}}} }) { nodes { name tours { shows { venue { id } startedAt } } } } } ```shell $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always ``` ```graphql query Find2024Shows { artists(filter: { tours: {anySatisfy: {shows: {anySatisfy: { startedAt: { gte: "2024-01-01T00:00:00Z" lt: "2025-01-01T00:00:00Z" # Using gte/lt to fully cover the range is simpler than gte/lte: # gte: "2024-01-01T00:00:00Z" # lte: "2024-12-31T23:59:99.999Z" # ...and simpler than gt/lt: # gt: "2023-12-31T23:59:99.999Z" # lt: "2025-01-01T00:00:00Z" } }}}} }) { nodes { name tours { shows { venue { id } startedAt } } } } } ``` ```graphql query FindEarlyAfternoonShows { artists(filter: { tours: {anySatisfy: {shows: {anySatisfy: { startedAt: { timeOfDay: { timeZone: "America/Los_Angeles" gte: "12:00:00" lt: "15:00:00" } } }}}} }) { nodes { name tours { shows { venue { id } startedAt } } } } } ``` ### ElasticGraph Query API: Equality Filtering ElasticGraph Query API: Equality Filtering Try these example queries by visiting the GraphiQL UI after booting locally. Copy code Copied! $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always The most commonly used predicate supports equality filtering: equalToAnyOf Matches records where the field value is equal to any of the provided values. This works just like an IN operator in SQL. When null is passed, matches all documents. When an empty list is passed, this part of the filter matches no documents. When null is passed in the list, this part of the filter matches records where the field value is null. Here’s a basic example: Copy code Copied! query FindU2OrRadiohead { artists(filter: { name: {equalToAnyOf: ["U2", "Radiohead"]} }) { nodes { name bio { yearFormed } } } } Unlike the SQL IN operator, you can find records with null values if you put null in the list: Copy code Copied! query FindUnnamedVenues { venues(filter: { name: {equalToAnyOf: [null]} }) { nodes { name # will be null on all returned nodes capacity } } } ```shell $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always ``` ```graphql query FindU2OrRadiohead { artists(filter: { name: {equalToAnyOf: ["U2", "Radiohead"]} }) { nodes { name bio { yearFormed } } } } ``` ```graphql query FindUnnamedVenues { venues(filter: { name: {equalToAnyOf: [null]} }) { nodes { name # will be null on all returned nodes capacity } } } ``` ### ElasticGraph Query API: Full Text Search ElasticGraph Query API: Full Text Search Try these example queries by visiting the GraphiQL UI after booting locally. Copy code Copied! $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always ElasticGraph supports two full-text search filtering predicates: matchesPhrase Matches records where the field value has a phrase matching the provided phrase using full text search. This is stricter than matchesQuery: all terms must match and be in the same order as the provided phrase. When null is passed, matches all documents. matchesQuery Matches records where the field value matches the provided query using full text search. This is more lenient than matchesPhrase: the order of terms is ignored, and, by default, only one search term is required to be in the field value. When null is passed, matches all documents. Matches Query matchesQuery is the more lenient of the two predicates. It’s designed to match broadly. Here’s an example: Copy code Copied! query AccordionOrViolinSearch { artists(filter: { bio: { description: { matchesQuery: { query: "accordion violin" } } } }) { nodes { name bio { description } } } } This query will match artists with bios like: Renowned for his mesmerizing performances, Luca “The Breeze” Fontana captivates audiences with his accordion, weaving intricate melodies that dance between the notes of traditional folk and modern jazz. Sylvia Varela’s avant-garde violin playing defies tradition, blending haunting dissonance with unexpected rhythms. Notably, the description needs accordion OR violin, but not both. In addition, it would match an artist bio that mentioned “viola” since it supports fuzzy matching by default and “viola” is only 2 edits away from “violin”. Arguments are supported to control both aspects to make matching stricter: Copy code Copied! query AccordionAndViolinStrictSearch { artists(filter: { bio: { description:{ matchesQuery: { query: "accordion violin" requireAllTerms: true allowedEditsPerTerm: NONE } } } }) { nodes { name bio { description } } } } Matches Phrase matchesPhrase is even stricter: it requires all terms in the provided order (matchesQuery doesn’t care about order). It’s particularly useful when you want to search on a particular multi-word expression: Copy code Copied! query PhraseSearch { artists(filter: { bio: { description:{ matchesPhrase: { phrase: "unique musical identity" } } } }) { nodes { name bio { description } } } } Bypassing matchesPhrase and matchesQuery In order to make a matchesPhrase or matchesQuery filter optional, you can supply null to the MatchesQueryFilterInput parameter, like this: Copy code Copied! query OptionalMatchingFilter( $optionalMatchQuery: MatchesQueryFilterInput = null ) { artists(filter: { bio: { description: { matchesQuery: $optionalMatchQuery } } }) { nodes { name bio { description } } } } ```shell $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always ``` ```graphql query AccordionOrViolinSearch { artists(filter: { bio: { description: { matchesQuery: { query: "accordion violin" } } } }) { nodes { name bio { description } } } } ``` ```graphql query AccordionAndViolinStrictSearch { artists(filter: { bio: { description:{ matchesQuery: { query: "accordion violin" requireAllTerms: true allowedEditsPerTerm: NONE } } } }) { nodes { name bio { description } } } } ``` ```graphql query PhraseSearch { artists(filter: { bio: { description:{ matchesPhrase: { phrase: "unique musical identity" } } } }) { nodes { name bio { description } } } } ``` ```graphql query OptionalMatchingFilter( $optionalMatchQuery: MatchesQueryFilterInput = null ) { artists(filter: { bio: { description: { matchesQuery: $optionalMatchQuery } } }) { nodes { name bio { description } } } } ``` ### ElasticGraph Query API: Geographic Filtering ElasticGraph Query API: Geographic Filtering Try these example queries by visiting the GraphiQL UI after booting locally. Copy code Copied! $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always The GeoLocation type supports a special predicate: near Matches records where the field’s geographic location is within a specified distance from the location identified by latitude and longitude. When null or an empty object is passed, matches all documents. Here’s an example of this predicate: Copy code Copied! query FindAsianVenues { venues(filter: { location: {near: { latitude: 49.102271 longitude: 87.143660 maxDistance: 2000 unit: MILE }} }) { nodes { name capacity } } } ```shell $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always ``` ```graphql query FindAsianVenues { venues(filter: { location: {near: { latitude: 49.102271 longitude: 87.143660 maxDistance: 2000 unit: MILE }} }) { nodes { name capacity } } } ``` ### ElasticGraph Query API: Filtering ElasticGraph Query API: Filtering Try these example queries by visiting the GraphiQL UI after booting locally. Copy code Copied! $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always Use filter: on a root query field to narrow down the returned results: Copy code Copied! query FindArtist { byName: artists(filter: { name: {equalToAnyOf: ["U2"]} }) { nodes { name bio { yearFormed } } } byBioYearFounded: artists(filter: { bio: {yearFormed: {gt: 2000}} }) { nodes { name bio { yearFormed } } } } As shown here, filters have two basic parts: A field path: this specifies which field you want to filter on. When dealing with a nested field (e.g. bio.yearFormed), you’ll need to provide a nested object matching the field structure. A filtering predicate: this specifies a filtering operator to apply at the field path. Empty Filters Filters with a value of null or empty object ({}) match all documents. When negated with not, no documents are matched. The filters in this query match all documents: Copy code Copied! query EmptyFilters { artists(filter: { name: {equalToAnyOf: null} bio: {yearFormed: {}} }) { nodes { name bio { yearFormed } } } } This particularly comes in handy when using query variables. It allows a query to flexibly support a wide array of filters without requiring them to all be used for an individual request. Copy code Copied! query FindArtists( $names: [String!] = null $yearFormed_gt: Int = null $albumNames: [String!] = null ) { artists(filter: { name: {equalToAnyOf: $names} bio: {yearFormed: {gt: $yearFormed_gt}} albums: {anySatisfy: {name: {equalToAnyOf: $albumNames}}} }) { nodes { name bio { yearFormed } albums { name } } } } ```shell $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always ``` ```graphql query FindArtist { byName: artists(filter: { name: {equalToAnyOf: ["U2"]} }) { nodes { name bio { yearFormed } } } byBioYearFounded: artists(filter: { bio: {yearFormed: {gt: 2000}} }) { nodes { name bio { yearFormed } } } } ``` ```graphql query EmptyFilters { artists(filter: { name: {equalToAnyOf: null} bio: {yearFormed: {}} }) { nodes { name bio { yearFormed } } } } ``` ```graphql query FindArtists( $names: [String!] = null $yearFormed_gt: Int = null $albumNames: [String!] = null ) { artists(filter: { name: {equalToAnyOf: $names} bio: {yearFormed: {gt: $yearFormed_gt}} albums: {anySatisfy: {name: {equalToAnyOf: $albumNames}}} }) { nodes { name bio { yearFormed } albums { name } } } } ``` ### ElasticGraph Query API: List Filtering ElasticGraph Query API: List Filtering Try these example queries by visiting the GraphiQL UI after booting locally. Copy code Copied! $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always ElasticGraph supports a couple predicates for filtering on list fields: anySatisfy Matches records where any of the list elements match the provided sub-filter. When null or an empty object is passed, matches all documents. count Used to filter on the number of non-null elements in this list field. When null or an empty object is passed, matches all documents. Filtering on list elements with anySatisfy When filtering on a list field, use anySatisfy to find records with matching list elements. This query, for example, will find artists that released a platinum-selling album in the 1990s: Copy code Copied! query ArtistsWithPlatinum90sAlbum { artists(filter: { albums: { anySatisfy: { soldUnits: {gte: 1000000} releasedOn: {gte: "1990-01-01", lt: "2000-01-01"} } } }) { nodes { name albums { name releasedOn soldUnits } } } } Warning One thing to bear in mind: this query is selecting which artists to return, not which albums to return. You might expect that the returned nodes.albums would all be platinum-selling 90s albums, but that’s not how the filtering API works. Only artists that had a platinum-selling 90s album will be returned, and for each returned artists, all their albums will be returned–even ones that sold poorly or were released outside the 1990s. Filtering on the list size with count If you’d rather filter on the size of a list, use count: Copy code Copied! query FindProlificArtists { artists(filter: { albums: {count: {gte: 5}} }) { nodes { name albums { name } } } } ```shell $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always ``` ```graphql query ArtistsWithPlatinum90sAlbum { artists(filter: { albums: { anySatisfy: { soldUnits: {gte: 1000000} releasedOn: {gte: "1990-01-01", lt: "2000-01-01"} } } }) { nodes { name albums { name releasedOn soldUnits } } } } ``` ```graphql query FindProlificArtists { artists(filter: { albums: {count: {gte: 5}} }) { nodes { name albums { name } } } } ``` ### ElasticGraph Query API: Filter Negation ElasticGraph Query API: Filter Negation Try these example queries by visiting the GraphiQL UI after booting locally. Copy code Copied! $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always ElasticGraph supports a negation predicate: not Matches records where the provided sub-filter evaluates to false. This works just like a NOT operator in SQL. When null or an empty object is passed, matches no documents. One of the more common use cases is to filter to non-null values: Copy code Copied! query FindArtistsWithBios { artists(filter: { bio: {description: {not: {equalToAnyOf: [null]}}} }) { nodes { name bio { description } } } } not is available at any level of a filter. All of these are equivalent: bio: {description: {not: {equalToAnyOf: [null]}}} bio: {not: {description: {equalToAnyOf: [null]}}} not: {bio: {description: {equalToAnyOf: [null]}}} ```shell $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always ``` ```graphql query FindArtistsWithBios { artists(filter: { bio: {description: {not: {equalToAnyOf: [null]}}} }) { nodes { name bio { description } } } } ``` ### Query API Query API Learn how to effectively use ElasticGraph’s powerful Query API to search, filter, sort, and aggregate your data. Documentation Sections Overview Filtering Available Predicates Equality Comparison DateTime Full Text Search Geographic Negation Conjunctions List Aggregations Aggregated Values Counts Grouping Sub-Aggregations Sorting Pagination ### ElasticGraph Query API: Overview ElasticGraph Query API: Overview Try these example queries by visiting the GraphiQL UI after booting locally. Copy code Copied! $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always ElasticGraph provides an extremely flexible GraphQL query API. As with every GraphQL API, you request the fields you want: Copy code Copied! query ListArtistAlbums { artists { nodes { name albums { name releasedOn tracks { name } } } } } If you’re just getting started with GraphQL, we recommend you review the graphql.org learning materials. ElasticGraph offers a number of query features that go far beyond a traditional GraphQL API (we like to call it “GraphQL with superpowers”). Each of these features is implemented directly by the ElasticGraph framework, ensuring consistent, predictable behavior across your entire schema. Filtering ElasticGraph’s filtering support allows clients to filter on any field defined in the schema with a wide array of filtering predicates. Native support is included to negate and combine filters in arbitrary ways. Aggregations ElasticGraph includes an intuitive, flexible aggregations API which allows clients to group records by any field in your schema. Within each grouping, clients can count records or compute aggregated values over the set of values from any field. Further sub-aggregations can be applied on list-of-object fields. Sorting ElasticGraph allows clients to sort by any field defined in the schema. Pagination ElasticGraph implements the industry standard Relay GraphQL Cursor Connections Specification to support pagination, and extends it with support for totalEdgeCount and nodes. Pagination is available under both a “raw data” field (e.g artists) and under an aggregations field (e.g. artistAggregations). ```shell $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always ``` ```graphql query ListArtistAlbums { artists { nodes { name albums { name releasedOn tracks { name } } } } } ``` ### ElasticGraph Query API: Pagination ElasticGraph Query API: Pagination Try these example queries by visiting the GraphiQL UI after booting locally. Copy code Copied! $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always To provide pagination, ElasticGraph implements the Relay GraphQL Cursor Connections Specification. Here’s an example query showing pagination in action: Copy code Copied! query PaginationExample($cursor: Cursor) { artists(first: 10, after: $cursor) { pageInfo { hasNextPage endCursor } edges { node { name albums { name } } } } } This example uses first:, after:, and pageInfo { hasNextPage, endCursor } to implement forward pagination. If pageInfo.hasNextPage indicates there is another page, the client can pass pageInfo.endCursor as the $cursor value on the next request. Relay backwards pagination is also supported using last:, before:, and pageInfo { hasPreviousPage, startCursor }. In addition, ElasticGraph offers some additional features beyond the Relay spec. Total Edge Count As an extension to the Relay spec, ElasticGraph offers a totalEdgeCount field alongside edges and pageInfo. It can be used to get a total count of matching records: Copy code Copied! query Count21stCenturyArtists { artists(filter: { bio: {yearFormed: {gte: 2000}} }) { totalEdgeCount } } Note totalEdgeCount is not available under an aggregations field. Nodes As an alternative to edges.node, ElasticGraph offers nodes. This is recommended over edges except when you need a per-node cursor (which is available under edges) since it removes an extra layer of nesting, providing a simpler response structure: Copy code Copied! query PaginationNodes($cursor: Cursor) { artists(first: 10, after: $cursor) { pageInfo { hasNextPage endCursor } nodes { name albums { name } } } } ```shell $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always ``` ```graphql query PaginationExample($cursor: Cursor) { artists(first: 10, after: $cursor) { pageInfo { hasNextPage endCursor } edges { node { name albums { name } } } } } ``` ```graphql query Count21stCenturyArtists { artists(filter: { bio: {yearFormed: {gte: 2000}} }) { totalEdgeCount } } ``` ```graphql query PaginationNodes($cursor: Cursor) { artists(first: 10, after: $cursor) { pageInfo { hasNextPage endCursor } nodes { name albums { name } } } } ``` ### ElasticGraph Query API: Sorting ElasticGraph Query API: Sorting Try these example queries by visiting the GraphiQL UI after booting locally. Copy code Copied! $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always Use orderBy: on a root query field to control how the results are sorted: Copy code Copied! query ListArtists { artists(orderBy: [name_ASC, bio_yearFormed_DESC]) { nodes { name albums { name } } } } This query, for example, would sort by name (ascending), with bio.yearFormed (descending) as a tie breaker. When no orderBy: argument is provided, ElasticGraph will sort according to the default sort configured on the index. ```shell $ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always ``` ```graphql query ListArtists { artists(orderBy: [name_ASC, bio_yearFormed_DESC]) { nodes { name albums { name } } } } ```