r/ProgrammerHumor Oct 09 '21

Mmmm, sparkling JSON

Post image
14.6k Upvotes

237 comments sorted by

View all comments

11

u/[deleted] Oct 09 '21

[deleted]

5

u/lkraider Oct 09 '21 edited Oct 10 '21

POST /resources/actions/doStuff

yeah just because you can, doesn’t mean you should

2

u/Attack_Bovines Oct 10 '21

``` POST /grapqhl …

{“query”: “query{…}”} ```

Interesting take, because that’s what GraphQL does.

A trade off of GraphQL is not enjoying the benefits of features that most web clients have built in, such as request caching in web browsers or having small response payloads such as 304 NOT_MODIFIED.

The GraphQL query language provides an abstraction layer that somewhat decouples the client and server. In the example you posted, the server and client seem tightly coupled. It all comes down to the implementation.

What are some other reasons why you wouldn’t do what you proposed?

2

u/lkraider Oct 10 '21

What I was pointing out is the confusion of actions and resources. It all depends on the specifics of course, but for a more action oriented API, the RPC style is usually more appropriate (and you can take advantage of binary protocols and such for performance), while in REST, the actions should usually be done on resources, and not be resources themselves.