abstract class GraphQL::DataLoader::Loader(O, K, V)

Overview

Abstract base class for all loaders

The first type parameter O is the type of the objects passed to #load. The second type parameter K is the type of keys for caching and determining uniqueness. The third type parameter V is the type of values returned by the loader.

You will need to override fetch to provide the actual batch loading behavior. If O differs from K you will also need to override #key_for.

Defined in:

graphql-dataloader/loader.cr

Constant Summary

VERSION = "0.1.0"

Constructors

Instance Method Summary

Constructor Detail

def self.new(cache : GraphQL::DataLoader::Cache(K, V) = MemoryCache(K, V).new) #

You can use a custom cache by implementing Cache(K, V) and passing it here.


[View source]

Instance Method Detail

def clear(object : O) : self #

[View source]
def clear : self #

[View source]
def key_for(object : O) : K #

Get the key for an object passed to #load. Override this if O differs from K


[View source]
def load(objects : Array(O)) : Array(V) #

Load multiple values at once.


[View source]
def load(object : O) : V #

Load a value for an object.


[View source]
def prime(object : O, value : V) : self #

[View source]