Solved: Exporting query builder classes
I saw this PR https://github.com/kysely-org/kysely/pull/763 where you guys have decided not to export classes as they are private.
Is there any specific reason for which you don't want to make these classes public? Because if you change the public API of these classes, then anyways the query builder will be impacted by the change.
GitHub
export SelectQueryBuilderImpl by Andersgee · Pull Request #763 · ky...
We have been adding an alternative .execute(). I noticed that the actual class (implementation) for SelectQueryBuilder is not exported in recent versions.
The classes for update, delete and insert ...
5 Replies
If we add public methods to the private class, those don't affect the public API if we don't add the methods to the public interface.
Having a private implementation class allows us to add methods to the class that can be called by the internals but not by the users.
Of course the users can cast the instance to
any
or whatever and just call the hidden methods, but that's clearly a violation of the public API and none of our concern. People can shoot themselves in the foot if they really want.
We just promise that the public interface works. Anything outside it can break at any time.
That was the reasoning behind the choice. Another reason was my misinterpretation of some typescript performance issues. I planned to move away from classes to interfaces everywhere. But that's not happening anymore since I was wrong.
I don't think we currently use any methods internally from the hidden class though. It might be ok to remove the interface and expose the class, just like all the other query builders.Okay, I get it. So basically you have been exposing interfaces publicly and keeping classes for internal runtime usage.
Yeah, I would personally love to have classes exported and also become the returning types, if that doesn't change a lot of internals
Yeah if we expose the class and not the interface we'd completely remove the interface.
Would you like me to create an issue for the same? Or is it something you want to re-evaluate and do it at your own pace?
Yeah, please create an issue. Otherwise this will get forgotten