Sha256: 948740981af38f2cb308c132c1552c4922a7fb7598ca0116e9f574439e6e4dea

Contents?: true

Size: 1.35 KB

Versions: 26

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

module GraphQL
  class Schema
    class Member
      module TypeSystemHelpers
        def initialize(...)
          super
          @to_non_null_type ||= nil
          @to_list_type ||= nil
        end

        # @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

26 entries across 26 versions & 1 rubygems

Version Path
graphql-2.4.9 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.4.8 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.4.7 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.4.6 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.4.5 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.4.4 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.4.3 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.4.2 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.4.1 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.4.0 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.3.20 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.3.19 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.3.18 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.3.17 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.3.16 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.3.15 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.3.14 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.3.13 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.3.12 lib/graphql/schema/member/type_system_helpers.rb
graphql-2.3.11 lib/graphql/schema/member/type_system_helpers.rb