4 ms·
It is really hard to do business logic in GraphQL. The language syntax is literally limited to ‘I want this data’.
by Aeolun 6y ago
It is really hard to do business logic in GraphQL. The language syntax is literally limited to ‘I want this data’.
- tsimionescu 6y agoWell, when you say 'give me all cars and all users joined by user ID = owner id', that's business logic. With a good REST API you would just do a GET on /cars and find any user details that are needed already in each car (perhaps under a link, which may lead to the N+1 problem, but that's another discussion). Of course, a bad REST API may expect that you do a GET /cars and GET /users and match them in your code, which is once again business logic in the front-end and bad design. There are even many DB-To-Rest libraries that encourage exactly this, unfortunately. A good GraphQL API could also allow you to query cars and get car.Owner.Name and car.Owner.Address without you explicitly joining (the join still happens in the backend). However, I feel that many people who choose GraphQL are trying to avoid exactly this type of logic on the backend, which would explain the popularity of DB-to-GraphQL libraries.
- deleted 6y ago[deleted]
- collyw 6y agoThat's exactly what SQL does. No one ever said it was hard to do business logic in SQL.