mirror of
https://github.com/aleleba/create-node-ts-graphql-server.git
synced 2025-06-20 04:48:24 -06:00
Adding GraphQL playground option to server.
This commit is contained in:
@ -7,11 +7,11 @@ import cookieParser from 'cookie-parser';
|
||||
import { useServer } from 'graphql-ws/lib/use/ws';
|
||||
import { execute, subscribe } from 'graphql';
|
||||
import GraphQLserver from './GraphQL/server';// Server of GraphQL,
|
||||
import expressPlayground from 'graphql-playground-middleware-express';
|
||||
import schema from './GraphQL/schema';
|
||||
import { config } from '../config';
|
||||
import apiRouter from './routes';
|
||||
|
||||
|
||||
const app = express(), //creating app
|
||||
whitelist = config.whiteList,
|
||||
corsOptions = {
|
||||
@ -34,6 +34,10 @@ app
|
||||
.use(apiRouter)//Routes de App
|
||||
.use('/graphql', GraphQLserver);//Server of Graphql
|
||||
|
||||
if(config.playgroundGraphQL === true){
|
||||
app.get('/playground', expressPlayground({ endpoint: '/graphql' }));
|
||||
}
|
||||
|
||||
// DO NOT DO app.listen() unless we're testing this directly
|
||||
if (require.main === module) {
|
||||
|
||||
|
Reference in New Issue
Block a user