Building GraphQL APIs with Prisma

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

It really helped me to choose the right tool with less setup and definition boilerplate, thanks Daniel. Looking forward to see more like this.

ostadomid
Автор

GraphQL isn't even good tho, I'll never understand why it got so popular.

Firstly, the GQL queries are poor. Selecting the `exact` properties you want sounds good in theory, except the 9/10, you're pulling the full property sets from your database; with GQL creating the partial result objects from the full result. There is no optimization from your DB > Server where your Server is asking for these exact properties (fields) which would be a win, but it doesn't do that, and I don't understand why GQL advocates keep ignoring this

Secondly, there is no GQL standard for filtering, projection and pagination. Instead GraphQL makes you write something analogous to a 'Function' where the parameters of the function are used to filter, project and paginate data. This doesn't actually solve anything you couldn't already do through a RESTful interface with query parameters. GQL needs some kind of query expression tree representation to do this properly (at least to a level inline with SQL or similar). More often than not, people just make up whatever (as they do for RESTful interfaces)

Thirdly, GraphQL invented it's own formats for queries and defining schematics, along with needlessly inventing terms "Mutations" as well as drawing a distinction between read and write operations (even those a query could in theory write, (as would be case with caching a result), so what's the point of the distinction? GQL could used JSON Schema (or hell, even OpenAPI) for it's schematics, and at least tried to be a bit more "aligned" with accepted web standards (as well as making it easier for developers to try and fix it's inadequacies)

Seriously, GraphQL is way more popular than it deserves to be. A better technology is OData (which literally solves all the above problems), but I guess the marketing for OData wasn't as good as GraphQL. If I'm being honest tho, OData is only really viable in equipped languages (those that support language integrated query, so C#, Elixir (ecto) and Rust's macro system, and I suppose any LISP). But I just find it surprising people continue to push GraphQL with these "known" issues, when far superior alternatives exist, and have existed well before GraphQL hit the scene.

BinaryReader