How to use the @nestjs/graphql.GraphQLModule.forRoot function in @nestjs/graphql

To help you get started, we’ve selected a few @nestjs/graphql examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jmcdo29 / testing-nestjs / apps / typeorm-graphql-sample / src / app.module.ts View on Github external
import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { TypeOrmModule } from '@nestjs/typeorm';
import { CatModule } from './cat/cat.module';

@Module({
  imports: [
    TypeOrmModule.forRoot({
      type: 'postgres',
      url: process.env.DATABASE_URL,
      synchronize: true,
      entities: [__dirname + '/**/*.entity.{ts,js}'],
    }),
    GraphQLModule.forRoot({
      debug: true,
      playground: true,
      typePaths: ['./**/*.graphql'],
      installSubscriptionHandlers: true,
      // context: ({req}) => {
      // return {req};
      // },
    }),
    CatModule,
  ],
})
export class AppModule {}
github jkchao / blog-service / src / module / tags / __test__ / tags.resolver.spec.ts View on Github external
beforeAll(async () => {
      const module = await Test.createTestingModule({
        imports: [
          MongooseModule.forRoot(config.MONGO_URL),
          TagsModule,
          GraphQLModule.forRoot({
            typePaths: ['./**/*.graphql'],
            path: '/api/v2',
            context: ({ req, res }: { req: Request; res: Response }) => ({
              request: req
            })
          })
        ]
      })
        .overrideProvider(TagsService)
        .useValue(tagsService)
        .compile();

      app = await module.createNestApplication().init();
    });
github jkchao / blog-service / src / module / links / __test__ / link.resolver.spec.ts View on Github external
beforeAll(async () => {
      const module = await Test.createTestingModule({
        imports: [
          MongooseModule.forRoot(config.MONGO_URL),
          LinksModule,
          GraphQLModule.forRoot({
            typePaths: ['./**/*.graphql'],
            path: '/api/v2'
          })
        ]
      })
        .overrideProvider(LinksService)
        .useValue(linksService)
        .compile();

      app = await module.createNestApplication().init();
    });
github webnoob / quasar-ts-jest-nestjs-apollojs-prisma2 / api / src / app.module.ts View on Github external
import { Module } from '@nestjs/common'
import { GraphQLModule } from '@nestjs/graphql'
import { BookModule } from './book/book.module'
import { AuthModule } from './auth/auth.module'
import { UserModule } from './user/user.module'

@Module({
  imports: [
    BookModule,
    UserModule,
    GraphQLModule.forRoot({
      autoSchemaFile: 'graphql/schema.gql',
      debug: true,
      playground: true,
      context: ({ req }) => ({ req })
    }),
    AuthModule
  ]
})
export class AppModule {}
github jimmyleray / Emendare / server / src / app.module.ts View on Github external
AuthService,
  CryptoService,
  MailService
]
const RESOLVERS = [AmendResolver, TextResolver, EventResolver, UserResolver]
const CONTROLLERS = [AppController]
const TASKS = [CheckAmendVoteTask]
const GATEWAYS = [EventGateway, AmendGateway, UserGateway, TextGateway]
const PROVIDERS = [...databaseProvider]

@Module({
  controllers: CONTROLLERS,
  providers: [...PROVIDERS, ...GATEWAYS, ...SERVICES, ...TASKS, ...RESOLVERS],
  imports: [
    ScheduleModule.register(),
    GraphQLModule.forRoot({
      autoSchemaFile: 'schema.gql',
      installSubscriptionHandlers: true,
      formatError(error) {
        return error
      }
    })
  ]
})
export class AppModule {}
github EricKit / nest-user-auth / src / app.module.ts View on Github external
useNewUrlParser: true,
          useCreateIndex: true,
          useFindAndModify: false,
          useUnifiedTopology: true,
        };

        if (configService.mongoAuthEnabled) {
          options.user = configService.mongoUser;
          options.pass = configService.mongoPassword;
        }

        return options;
      },
      inject: [ConfigService],
    }),
    GraphQLModule.forRoot({
      typePaths: ['./**/*.graphql'],
      installSubscriptionHandlers: true,
      context: ({ req }: any) => ({ req }),
      definitions: {
        path: join(process.cwd(), 'src/graphql.classes.ts'),
        outputAs: 'class',
      },
    }),
    UsersModule,
    AuthModule,
    ConfigModule,
  ],
})
export class AppModule {}
github zifahm / nestjs-voting-app / server / src / app.module.ts View on Github external
import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { UserModule } from './user/user.module';

@Module({
  imports: [
    GraphQLModule.forRoot({
      autoSchemaFile: 'schema.gql',
    }),
    UserModule,
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}