Sha256: 3a0172c9142724699372a6a338b90fe5df6a616143757fa7a096489af65007a4

Contents?: true

Size: 1.43 KB

Versions: 44

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true

module GraphQL
  class Schema
    class Member
      module TypeSystemHelpers
        def initialize(*args, &block)
          super
          @to_non_null_type ||= nil
          @to_list_type ||= nil
        end
        ruby2_keywords :initialize if respond_to?(:ruby2_keywords, true)

        # @return [Schema::NonNull] Make a non-null-type representation of this type
        def to_non_null_type
          @to_non_null_type ||= GraphQL::Schema::NonNull.new(self)
        end

        # @return [Schema::List] Make a list-type representation of this type
        def to_list_type
          @to_list_type ||= GraphQL::Schema::List.new(self)
        end

        # @return [Boolean] true if this is a non-nullable type. A nullable list of non-nullables is considered nullable.
        def non_null?
          false
        end

        # @return [Boolean] true if this is a list type. A non-nullable list is considered a list.
        def list?
          false
        end

        def to_type_signature
          graphql_name
        end

        # @return [GraphQL::TypeKinds::TypeKind]
        def kind
          raise GraphQL::RequiredImplementationMissingError, "No `.kind` defined for #{self}"
        end

        private

        def inherited(subclass)
          subclass.class_eval do
            @to_non_null_type ||= nil
            @to_list_type ||= nil
          end
          super
        end
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
graphql-2.2.16 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.1.13 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.0.31 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.3.2 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.3.1 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.3.0 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.2.14 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.2.13 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.2.12 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.0.29 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.1.12 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.2.11 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.2.10 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.2.9 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.2.8 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.2.7 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.2.6 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.1.11 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.0.28 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.2.5 lib/graphql/schema/member/type_system_helpers.rb