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

Projects
None yet
2 participants
@dylanahsmith
Member

dylanahsmith commented Aug 11, 2017

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 Aug 11, 2017

@xuorig

This comment has been minimized.

Show comment
Hide comment
@xuorig

xuorig Aug 11, 2017

Contributor

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 🤷‍♂️

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

This comment has been minimized.

Show comment
Hide comment
@dylanahsmith

dylanahsmith Aug 11, 2017

Member

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

Member

dylanahsmith commented Aug 11, 2017

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

@xuorig

xuorig approved these changes Aug 15, 2017

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

This comment has been minimized.

Show comment
Hide comment
@dylanahsmith

dylanahsmith Aug 15, 2017

Member

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.

Member

dylanahsmith commented Aug 15, 2017

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

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@dylanahsmith dylanahsmith deleted the active-record-examples branch Aug 15, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment