Skip to content

Instantly share code, notes, and snippets.

@martijnvdbrug
Last active March 1, 2019 12:58
Show Gist options
  • Save martijnvdbrug/f6d900810a312c4d127d4d7c8c3fa298 to your computer and use it in GitHub Desktop.
Save martijnvdbrug/f6d900810a312c4d127d4d7c8c3fa298 to your computer and use it in GitHub Desktop.
app.module.ts used for Google Cloud Function + NestJS POC
import {DocumentNode} from 'graphql';
import {Module} from '@nestjs/common';
import { TeslaModule } from './tesla/tesla.module';
import * as fs from 'fs';
import glob = require('glob');
@Module({
imports: [
TeslaModule
],
providers: []
})
export class AppModule {
typeDefs: Array<DocumentNode> = [];
resolvers: any = [];
constructor() {
this.resolvers.push(TeslaModule.resolvers);
this.typeDefs = <any>this.getAllTypeDefs();
}
/**
* Get all files ending in .graphql
*/
getAllTypeDefs(): string[] {
const typeDefs = [];
const files = glob.sync('dist/**/*.graphql');
files.forEach(file => {
typeDefs.push(fs.readFileSync(file).toString());
});
return typeDefs;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment