-
-
Notifications
You must be signed in to change notification settings - Fork 438
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
Avoid calling model accessor twice through default resolver #1671
Comments
That behaviour comes from the |
@canatufkansu while that fix is not accepted into graphql-php, here's a dirty workaround. Add to your model class:
|
Thank you very much, I was trying to figure out the issue for a while. 👌 |
Let's keep this open, depending on the outcome of the other PR we might change something in Lighthouse. |
Given that I am actually delighted we got this far with the default. However, the most commonly used data structure in Lighthouse are probably Laravel Models, so we can optimize our implementation to fit them better. |
Since both graphql-php and laravel think that it's a feature and not a bug, thanks for wanting to fix this here. |
I think the stance we took in |
I understand the position in Is there anything I can do to help this to be fixed in lighthouse ASAP? |
You can add a PR with another default field resolver that checks for |
Let me see if I get this right:
Is that it? |
We currently use |
Following the example, posible workarounds I have found for deal with this:
or
|
Describe the bug
When I call a model accessor from GraphQL query Lighthouse calls it twice. When I call it from outside of Lighthouse it is being called only once.
Expected behavior/Solution
When I call the accessor it should only be called once.
Steps to reproduce
Lighthouse Version
v4.18.0
The text was updated successfully, but these errors were encountered: