-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
70 lines (60 loc) · 1.63 KB
/
server.js
File metadata and controls
70 lines (60 loc) · 1.63 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import express from 'express';
//import schema from './data/schema';
import TestClass from './data/testdebug'
import GraphQLHTTP from 'express-graphql';
import {MongoClient} from 'mongodb';
import {
GraphQLSchema,
GraphQLObjectType,
GraphQLList,
GraphQLInt,
GraphQLString
} from 'graphql';
let Schema = (db) => {
let linkType = new GraphQLObjectType({
name: 'Link',
fields: () => ({
_id: { type: GraphQLString },
title: { type: GraphQLString },
url: { type: GraphQLString }
})
});
let schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'Query',
fields: () => ({
links: {
type: new GraphQLList(linkType),
resolve: () => {
const inst = new TestClass();
inst.logFuncition('messagetext');
return db.collection("links").find({}).toArray();
}
}
})
})
});
function logger(){
"use strict";
console.log('joggu');
}
return schema
};
let app = express();
app.use(express.static('public'));
let db;
MongoClient.connect('mongodb://ohabbers:dykk12@ds042898.mongolab.com:42898/dbgira', (err, database) => {
if (err) throw err;
db = database;
app.use('/graphql', GraphQLHTTP({
schema: Schema(db),
graphiql: true
}));
app.listen(3000, () =>
console.log('Listening on port 3000 '));
});
if(true){
console.log('jaggu');
const inst = new TestClass();
inst.logFuncition('messagetext');
}