forked from oslabs-beta/Orbit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrouter.js
More file actions
51 lines (45 loc) · 1.14 KB
/
router.js
File metadata and controls
51 lines (45 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const express = require('express');
const router = express.Router();
const { graphqlHTTP } = require('express-graphql');
const {
getSQLSchema,
formatGraphData,
} = require('./controllers/SQLController');
const { createGQLSchema } = require('./controllers/GQLController');
const schema = require('./schema');
/* Route for example SQL Schema and example GQL Schema */
router.get(
'/example-schema',
getSQLSchema,
createGQLSchema,
formatGraphData,
(req, res) => {
res.status(200).json(res.locals);
},
);
/* Route for example SQL Schema */
router.get('/example-schema-json', getSQLSchema, (req, res) => {
res.status(200).json(res.locals.SQLSchema);
});
/* Route to get user db schema */
router.post(
'/sql-schema',
getSQLSchema,
createGQLSchema,
formatGraphData,
(req, res) => {
res.status(200).json(res.locals);
},
);
router.use(
'/playground',
graphqlHTTP({
schema,
graphiql: true,
}),
);
/* Route to get user (table specific) GraphQL Schema and Resolvers */
// router.post('gql-schema', GQLController.createGQLSchema,
// (req, res) => {res.status(200).json(res.locals.GQLSchema)
// });
module.exports = router;