-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.ts
58 lines (51 loc) · 929 Bytes
/
index.ts
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
import 'reflect-metadata';
import { AppModule } from './modules/app';
import * as express from 'express';
import * as graphqlHTTP from 'express-graphql';
const PORT = process.env.PORT || 4000;
const chats = [
{
id: 1,
title: "My first chat",
description: "Just a chat",
},
{
id: 2,
title: "My second chat",
description: "Yet another chat",
},
];
const messages = [
{
id: 1,
chatId: 1,
content: "Hi Kamil, how are you?",
},
{
id: 2,
chatId: 2,
content: "Do you use graphql-code-generator?",
},
{
id: 3,
chatId: 1,
content: "I'm fine, thanks :)",
},
{
id: 4,
chatId: 2,
content: "Yes, I do!",
},
];
const { schema } = AppModule.forRoot({
chats,
messages,
});
const app = express();
app.use(graphqlHTTP({
schema,
graphiql: true,
}));
app.listen(PORT, () => {
console.log(`Server ready at http://localhost:${PORT}`);
});