(consumer: MiddlewareConsumer)
| 199 | } |
| 200 | |
| 201 | configure(consumer: MiddlewareConsumer) { |
| 202 | |
| 203 | console.log(chalk.green(`Configuring NestJS ApplicationModule`)); |
| 204 | |
| 205 | // trick for GraphQL vs MongoDB ObjectId type. |
| 206 | // See https://github.com/apollographql/apollo-server/issues/1633 and |
| 207 | // https://github.com/apollographql/apollo-server/issues/1649#issuecomment-420840287 |
| 208 | const { ObjectId } = mongoose.Types; |
| 209 | |
| 210 | ObjectId.prototype.valueOf = function () { |
| 211 | return this.toString(); |
| 212 | }; |
| 213 | |
| 214 | /* Next is code which could be used to manually create GraphQL Server instead of using GraphQLModule.forRoot(...) |
| 215 | |
| 216 | const schema: GraphQLSchema = this.createSchema(); |
| 217 | const server: ApolloServer = this.createServer(schema); |
| 218 | |
| 219 | // this creates manually GraphQL subscriptions server (over ws connection) |
| 220 | this.subscriptionsService.createSubscriptionServer(server); |
| 221 | |
| 222 | const app: any = this.httpServerRef; |
| 223 | |
| 224 | const graphqlPath = '/graphql'; |
| 225 | |
| 226 | server.applyMiddleware({app, path: graphqlPath}); |
| 227 | |
| 228 | */ |
| 229 | |
| 230 | log.info(`GraphQL Playground available at http://${host}:${port}/graphql`); |
| 231 | console.log(chalk.green(`GraphQL Playground available at http://${host}:${port}/graphql`)); |
| 232 | } |
| 233 | |
| 234 | /* |
| 235 | Creates GraphQL Apollo Server manually |
no test coverage detected