-
Notifications
You must be signed in to change notification settings - Fork 109
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 Eloquent adapter query hooks #292
Comments
Hey! Do you have any suggestions as to how it would be better to add joins? What is your join being used for? |
Thank you! I would like to query relationship counts and for example the customer_value (the sum of all related orders for a customer) in an efficient way. Additionally, sometimes it is more efficient to add the customer_name as an attribute directly to the order. That way I don't need a separate query for the related customer when I only need the name. I'd love to see a function, like the filter() function, where I can easily extend the query without overwriting anything. |
Hey @lindyhopchris ! Do you have any update to this issue or do you plan to include a separate function? Because it seems like the queryAll() or with() method does not affect the read request for a single resource. I would like to avoid to duplicate my logic for the read method. |
Hi! I'm not adverse to adding a new hook in, but I'm not sure what this hook would be, and under what circumstances it would get called? That would need to be clear for me to add it in - do you have any suggestions? One thing to mention is that in these kind of scenarios, we've implemented it by putting all these values in a related resource that the client can choose to include or not. So for example, we'd have
The purpose of the JSON API spec is to give the client control over what it is asking for. How are you determining when to put the customer name attribute on the order or not? Whether attributes are in the response or not is defined in the spec using the (Sorry for all the question - just trying to figure out what the best way to approach this use case is!) |
Hey @lindyhopchris,
To use the newly selected attribute, you can simply add the Another important use case for me is to add custom selection, like concatenating the customer name to the |
Ok. I think that It's more about how you are querying the resource, so the hooks I think should be:
|
I totally agree with you. The naming and separation of the hook looks perfect. |
Hi @lindyhopchris, are there any updates on this issue? |
No update I'm afraid - combination of too much other work going on, and me being in two minds about adding these querying hooks, or supporting them in some other way. Let me have another think about these. |
I was wondering where is the best place to add some custom joins to the index query?
Currently, I am overwriting the queryAll method in the Adapter but it doesn‘t feel right.
Is there any function or hook which is better suited?
Thanks in advance!
The text was updated successfully, but these errors were encountered: