Sha256: 503814df79afa0e7d3dd946ff62013d807e01f9147e91b39082b22d634401fd9

Contents?: true

Size: 704 Bytes

Versions: 2

Compression:

Stored size: 704 Bytes

Contents

require 'graphql'
require 'graphql/batch'
require 'promise.rb'

GraphQL::Field.accepts_definitions(
  preload: ->(type, *args) do
    type.metadata[:preload] ||= []
    type.metadata[:preload].concat(args)
  end,
  preload_scope: ->(type, arg) { type.metadata[:preload_scope] = arg }
)

GraphQL::Schema.accepts_definitions(
  enable_preloading: ->(schema) do
    schema.instrument(:field, GraphQL::Preload::Instrument.new)
  end
)

module GraphQL
  # Provides a GraphQL::Field definition to preload ActiveRecord::Associations
  module Preload
    autoload :Instrument, 'graphql/preload/instrument'
    autoload :Loader, 'graphql/preload/loader'
    autoload :VERSION, 'graphql/preload/version'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
graphql-preload-2.0.1 lib/graphql/preload.rb
graphql-preload-2.0.0 lib/graphql/preload.rb