Module: ElasticGraph::Apollo::SchemaDefinition::FactoryExtension

Defined in:
lib/elastic_graph/apollo/schema_definition/factory_extension.rb

Overview

Extension module applied to ‘ElasticGraph::SchemaDefinition::Factory` to add Apollo tagging support.

Instance Method Summary collapse

Instance Method Details

#new_argument(field, name, value_type) ⇒ Object



41
42
43
44
45
46
# File 'lib/elastic_graph/apollo/schema_definition/factory_extension.rb', line 41

def new_argument(field, name, value_type)
  super(field, name, value_type) do |type|
    type.extend ArgumentExtension
    yield type if block_given?
  end
end

#new_enum_type(name) ⇒ Object



48
49
50
51
52
53
# File 'lib/elastic_graph/apollo/schema_definition/factory_extension.rb', line 48

def new_enum_type(name)
  super(name) do |type|
    type.extend EnumTypeExtension
    yield type
  end
end

#new_enum_value(name, original_name) ⇒ Object



55
56
57
58
59
60
# File 'lib/elastic_graph/apollo/schema_definition/factory_extension.rb', line 55

def new_enum_value(name, original_name)
  super(name, original_name) do |type|
    type.extend EnumValueExtension
    yield type if block_given?
  end
end

#new_graphql_sdl_enumerator(all_types_except_root_query_type) ⇒ Object



35
36
37
38
39
# File 'lib/elastic_graph/apollo/schema_definition/factory_extension.rb', line 35

def new_graphql_sdl_enumerator(all_types_except_root_query_type)
  super.tap do |enum|
    enum.extend GraphQLSDLEnumeratorExtension
  end
end

#new_input_type(name) ⇒ Object



62
63
64
65
66
67
# File 'lib/elastic_graph/apollo/schema_definition/factory_extension.rb', line 62

def new_input_type(name)
  super(name) do |type|
    type.extend InputTypeExtension
    yield type
  end
end

#new_interface_type(name) ⇒ Object



69
70
71
72
73
74
# File 'lib/elastic_graph/apollo/schema_definition/factory_extension.rb', line 69

def new_interface_type(name)
  super(name) do |type|
    type.extend InterfaceTypeExtension
    yield type
  end
end

#new_object_type(name) ⇒ Object

Here we override ‘object_type` in order to automatically add the apollo `@key` directive to indexed types.



77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/elastic_graph/apollo/schema_definition/factory_extension.rb', line 77

def new_object_type(name)
  super(name) do |raw_type|
    raw_type.extend ObjectTypeExtension
    type = raw_type # : ElasticGraph::SchemaDefinition::SchemaElements::ObjectType & ObjectTypeExtension

    yield type if block_given?

    if type.indexed? && type.graphql_fields_by_name.key?("id")
      type.apollo_key fields: "id"
    end
  end
end

#new_scalar_type(name) ⇒ Object



90
91
92
93
94
95
# File 'lib/elastic_graph/apollo/schema_definition/factory_extension.rb', line 90

def new_scalar_type(name)
  super(name) do |type|
    type.extend ScalarTypeExtension
    yield type
  end
end

#new_union_type(name) ⇒ Object



97
98
99
100
101
102
# File 'lib/elastic_graph/apollo/schema_definition/factory_extension.rb', line 97

def new_union_type(name)
  super(name) do |type|
    type.extend UnionTypeExtension
    yield type
  end
end