introduces react GraphQLPlayground
This commit is contained in:
@@ -6,6 +6,10 @@ import config from '../../../securedConfig';
|
||||
const GraphQLPlayground = () => {
|
||||
return (
|
||||
<Provider store={store}>
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700|Source+Code+Pro:400,700"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<Playground endpoint={`${config.routes.api}${config.routes.graphQL}`} />
|
||||
</Provider>
|
||||
);
|
||||
|
||||
20
src/index.js
20
src/index.js
@@ -1,5 +1,4 @@
|
||||
const express = require('express');
|
||||
const graphQLPlayground = require('graphql-playground-middleware-express').default;
|
||||
|
||||
const connectMongoose = require('./mongoose/connect');
|
||||
const expressMiddleware = require('./express/middleware');
|
||||
@@ -46,25 +45,6 @@ class Payload {
|
||||
// Init GraphQL
|
||||
this.router.use(this.config.routes.graphQL, new GraphQL(this.config, this.collections).init());
|
||||
|
||||
this.router.get(this.config.routes.graphQLPlayground, (req, res, next) => {
|
||||
let endpoint = `${this.config.routes.api}${this.config.routes.graphQL}`;
|
||||
|
||||
if (req.cookies.token) {
|
||||
endpoint += `?headers=${encodeURIComponent(
|
||||
JSON.stringify({
|
||||
Authorization: `JWT ${req.cookies.token}`,
|
||||
}),
|
||||
)}`;
|
||||
}
|
||||
|
||||
graphQLPlayground({
|
||||
endpoint,
|
||||
settings: {
|
||||
'request.credentials': 'include',
|
||||
},
|
||||
})(req, res, next);
|
||||
});
|
||||
|
||||
// Bind router to API
|
||||
this.express.use(this.config.routes.api, this.router);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user