class GraphQL::Schema::BuildFromDefinition::Builder::TypeResolver
Attributes
Directive applications waiting for {Builder#apply_queued_directives}
Public Class Methods
# File lib/graphql/schema/build_from_definition.rb, line 822 def initialize(lookup_hash, directives, queued_directives, type_classes, &missing_type_handler) @lookup_hash = lookup_hash @directives = directives @queued_directives = queued_directives @type_classes = type_classes @missing_type_handler = missing_type_handler end
Public Instance Methods
# File lib/graphql/schema/build_from_definition.rb, line 846 def build_interface_now(interface_name) @build_interface&.call(interface_name, self) end
Source
# File lib/graphql/schema/build_from_definition.rb, line 890 def call(ast_node) case ast_node when GraphQL::Language::Nodes::TypeName type_name = ast_node.name if @lookup_hash.key?(type_name) @lookup_hash[type_name] else @missing_type_handler.call(type_name) end when GraphQL::Language::Nodes::NonNullType call(ast_node.of_type).to_non_null_type when GraphQL::Language::Nodes::ListType call(ast_node.of_type).to_list_type when String @directives[ast_node] ||= @missing_type_handler.call(ast_node) else raise "Unexpected ast_node: #{ast_node.inspect}" end end
Source
# File lib/graphql/schema/build_from_definition.rb, line 875 def directive_class(name) @directives[name] end
The already-defined directive class named name, or nil if there isnโt one yet
# File lib/graphql/schema/build_from_definition.rb, line 879 def directive_without_arguments?(name) @directives_without_arguments ||= {} if @directives_without_arguments.key?(name) @directives_without_arguments[name] else dir_class = @directives[name] # Don't cache unknown directives, they might be defined later dir_class ? (@directives_without_arguments[name] = dir_class.all_argument_definitions.empty?) : false end end
Source
# File lib/graphql/schema/build_from_definition.rb, line 865 def field_resolve_methods @field_resolve_methods ||= FieldResolveMethods.new end
# File lib/graphql/schema/build_from_definition.rb, line 855 def get_argument(owner, argument_name) @arguments_by_owner ||= {}.compare_by_identity owner_arguments = @arguments_by_owner[owner] ||= {} if owner_arguments.key?(argument_name) owner_arguments[argument_name] else owner_arguments[argument_name] = owner.get_argument(argument_name) end end
Like owner.get_argument(argument_name), but cached. Directives are applied after types are built, so their arguments donโt change while this cache is used.
# File lib/graphql/schema/build_from_definition.rb, line 838 def interface_module(type_name, base_type) @type_classes.delete(type_name) || Builder.new_interface_module(type_name, base_type) end
Source
# File lib/graphql/schema/build_from_definition.rb, line 870 def register(type) @lookup_hash[type.graphql_name] = type end
Add type to the lookup hash. Types call this before building their members, so that references back to them (including cycles) find this type.
# File lib/graphql/schema/build_from_definition.rb, line 831 def type_class(type_name, base_type) @type_classes.delete(type_name) || Class.new(base_type) { #: self as singleton(GraphQL::Schema::Member) graphql_name(type_name) } end
The class made ahead of time for type_name (returned once, to be built), or a new subclass of base_type