Class: ElasticGraph::SchemaDefinition::SchemaElements::ObjectType

Inherits:
TypeWithSubfields
  • Object
show all
Includes:
Mixins::HasIndices, Mixins::ImplementsInterfaces, Mixins::SupportsFilteringAndAggregation
Defined in:
lib/elastic_graph/schema_definition/schema_elements/object_type.rb

Overview

Defines a [GraphQL object type](graphql.org/learn/schema/#object-types-and-fields) 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::HasIndices

#default_graphql_resolver, #runtime_metadata_overrides

Attributes inherited from TypeWithSubfields

#field_factory, #graphql_fields_by_name, #indexing_fields_by_name_in_index, #relay_pagination_type, #reserved_field_names, #schema_def_state, #schema_kind, #type_ref, #wrapping_type

Attributes included from Mixins::HasDocumentation

#doc_comment

Instance Method Summary collapse

Methods included from Mixins::ImplementsInterfaces

#implemented_interfaces, #implements, #to_sdl, #verify_graphql_correctness!

Methods included from Mixins::HasIndices

#abstract?, #derive_indexed_type_fields, #derived_indexed_types, #fields_with_sources, #index, #index_def, #indexed?, #override_runtime_metadata, #plural_root_query_field_name, #resolve_fields_with, #root_query_fields, #root_query_fields_customizations, #runtime_metadata, #singular_root_query_field_name

Methods included from Mixins::SupportsFilteringAndAggregation

#derived_graphql_types, #does_not_support?, #has_custom_mapping_type?, #supports?

Methods inherited from TypeWithSubfields

#aggregated_values_type, #current_sources, #deleted_field, #field, #generate_sdl, #index_field_runtime_metadata_tuples, #indexed?, #name, #paginated_collection_field, #relates_to_many, #relates_to_one, #renamed_from, #to_indexing_field_type, #to_sdl

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, #derived_field_customizations_by_name_for_type, #derived_field_customizations_by_type_and_field_name, #derived_type_customizations_by_name, #derived_type_customizations_for_type

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!

Constructor Details

#initialize(schema_def_state, name) ⇒ ObjectType

Returns a new instance of ObjectType.



42
43
44
45
46
47
48
49
# File 'lib/elastic_graph/schema_definition/schema_elements/object_type.rb', line 42

def initialize(schema_def_state, name)
  field_factory = schema_def_state.factory.method(:new_field)
  schema_def_state.factory.new_type_with_subfields(:type, name, wrapping_type: self, field_factory: field_factory) do |type|
    __skip__ = super(type) do
      yield self
    end
  end
end