Last active
March 1, 2019 12:58
-
-
Save martijnvdbrug/f6d900810a312c4d127d4d7c8c3fa298 to your computer and use it in GitHub Desktop.
app.module.ts used for Google Cloud Function + NestJS POC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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