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

Add Active Record AssociationLoader and RecordLoader examples #64

Merged
merged 1 commit into from
Aug 15, 2017

Conversation

dylanahsmith
Copy link
Contributor

Fixes #24

This adds a couple of examples for a RecordLoader and AssociationLoader that work with Active Record and links to those examples in the README.

Each of these handle a problem that a naive loader would have:

  • RecordLoader type casts keys to avoid to fulfilling the wrong key when the wrong type is provided
  • AssociationLoader preloads the association on all records, even if some share the same id

These are just examples, since I didn't want to add an active record dependency to this library.

@dylanahsmith dylanahsmith requested a review from xuorig August 11, 2017 16:15
@xuorig
Copy link
Contributor

xuorig commented Aug 11, 2017

Cool, should help newcomers a lot.

I wrote this a while ago for an easy plug and play solution in graphql ruby: https://github.com/xuorig/graphql-active_record_batcher

might be cool to link it 🤷‍♂️

@dylanahsmith
Copy link
Contributor Author

I love the way fields preloads are specified declaratively in a similar way to how we do it at Shopify. Maybe we should just add the examples to that repo and link to it instead. The gemspec in that repo could also use a github link so that the repo can be easily found from its rubygems page

Copy link
Contributor

@xuorig xuorig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great examples. I'll PR to add a link to the graphql-ruby integration in a follow up PR? This LGTM as it is.

@dylanahsmith
Copy link
Contributor Author

I'll PR to add a link to the graphql-ruby integration in a follow up PR?

Yes, please. If you add a RecordLoader to your repo, then we could just link directly to the loaders in that repo and won't need examples in this repo.

@dylanahsmith dylanahsmith merged commit 058213b into master Aug 15, 2017
@dylanahsmith dylanahsmith deleted the active-record-examples branch August 15, 2017 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants