Hi,
In our use-case we are planning to integrate Cube-js into electron application. In this scenario communication between client & server is done using IPC not API.
It seems that currently server-core is supporting only API communication.
Is there a way to initialize server (or just part of the server-core) to accept direct requests as funcional calls into objects?
For example:
CubejsServerCore.load (request);
CubejsServerCore.subscribe (request);
CubejsServerCore.sql (request);
CubejsServerCore.meta (request);
If there is another way to achieve this functionality I would appreciate simple examples
@flesicek Hey Jozef! Great question! We don't have any such documented API right now. It's probably part of #251. On other hand there's an API for subscription server which we aren't quite ready to expose in docs but it's pretty reliable. You can use it as following:
const serverCore = CubejsServerCore.create();
const context = { authInfo: {} };
const res = await serverCore.apiGateway().load({
query,
context,
res: (message, { status }) => // TODO handle result message
});
@paveltiunov Hey Pavel, that is fantastic. Thanks a lot for suggestion.
One more think, what should be format of the request json? Here are examples of curl request https://cube.dev/docs/rest-api but they are send to specific URL. I'm assuming that request should have payload + function which to execute.
Can you point me to format of the request variable?
Thanks a lot for your support !
@flesicek It's actually receives query instead of request. Just fixed my comment. So you should provide just query object: https://cube.dev/docs/query-format.
Closing this as it's outside of Cube.js vision: https://github.com/cube-js/cube.js/issues/1343#issuecomment-724835892.
Most helpful comment
@flesicek Hey Jozef! Great question! We don't have any such documented API right now. It's probably part of #251. On other hand there's an API for subscription server which we aren't quite ready to expose in docs but it's pretty reliable. You can use it as following: