Skip to content

Commit 63f6abd

Browse files
committed
update readme
1 parent 8a8eb19 commit 63f6abd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ php artisan vendor:publish --provider="StudioNet\GraphQL\ServiceProvider"
3636
- [Require authorization](#require-authorization)
3737
- [Self documentation](#self-documentation)
3838
- [Examples](#examples)
39+
- [N+1 Problem](#n+1-problem)
3940

4041
### Definition
4142

@@ -604,6 +605,14 @@ post-save (which can be useful for eloquent relational models) :
604605
}
605606
```
606607

608+
### N+1 Problem
609+
610+
The common question is, if graphql library solves n+1 problem. This occures, when graphql resolves relation. Often entities are fetched without relations, and when graphql query needs to fetch relation, for each fetched entity relation would be fetched from SQL separately. So instead of executing 2 SQL queries, you will get N+1 queries, where N is the count of results of root entity. In that example you would query only one relation. If you query more relations, then it becomes N^2+1 problem.
611+
612+
To solve it, Eloquent has already options to eager load relations. Transformers in this library use eager loading, depends on what you query.
613+
614+
Currently this smart detection works perfect only on View and List Transformers. Other transformers will be reworked soon.
615+
607616
## Contribution
608617

609618
If you want participate to the project, thank you ! In order to work properly,

0 commit comments

Comments
 (0)