lib/rails/graphql/type_map.rb
def register(object)
        namespaces = object.namespaces.dup
        namespaces = namespaces.is_a?(Set) ? namespaces.to_a : Array.wrap(namespaces)

        base_namespace = namespaces.shift || :base
        base_class = find_base_class(object)
        ensure_base_class!(base_class)

        # Cache the name, the key, and the alias proc
        object_name = object.gql_name
        object_key = object.to_sym
        alias_proc = -> do
          fetch(object_key,
            base_class: base_class,
            namespaces: base_namespace,
            exclusive: true,
          )
        end

        # Register the main type object
        add(base_namespace, base_class, object_key, -> { object })

        # Register all the aliases plus the object name
        aliases = object.try(:aliases) || []
        [object_name, *aliases].each do |alias_name|
          add(base_namespace, base_class, alias_name, alias_proc)
        end

        # For each remaining namespace, register a key and a name alias
        namespaces.product([object_key, object_name, *aliases]) do |(namespace, key_or_name)|
          add(namespace, base_class, key_or_name, alias_proc)
        end

        # Return the object for chain purposes
        @objects += 1
        object
      end
# Register a given object, which must be a class where the namespaces and
# the base class can be inferred
Register a given object, which must be a class where the namespaces and
the base class can be inferred
Register a given object which must be a class where the namespaces and the base class can be inferred
def register(object)
        namespaces = object.namespaces.dup
        namespaces = namespaces.is_a?(Set) ? namespaces.to_a : Array.wrap(namespaces)
        base_namespace = namespaces.shift || :base
        base_class = find_base_class(object)
        ensure_base_class!(base_class)
        object_name = object.gql_name
        object_key = object.to_sym
        alias_proc = -> do
          fetch(object_key,
            base_class: base_class,
            namespaces: base_namespace,
            exclusive: true,
          )
        end
        add(base_namespace, base_class, object_key, -> { object })
        aliases = object.try(:aliases) || []
        [object_name, *aliases].each do |alias_name|
          add(base_namespace, base_class, alias_name, alias_proc)
        end
        namespaces.product([object_key, object_name, *aliases]) do |(namespace, key_or_name)|
          add(namespace, base_class, key_or_name, alias_proc)
        end
        @objects += 1
        object
      end
def register ( object ) namespaces = object . namespaces . dup namespaces = namespaces . is_a? ( Set ) ? namespaces . to_a : Array . wrap ( namespaces ) base_namespace = namespaces . shift || :base base_class = find_base_class ( object ) ensure_base_class! ( base_class ) object_name = object . gql_name object_key = object . to_sym alias_proc = -> do fetch ( object_key , base_class : base_class , namespaces : base_namespace , exclusive : true , ) end add ( base_namespace , base_class , object_key , -> { object } ) aliases = object . try ( :aliases ) || [ ] [ object_name , * aliases ] . each do | alias_name | add ( base_namespace , base_class , alias_name , alias_proc ) end namespaces . product ( [ object_key , object_name , * aliases ] ) do | ( namespace , key_or_name ) | add ( namespace , base_class , key_or_name , alias_proc ) end @objects += 1 object end
Register a given object, which must be a class where the namespaces and
the base class can be inferred
Register a given object which must be a class where the namespaces and the base class can be inferred
# Cache the name, the key, and the alias proc # Register the main type object # Register all the aliases plus the object name # For each remaining namespace, register a key and a name alias # Return the object for chain purposes
object