Live data from Hacker News

Why I believe GraphQL will come to replace REST

dev.to

11–12 of 12 posts

Re: Why I believe GraphQL will come to replace REST

#11
I'm in the process of rewriting our external api using GraphQL, It's kind of amazing, I do find my self tripping on "best practices" e.g. pertaining to a User view model

query {user {name}} query {users(someQualifier: $qualifier){name}} mutation {createUser(name: $name) {name}} mutation {updateUser(id: $id, name: $name){name}} mutation {destroyUser(id: $id) {name}}

It ends up looking like CRUD. But so much easier to reason about :)

Re: Why I believe GraphQL will come to replace REST

#12
The pendulum swings back the other way. One of the advantages of (proper) REST is precisely that the returning payload is a server-defined, well-specced mediatype, so you know that responses always look the same way. GraphQL -- and literally any other client-driven query language, including SQL -- instead you ask for specific data items and have to case-by-case write the handling logic right after your request completes.

It's a trade-off, like any other. As another commenter said, this battle was fought many years ago with SQL, where it began to be considered good practice to formalize the APIs with stored procedures or abstract away from the backend tables by restricted-column views, instead of just accepting arbitrary queries against the raw table.

Post reply on HN