-
Notifications
You must be signed in to change notification settings - Fork 115
Expand file tree
/
Copy pathindex.ts
More file actions
36 lines (32 loc) · 906 Bytes
/
index.ts
File metadata and controls
36 lines (32 loc) · 906 Bytes
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
declare global {
namespace GraphQLModules {
interface GlobalContext {
request: any;
}
}
}
import 'reflect-metadata';
import { createApplication } from 'graphql-modules';
import express from 'express';
import { graphqlHTTP } from 'express-graphql';
import { UserModule } from './app/user/user.module';
import { AuthModule } from './app/auth/auth.module';
import { SocialNetworkModule } from './app/social-network/social-network.module';
const server = express();
const app = createApplication({
modules: [UserModule, AuthModule, SocialNetworkModule],
executionContext: false,
});
const execute = app.createExecution();
server.use(
'/graphql',
graphqlHTTP((request: any) => ({
schema: app.schema,
graphiql: true,
customExecuteFn: execute as any,
context: { request },
}))
);
server.listen(4000, () => {
console.log('Live http://localhost:4000/graphql');
});