I have this code:
import { Neo4jOptions } from './../interfaces/neo4joptions.interface';
import { DynamicModule, Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { Connection } from 'cypher-query-builder';
import { ConnectionWithDriver, Neo4jConfig } from './neo4j-config.interface';
import { NEO4J_CONFIG, NEO4J_CONNECTION, NEO4J_OPTIONS, TYPE_DEFS } from './neo4j.constants';
import { createDatabaseConfig, ConnectionError } from './neo4j.utils';
import { QueryRepository } from './query.repository';
import { Neo4jService } from './neo4j.service';
@Module({
providers: [QueryRepository, Neo4jService],
})
export class Neo4jModule {
static forRootAsync( typeDefs: any, neo4jOptions?: Neo4jOptions,customConfig?: Neo4jConfig): DynamicModule {
const providers = [
{
provide: NEO4J_CONFIG,
inject: [ConfigService],
useFactory: (configService: ConfigService) =>
createDatabaseConfig(configService, customConfig),
},
{
provide: TYPE_DEFS,
useFactory: () => typeDefs,
},
{
provide: NEO4J_OPTIONS,
useFactory: () => neo4jOptions,
},
{
provide: NEO4J_CONNECTION,
inject: [NEO4J_CONFIG,NEO4J_OPTIONS],
useFactory: async (config: Neo4jConfig, options: Neo4jOptions) => {
try {
const { host, scheme, port, username, password } = config;
const connection = new Connection(`${scheme}://${host}:${port}`, {
username,
password,
...options
},{}) as ConnectionWithDriver;
await connection.driver.verifyConnectivity();
return connection;
} catch (error) {
throw new ConnectionError(error);
}
},
},
];
return {
module: Neo4jModule,
imports: [ConfigModule],
global: true,
providers: providers,
exports: providers,
};
}
}
where I am creating a ConnectionWithDriver and then trying to verify the connection. The problem is that there seems to be a conflict in the _id types in neo4j-driver and cypher-query-builder. verifyConnectivity() gives the following error:
Property 'verifyConnectivity' does not exist on type 'never'.
The intersection 'import("/Applications/flash/flash-gateway/node_modules/cypher-query-builder/node_modules/neo4j-driver/types/driver").Driver & import("/Applications/flash/flash-gateway/node_modules/neo4j-driver/types/driver").Driver' was reduced to 'never' because property '_id' exists in multiple constituents and is private in some.
I would appreciate any help with this.
.