introduces react GraphQLPlayground

This commit is contained in:
James
2020-04-11 17:25:19 -04:00
parent bb496cfd26
commit c51a87a852
2 changed files with 4 additions and 20 deletions

View File

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

View File

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