@aleleba/create-node-ts-graphql-server 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.env.example CHANGED
@@ -4,5 +4,7 @@ ENVIRONMENT=
4
4
  WHITELIST_URLS=
5
5
  #GRAPHIQL Default to "false"
6
6
  GRAPHIQL=
7
+ #PLAYGROUND GRAPHQL Default to "false"
8
+ PLAYGROUND_GRAPHQL=
7
9
  # PORT EXPOSE APP Default to 4000
8
10
  PORT=
package/config/index.ts CHANGED
@@ -5,6 +5,7 @@ dotenv.config();
5
5
  export const config = {
6
6
  env: process.env.ENVIRONMENT ? process.env.ENVIRONMENT : 'production',
7
7
  graphiQL: process.env.GRAPHIQL === 'true' ? true : false,
8
+ playgroundGraphQL: process.env.PLAYGROUND_GRAPHQL === 'true' ? true : false,
8
9
  whiteList: process.env.WHITELIST_URLS ? process.env.WHITELIST_URLS.split(',') : [
9
10
  'http://localhost'
10
11
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aleleba/create-node-ts-graphql-server",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Node with Typescript and GraphQL Server",
5
5
  "bin": "./bin/cli.js",
6
6
  "main": "index.js",
@@ -40,6 +40,7 @@
40
40
  "express": "^4.18.1",
41
41
  "express-graphql": "^0.12.0",
42
42
  "graphql": "^16.5.0",
43
+ "graphql-playground-middleware-express": "^1.7.23",
43
44
  "graphql-subscriptions": "^2.0.0",
44
45
  "graphql-tools": "^8.2.11",
45
46
  "graphql-ws": "^5.8.2",
package/src/index.ts CHANGED
@@ -7,11 +7,11 @@ import cookieParser from 'cookie-parser';
7
7
  import { useServer } from 'graphql-ws/lib/use/ws';
8
8
  import { execute, subscribe } from 'graphql';
9
9
  import GraphQLserver from './GraphQL/server';// Server of GraphQL,
10
+ import expressPlayground from 'graphql-playground-middleware-express';
10
11
  import schema from './GraphQL/schema';
11
12
  import { config } from '../config';
12
13
  import apiRouter from './routes';
13
14
 
14
-
15
15
  const app = express(), //creating app
16
16
  whitelist = config.whiteList,
17
17
  corsOptions = {
@@ -34,6 +34,10 @@ app
34
34
  .use(apiRouter)//Routes de App
35
35
  .use('/graphql', GraphQLserver);//Server of Graphql
36
36
 
37
+ if(config.playgroundGraphQL === true){
38
+ app.get('/playground', expressPlayground({ endpoint: '/graphql' }));
39
+ }
40
+
37
41
  // DO NOT DO app.listen() unless we're testing this directly
38
42
  if (require.main === module) {
39
43