In my previous post I mentioned that I am trying to write to Neo4j from node.
This is becoming difficult as each of the top two libraries seems to have serious dependency problems.
The Neo4j package does not handle error conditions well due to a missing stacktrace function.
The neo4j-driver package is also broken with a vague “Headers is not defined”.
This brings me to the main topic: when should you choose a library versus directly using an api?
Firstly does the library do the job? There are lot of node packages out there. Some of them are useful.
If the library adds some features then it’s a no-brainer. Especially if the library can maintain a stable contract despite the underlying api changing (The Delphi VCL was a great example of this. The VCL survived the underlying platform moving from 16 to 32 bit without any code changes required).
There is also the matter of the dependency chain that you will pick up with the library. It’s not uncommon for a npm package to have tens of dependencies. This can mean that a poorly maintained library can be broken by someone else’s change (this may be less of a problem with the introduction of package-lock). This can also be difficult with dependencies from multiple required libraries: these can clash and you may have to chose which bugs you can live with.
If the usage that you have of an api is simple and the api is stable it may be worth directly calling just the parts that you need.