Hacker News new | ask | show | jobs
by javajosh 3816 days ago
Am I the only one who designs endpoints to spit back usage instructions if you call them without arguments? This goes a long way toward helping devs use those endpoints, in my experience - and they can use normal tools (in particular, the network pane of Chrome Dev tools). This is not to take away from GraphiQL, but it doesn't seem like that much more than you get with such a convention.
2 comments

I've not seen this practice very much in my experience; most API's I've worked with go the "automated documentation generation" route and host the docs somewhere separate instead. This does mean you don't need tooling just to find out how to use the API.

This is distinct from throwing exceptions when an endpoint is called with e.g. invalid parameters.

No you're not the only one. But I do fear we may be some sort of "silent minority". I always felt that having human and machine readable instructions was part of trying to achieve "proper" REST, the full HEOTAS or whatever the acronym is. I admire the principle and the outcomes it strives for, but very much dislike the "wankery" that goes on over the topic sometimes.