I have separate databases for different customers in our project, I want to connect with a specific database on the bases of tenantID
(which is already known to me). I have achieved this in Java (spring boot) after going through this documentation
text.
However, I am not finding any examples on how to do it in NodeJS.
The code I have written in Node JS isn't allowing me to connect to different database using tenantID
(which is stored in a file).
const ConnectionFilterPlugin = require("postgraphile-plugin-connection-filter");
const PgAggregatesPlugin = require("@graphile/pg-aggregates").default;
const SubscriptionPlugin = require("@graphile/subscriptions-lds").default;
const http = require("http");
const { postgraphile } = require("postgraphile");
const eurekaHelper = require('./eureka-helper');
http
.createServer(postgraphile("postgres://"+process.env.DB_USER+":"+process.env.DB_PASSWORD+"@"+process.env.DB_HOST+"/"+process.env.DB_DATABASE,
schemaName = "graphiql",
{appendPlugins: [PgAggregatesPlugin, ConnectionFilterPlugin, SubscriptionPlugin], simpleCollections: "both",
enhanceGraphiql: true, allowExplain: (req) => { return true; }, disableDefaultMutations: true, ignoreRBAC: false,
dynamicJson: true, enhanceGraphiql: true, watchPg:true, graphiql: true, live: true, graphqlRoute: '/gateway/graphql' }))
.listen(process.env.PORT);
eurekaHelper.registerWithEureka('graphql-service', process.env.PORT);
How can I modify the above code to make the connection multitenant ?