Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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

    ...

  }
```


I don't think I understand how that change avoids the N+1 issue. It's still fetching all of that user's friends, no?


I 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: