<commit_before># frozen_string_literal: true
module GraphQL
  # This type exposes fields on an object.
  #
  # @example defining a type for your IMDB clone
  #   MovieType = GraphQL::ObjectType.define do
  #     name "Movie"
  #     description "A full-length film or a short film"
  #     interfaces [ProductionInterface, DurationInterface]
  #
  #     field :runtimeMinutes, !types.Int, property: :runtime_minutes
  #     field :director, PersonType
  #     field :cast, CastType
  #     field :starring, types[PersonType] do
  #       argument :limit, types.Int
  #       resolve ->(object, args, ctx) {
  #         stars = object.cast.stars
  #         args[:limit] && stars = stars.limit(args[:limit])
  #         stars
  #       }
  #      end
  #   end
  #
  class ObjectType < GraphQL::BaseType
    accepts_definitions :interfaces, :fields, :mutation, field: GraphQL::Define::AssignObjectField
    accepts_definitions implements: ->(type, *interfaces) { type.add_interfaces(*interfaces) }

    attr_accessor :fields, :mutation
    ensure_defined(:fields, :mutation, :interfaces)

    # @!attribute fields
    #   @return [Hash<String => GraphQL::Field>] Map String fieldnames to their {GraphQL::Field} implementations

    # @!attribute mutation
    #   @return [GraphQL::Relay::Mutation, nil] The mutation this field was derived from, if it was derived from a mutation

    def initialize
      super
      @fields = {}
      @dirty_interfaces = []
    end

    def initialize_copy(other)
      super
      @clean_interfaces = nil
      @dirty_interfaces = other.dirty_interfaces.dup
      @fields = other.fields.dup
    end

    # @param new_interfaces [Array<GraphQL::Interface>] interfaces that this type implements
    def interfaces=(new_interfaces)
      @clean_interfaces = nil
      @dirty_interfaces = new_interfaces
    end

    def interfaces
      @clean_interfaces ||= begin
        if @dirty_interfaces.respond_to?(:map)
          @dirty_interfaces.map { |i_type| GraphQL::BaseType.resolve_related_type(i_type) }
        else
          @dirty_interfaces
        end
      end
    end

    # @param interface [GraphQL::Interface] add a new interface that this type implements
    def add_interfaces(*interfaces)
      @clean_interfaces = nil
      @dirty_interfaces ||= []
      @dirty_interfaces.push(*interfaces)
    end

    def kind
      GraphQL::TypeKinds::OBJECT
    end

    # @return [GraphQL::Field] The field definition for `field_name` (may be inherited from interfaces)
    def get_field(field_name)
      fields[field_name] || interface_fields[field_name]
    end<commit_msg>Deprecate `interfaces` in favour of `implements`<commit_after># frozen_string_literal: true
module GraphQL
  # This type exposes fields on an object.
  #
  # @example defining a type for your IMDB clone
  #   MovieType = GraphQL::ObjectType.define do
  #     name "Movie"
  #     description "A full-length film or a short film"
  #     interfaces [ProductionInterface, DurationInterface]
  #
  #     field :runtimeMinutes, !types.Int, property: :runtime_minutes
  #     field :director, PersonType
  #     field :cast, CastType
  #     field :starring, types[PersonType] do
  #       argument :limit, types.Int
  #       resolve ->(object, args, ctx) {
  #         stars = object.cast.stars
  #         args[:limit] && stars = stars.limit(args[:limit])
  #         stars
  #       }
  #      end
  #   end
  #
  class ObjectType < GraphQL::BaseType
    accepts_definitions :interfaces, :fields, :mutation, field: GraphQL::Define::AssignObjectField
    accepts_definitions implements: ->(type, *interfaces) { type.add_interfaces(*interfaces) }

    attr_accessor :fields, :mutation
    ensure_defined(:fields, :mutation, :interfaces)

    # @!attribute fields
    #   @return [Hash<String => GraphQL::Field>] Map String fieldnames to their {GraphQL::Field} implementations

    # @!attribute mutation
    #   @return [GraphQL::Relay::Mutation, nil] The mutation this field was derived from, if it was derived from a mutation

    def initialize
      super
      @fields = {}
      @dirty_interfaces = []
    end

    def initialize_copy(other)
      super
      @clean_interfaces = nil
      @dirty_interfaces = other.dirty_interfaces.dup
      @fields = other.fields.dup
    end

    # @param new_interfaces [Array<GraphQL::Interface>] interfaces that this type implements
    # @deprecated Use `implements` instead of `interfaces`.
    def interfaces=(new_interfaces)
      @clean_interfaces = nil
      @dirty_interfaces = new_interfaces
    end

    def interfaces
      @clean_interfaces ||= begin
        if @dirty_interfaces.respond_to?(:map)
          @dirty_interfaces.map { |i_type| GraphQL::BaseType.resolve_related_type(i_type) }
        else
          @dirty_interfaces
        end
      end
    end

    # @param interface [GraphQL::Interface] add a new interface that this type implements
    def add_interfaces(*interfaces)
      @clean_interfaces = nil
      @dirty_interfaces ||= []
      @dirty_interfaces.push(*interfaces)
    end

    def kind
      GraphQL::TypeKinds::OBJECT
    end

    # @return [GraphQL::Field] The field definition for `field_name` (may be inherited from interfaces)
    def get_field(field_name)
      fields[field_name] || interface_fields[field_name]
    end
{'fraction_non_alphanumeric': 0.09573067519277788, 'fraction_numerical': 0.0, 'mean_word_length': 3.0349013657056148, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7289423', 'n_tokens_mistral': 1604, 'n_tokens_neox': 1554, 'n_words': 412}