must
must

Reputation: 226

Calling internal nodes programmatically on CONNECT platform

When programmatically calling internal nodes on CONNECT platform, should you use the original path or is it okay to just use an alias? This question mainly refers to what the best practice would be, as aliases might introduce additional dependencies and may result in errors in the future.

Upvotes: 1

Views: 29

Answers (1)

well it really depends on what you want to do. 'aliasing' basically is a mechanism for dependency injection on CONNECT platform, meaning other packages will be able to replace some nodes with a specific alias silently, so that other nodes depending on that functionality will seamlessly be calling the 'injected' node.

to give an example, if you have something like '/firestore/insert', which is aliased by '/db/insert', then no other package can overwrite '/firestore/insert' path, but they can overwrite the alias on '/db/insert' path. so when you are making your call, if you make it directly to '/firestore/insert', it would definitely do the insert on firestore, while if you are making the call to '/db/insert', it would invoke the insert node on any database backend that is being used.

as a rule of thumb, it is always recommended to make calls to aliases so that you can take full advantage of the dependency injection system. however in some cases you might want finer control, in which case you can make your calls to the original path. in case of a package, this can get pretty tricky, as it might affect the internal workings of your package and you might want to not allow injection into that flow. however, consider the situation, and if it is not the case, i.e. if you can allow other packages to inject nodes into the flow of your package, then make your calls to the aliases. otherwise, make strict calls to the actual paths.

Upvotes: 1

Related Questions