Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError, key not found #50

Closed
maxtechera opened this issue Mar 2, 2017 · 1 comment
Closed

KeyError, key not found #50

maxtechera opened this issue Mar 2, 2017 · 1 comment
Labels

Comments

@maxtechera
Copy link

maxtechera commented Mar 2, 2017

I'm using the base example with RecordLoader, like this in a resolver
Loaders::RecordLoader.for(Product).load(Product.ids)

I'm getting this error:
KeyError (key not found: 6)

6 is the first id loaded. I think its somehow related to promise_for(load_key) in loader.rb.

Has anyone had this happen?

@dylanahsmith
Copy link
Contributor

That happens when Loaders::RecordLoader#perform calls fulfill with a key that wasn't among the keys passed into perform.

The problem is that you are passing an array of ids in as a single key, which it doesn't find using the id of a single record. Instead use Loaders::RecordLoader.for(Product).load_many(Product.ids)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants