-
Notifications
You must be signed in to change notification settings - Fork 99
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
run_batch override for association loads #133
Comments
Hi @tlvenn. Thanks, but that's the problem - it pushes responsibility for a domain logic concern right down into the schema resolution layer. This really should be handled in the context module. For now I've decided to bypass the magic association helper in the schema and use Dataloader directly, handling all association batch loading at the context level (with some generic helpers). That way the context module can have the final say over all data flow. I definitely feel that @jfrolich was onto something here: #25 (comment) |
You can do this:
|
It would be really nice if we could override batch loading for associations.
Imagine a fusebox with fuses. In my absinthe schema, I specify:
I can specify a base query in the context module:
However, imagine that later, we decide that for our domain model, a fusebox cannot contain zero fuses, so if none are found for a given Fusebox, we should return a single default fuse. I would now like to override
run_batch
to override the way this association is loaded, but there is no facility to do that. So this cannot be done from within the context module without changing the API offered to the schema resolvers. Instead I have to change the schema to something like this:Which will then use the "standard" implementation of
run_batch
that will delegate to therun_batch
hook in the context module. This seems like an important limitation of the "magic" association data loading functionality, pushing a change that should affect only the domain logic into the schema layer. If I need to change the way I load the data in order to modify the loading behaviour in the context, it makes me wary of using the association shortcut magic at all :(The text was updated successfully, but these errors were encountered: