@nestjs/tigergraph
A NestJS module for TigerGraph integration.
Installation
npm install @nestjs/tigergraph
Usage
import { Module } from '@nestjs/common';
import { TigerGraphModule } from '@nestjs/tigergraph';
@Module({
imports: [
TigerGraphModule.register({
host: 'localhost',
port: 14240,
graphName: 'myGraph',
userName: 'user',
password: 'pass',
}),
],
})
export class AppModule {}
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { TigerGraphModule } from '@nestjs/tigergraph';
@Module({
imports: [
ConfigModule.forRoot(),
TigerGraphModule.forRootAsync({
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => ({
host: configService.get('TIGERGRAPH_HOST'),
port: configService.get('TIGERGRAPH_PORT'),
graphName: configService.get('TIGERGRAPH_GRAPH'),
userName: configService.get('TIGERGRAPH_USER'),
password: configService.get('TIGERGRAPH_PASSWORD'),
}),
inject: [ConfigService],
}),
],
})
export class AppModule {}
import { Injectable } from '@nestjs/common';
import { TigerGraphService } from '@nestjs/tigergraph';
@Injectable()
export class YourService {
constructor(private readonly tigerGraphService: TigerGraphService) {}
async getData() {
const result = await this.tigerGraphService.query('yourQuery', {
param1: 'value1',
});
return result;
}
}
API Reference
TigerGraphModule
register(options: ITigerGraphOptions)
: Static configurationforRootAsync(options: ITigerGraphAsyncOptions)
: Async configuration
TigerGraphService
connect()
: Establish connection to TigerGraphquery<T>(queryName: string, params?: Record<string, any>): Promise<T>
: Execute a query