Sha256: a63cad12a0bad6c791f8a6e2051f77ac2d80f117c739809e9caf769c709df320

Contents?: true

Size: 734 Bytes

Versions: 1

Compression:

Stored size: 734 Bytes

Contents

# frozen_string_literal: true

require 'graphql/execution/interpreter/runtime'
module GraphqlPreloadQueries::PatchContinueValue # rubocop:disable Style/ClassAndModuleChildren:
  # gql args: path, value, parent_type, field, is_non_null, ast_node
  def continue_value(*args)
    value = args[1]
    ast_node = args[5]
    field = args[3]
    type_klass = field.owner
    is_active_record = value.is_a?(ActiveRecord::Relation)
    return super if !is_active_record || value.loaded? || !type_klass.respond_to?(:preloads)

    klass = GraphqlPreloadQueries::Extensions::Preload
    klass.preload_associations(value, ast_node, type_klass)
  end
end
GraphQL::Execution::Interpreter::Runtime.prepend GraphqlPreloadQueries::PatchContinueValue

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
graphql_preload_queries-0.2.2 config/initializers/patch_continue_value.rb