Adding GraphQL playground option to server.

This commit is contained in:
2022-06-05 02:58:11 +00:00
parent b371152812
commit 5ce9f4ff9a
5 changed files with 84 additions and 8 deletions

View File

@ -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) {