Skip to content

Commit

Permalink
Merge pull request #8 from BrewInteractive/docs/update-installation-d…
Browse files Browse the repository at this point in the history
…ocument

docs: update installation document
  • Loading branch information
mfozmen authored Jun 25, 2024
2 parents cc0e7c6 + bbe005b commit 565703d
Showing 1 changed file with 39 additions and 7 deletions.
46 changes: 39 additions & 7 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,31 @@ import { HasuraModule } from '@brewww/nestjs-hasura-module';
import { Module } from '@nestjs/common';
import { UserController } from './user.controller';
import { UserService } from './user.service';
import { ConfigService } from '@nestjs/config';

@Module({
imports: [
HasuraModule.register({
graphqlEndpoint: 'http://localhost:8080/v1/graphql',
adminSecret: 'Admin Secret',
}),
// or
})
],
providers: [UserService],
controllers: [UserController],
})
export class UserModule {}
```

The `register` method takes package configurations directly as parameters, while the `registerAsync` method allows you to fetch data from services like `ConfigService` and provide configurations dynamically through a method.

```ts
import { HasuraModule } from '@brewww/nestjs-hasura-module';
import { Module } from '@nestjs/common';
import { UserController } from './user.controller';
import { UserService } from './user.service';
import { ConfigService } from '@nestjs/config';

@Module({
imports: [
HasuraModule.registerAsync({
useFactory: (configService: ConfigService) => {
return {
Expand All @@ -42,7 +58,7 @@ import { ConfigService } from '@nestjs/config';
};
},
inject: [ConfigService],
}),
})
],
providers: [UserService],
controllers: [UserController],
Expand All @@ -59,15 +75,31 @@ import { HasuraModule } from '@brewww/nestjs-hasura-module';
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { ConfigService } from '@nestjs/config';

@Module({
imports: [
HasuraModule.forRoot({
graphqlEndpoint: 'http://localhost:8080/v1/graphql',
adminSecret: 'Admin Secret',
}),
// or
})
],
providers: [AppService],
controllers: [AppController],
})
export class AppModule {}
```

The `forRoot` method takes package configurations directly as parameters, while the `forRootAsync` method allows you to fetch data from services like `ConfigService` and provide configurations dynamically through a method.

```ts
import { HasuraModule } from '@brewww/nestjs-hasura-module';
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { ConfigService } from '@nestjs/config';

@Module({
imports: [
HasuraModule.forRootAsync({
useFactory: (configService: ConfigService) => {
return {
Expand Down

0 comments on commit 565703d

Please sign in to comment.