panoti / cubejs-arangodb-driver

ArangoDB driver for Cube JS
MIT License
5 stars 1 forks source link

Can't find dialect for 'ArangoDB' data source: arangodb #5

Open tokarenko opened 1 year ago

tokarenko commented 1 year ago

Dear Thanh, thank you for updating the driver and integrating my contributions! I am unable to get it working though...

arangodb-cubejs-driver@0.1.0 with cube:latest (0.33.41) and cube:v0.30.39 raises the following error when running any query via GUI:

Can't find dialect for 'ArangoDB' data source: arangodb
Error: Can't find dialect for 'ArangoDB' data source: arangodb
    at CompilerApi.getSql (/cube/node_modules/@cubejs-backend/server-core/src/core/CompilerApi.js:138:15)
    at /cube/node_modules/@cubejs-backend/api-gateway/src/gateway.ts:1306:28
    at async Promise.all (index 0)
    at ApiGateway.getSqlQueriesInternal (/cube/node_modules/@cubejs-backend/api-gateway/src/gateway.ts:1302:24)
    at ApiGateway.load (/cube/node_modules/@cubejs-backend/api-gateway/src/gateway.ts:1529:26)
    at /cube/node_modules/@cubejs-backend/api-gateway/src/gateway.ts:245:7

Please find below my cube.js configuration for dual DB. It works with image: ghcr.io/panoti/cube:main. For v0.1.0 I commented lines with "Object.setPrototypeOf" that were needed for v0.0.5 to load the driver.

const PostgresDriver = require('@cubejs-backend/postgres-driver').PostgresDriver;
const arango_db_driver = require("arangodb-cubejs-driver/dist/arangodb-driver.js").ArangoDbDriver;
const base_driver = require("@cubejs-backend/query-orchestrator").BaseDriver;

module.exports = {
  dbType: ({ dataSource }) => {
    switch (dataSource) {
      case 'ArangoDB': return process.env.CUBEJS_DB_ARANGO_TYPE;
      default: return process.env.CUBEJS_DB_TYPE;
    }
  },

  driverFactory: ({ dataSource }) => {
    switch(dataSource) {
      case 'ArangoDB':
        //Object.setPrototypeOf(arango_db_driver.prototype,base_driver.prototype)

        return new arango_db_driver({
          url: process.env.CUBEJS_DB_ARANGO_URL,
          databaseName: process.env.CUBEJS_DB_ARANGO_NAME,
          auth: {
            username: process.env.CUBEJS_DB_ARANGO_USER,
            password: process.env.CUBEJS_DB_ARANGO_PASS,
          },
        });
      default:
        //Object.setPrototypeOf(PostgresDriver.prototype,base_driver.prototype)
        return new PostgresDriver({
        //type: process.env.CUBEJS_DB_TYPE,
        host: process.env.CUBEJS_DB_HOST,
        port: process.env.CUBEJS_DB_PORT,
        database: process.env.CUBEJS_DB_NAME,
        user: process.env.CUBEJS_DB_USER,
        password: process.env.CUBEJS_DB_PASS,
      });
    }
  },
};
tokarenko commented 1 year ago

I suppose the root cause is missing static dialectClass() method as described here

panoti commented 1 year ago

I referenced with the other built-in drivers, they removed dialectClass from their code, so I also remove those codes 🤣 . I think I should restore those lines of code.

tokarenko commented 1 year ago

Dear @panoti , did you restore dialectClass? I would be grateful if you could provide corresponding docker image for arangodb-cubejs-driver@0.1.x that I will use in production.