Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c327676

Browse filesBrowse files
committed
show apolloServer conf in server
1 parent 02eeb8a commit c327676
Copy full SHA for c327676

File tree

Expand file treeCollapse file tree

2 files changed

+11
-12
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+11
-12
lines changed

‎src/init/graphql/server.ts

Copy file name to clipboard
+2-10Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,27 @@
11
import 'reflect-metadata';
2-
import { Express } from 'express';
32
import { join } from 'path';
43
import { BuildSchemaOptions, buildSchema } from 'type-graphql';
54
import { ApolloServer } from 'apollo-server-express';
65

7-
import { cors } from 'src/config';
86
import formatError from './formatError';
97
import ErrorHandlePlugin from './errorHandlePlugin';
108

119
export const path = '/graphql';
12-
const server = async (app: Express) => {
10+
const server = async () => {
1311
const privatePath = join(__dirname, '../../graphql/resolvers/**/*{.ts,.js}');
1412
const apolloSchemeOptions: BuildSchemaOptions = {
1513
resolvers: [privatePath],
1614
validate: false,
1715
};
1816
const apolloSchema = await buildSchema(apolloSchemeOptions);
19-
const apolloServer = new ApolloServer({
17+
return new ApolloServer({
2018
schema: apolloSchema,
2119
formatError,
2220
plugins: [ErrorHandlePlugin],
2321
playground: true,
2422
introspection: true,
2523
uploads: false,
2624
});
27-
apolloServer.applyMiddleware({
28-
cors,
29-
app,
30-
path,
31-
bodyParserConfig: true,
32-
});
3325
};
3426

3527
export default server;

‎src/init/server.ts

Copy file name to clipboardExpand all lines: src/init/server.ts
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import './i18n/index';
1010
import './bugsnag';
1111
import '../util/validatorjs/rules';
1212
import handleErrors from './handleErrors';
13-
import apolloServer from './graphql/server';
13+
import ApolloServer, { path } from './graphql/server';
1414
import useControllersApi from './controllers';
15+
import { cors } from 'src/config';
1516

1617
const getApp = async (): Promise<Express> => {
1718
dotenv.config();
@@ -27,7 +28,13 @@ const getApp = async (): Promise<Express> => {
2728
// use multi languages
2829
app.use(i18n.init);
2930
// Apollo graphQL
30-
await apolloServer(app);
31+
const apolloServer = await ApolloServer();
32+
apolloServer.applyMiddleware({
33+
cors,
34+
app,
35+
path,
36+
bodyParserConfig: true,
37+
});
3138
app.use(graphqlUploadExpress({ maxFileSize: 10000, maxFiles: 10 }));
3239
// Api
3340
useControllersApi(app);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.