6 ms·
Working with GraphQL over 6 years, I have seen (and created) many mistakes mentioned in the article. GraphQL is not great but it has worked well for me, you jus
by knlam 2y ago
Working with GraphQL over 6 years, I have seen (and created) many mistakes mentioned in the article. GraphQL is not great but it has worked well for me, you just need to adapt & change mindset to create better interface for your graphQL endpoint.
For example, having nested queries more than 2 levels is a no go for me (just like having nested inheritance is basically anti pattern)
Focus more on your interface. One way to avoid N+1 and nested query is to required parameter for related fields. For example
```
user(id: $userId) { {
id
friends {
id
...
}
```
to
```
user(id: $userId) {
id
friends(id: $userId) {
id
...
}
```
- pavel_lishin 2y agoI don't think I understand how that change avoids the N+1 issue. It's still fetching all of that user's friends, no?
- vvpan 2y agoI have had to implement a large REST API recently and feel like I spent a lot of time setting up things manually that GraphQL provides out of box. REST tooling has gotten better but so far I have not seen anything as convenient as Apollo, for example.