-
Notifications
You must be signed in to change notification settings - Fork 5
Fixing n+1 relations problem #27
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
60cdd3f
ignore PhpStorm IDE files
lorado 9ec1416
improve guessing relations
lorado 4c11459
fix errors
lorado 718de93
define Paginable interface for identifying those transformers
lorado 870de54
ListTransformer implements now Paginable interface
lorado bffe998
rework, how ListTransformer is identified
lorado f694792
extend DB structure for tests. Tests are still the same
lorado 1051554
sync tables and model definitions
lorado 53db424
rework how relations are identified (much cleaner and correct way)
lorado 1453da4
add missing author parameter to PostDefinition
lorado 171c290
define unit tests for eager loading relations
lorado 035b470
copy-paste travis config
lorado 13cdf22
delete unused imports
lorado a9beecc
refactor code, so phpmd don't blame on me (CouplingBetweenObjects)
lorado 02cb7e9
calling function recursive make sense only, if relations are found
lorado 88ceb91
save changes after php-cs-fixer
lorado 9088301
remove unnecessary $app variable
lorado c9fe50e
define fiels selection depth as constant
lorado 68901b2
move relations guessing to static in GraphQL class (will be reused)
lorado 7703678
guess relations also for custom fields
lorado 8bd4965
extend custom query, add test for eager loading in custom queries
lorado daf6927
add doc to test-query
lorado 06097b4
remove array_filter(), as I see no reason in using it...
lorado c3bbc1a
extend readme
lorado 55c3c00
fix code styling
lorado 4af8f80
fetch fields ONLY, if returned type is an object
lorado 83b94ea
add new test for fetching simple string from graphql
lorado fe7fd5e
add authorize check for fields, default is true. update readme
lorado 31cb88b
add tests for authorize checking (test - unauthorized error gets thrown)
lorado e2a0261
fix definition of method
lorado dcc86aa
Merge branch 'master' into bug/26
cmizzi a92e22c
fix(transformers): fix bad merge
cmizzi 12024dd
Merge branch 'master' into bug/26
lorado 7d085f7
fix returned type in docs
lorado 60928bb
adopt EloquentTransformer to fix n+1 problem (at least on read data)
lorado e227585
fix for linters
lorado 4b52290
add readme for authorization
lorado 5845e35
Merge remote-tracking branch 'origin/bug/26' into bug/26
lorado 8a8eb19
remove unused reflect
lorado 63f6abd
update readme
lorado File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix errors
- Loading branch information
commit 4c114592ece5813f04c4f98059375d146538cd80
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happened is the
$key
isdelete
,update
, or whatever that does not relied to relationships ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you do some concrete example?
Method gets called, only if field is an array. Currently even if
delete
is the key, nothing will happen.$model
is just an empty model-object instance, sodelete()
orupdate()
make no changes. After call,$relation
will beboolean
ornull
or whatever these functions return, but definitely not an instance ofIlluminate\Database\Eloquent\Relations\Relation
, so that code will continue executing and let this field as not a relation.May be we should add some filter, so that key should not be equal
delete
orupdate
or what else method of Model are 'critical'? I mean even if you want to havedelete
to be relation, it is not possible to implement it with Laravel... Also you can't damage the DB somehow with those fields, as model-objects, which gets created in this relation guessing, are empty, and have no connection to any rows in DB. Or am I wrong?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're true. The
$model
isn't loaded from database (you've used$this->app->make
). My bad.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an idea:
If you wish, I could get all methods of Eloquent-Model class, cache them, and when relation is guessed, those keys that equal the method-names will be just ignored. But I don't really think it is necessary...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's not necessary. Don't worry, I'm just tired :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok :D
then I am gonna wait till new release with my PR ^_^