question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Conditionally import `HasuraModule` based on value from `ConfigService`

See original GitHub issue

Hello.

The documentation regarding Automatic Hasura Metadata Synchronization states that:

It is recommended that you conditionally add this configuration based on the Node Environment as this should only be used in development environments

It is quite trivial to do so with process.env.NODE_ENV, since it is available outside of the Dependency Injection framework, but what if we wanted to set the condition based on the value from Nest’s ConfigService, which is available from within the DI? I know that if we use HasuraModule.forRootAsync, we would be able to configure the module using the injected config service, but I can’t seem to find a similar factory method that would allow me to exclude the HasuraModule from the imports array of the @Module annotation.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
WonderPandacommented, Aug 30, 2021

The HasuraModule provides the necessary components to actually receive event payloads from Hasura and then route them to the correct service so that they can be handled by your custom business logic. If you do not include the HasuraModule in your imports then you will not be able to process events.

The section you linked in your original comment from the docs is referring specifically to the managedMetaDataConfig portion of the module configuration. You should only include this property in development mode so that the module can help keep your local metadata files up to date.

0reactions
WonderPandacommented, Aug 30, 2021

No problem, glad I was able to help out 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

import module in condition based #601 - nestjs/nest - GitHub
I'm wondering if there's a way to use DI with Dynamic Modules? I want my imports to be based on a ConfigService value....
Read more >
Can you import a NestJS module on condition - Stack Overflow
My question is: is it possible to import the RabbitmqModule based on a .env variable? Such as: USE_BROKER=false . If this variable is...
Read more >
@golevelup/nestjs-hasura - npm
Import and add HasuraModule to the imports section of the consuming module (most ... the necessary config values from a ConfigService or other...
Read more >
Configuration | NestJS - A progressive Node.js framework
To access configuration values from our ConfigService , we first need to inject ConfigService . As with any provider, we need to import...
Read more >
How To Combine Business Logic & Event Handling Using ...
import { HasuraModule } from '@golevelup/nestjs-hasura'; @Module({ imports: ... It is recommended that you conditionally add this configuration based on the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found