|
|
@ -8,7 +8,7 @@ import * as graphqlHTTP from "express-graphql";
|
|
|
|
import * as session from "express-session";
|
|
|
|
import * as session from "express-session";
|
|
|
|
import sharedsession = require("express-socket.io-session");
|
|
|
|
import sharedsession = require("express-socket.io-session");
|
|
|
|
import * as fsx from "fs-extra";
|
|
|
|
import * as fsx from "fs-extra";
|
|
|
|
import {buildSchema} from "graphql";
|
|
|
|
import {buildSchema, GraphQLError} from "graphql";
|
|
|
|
import {importSchema} from "graphql-import";
|
|
|
|
import {importSchema} from "graphql-import";
|
|
|
|
import queryComplexity, {directiveEstimator, simpleEstimator} from "graphql-query-complexity";
|
|
|
|
import queryComplexity, {directiveEstimator, simpleEstimator} from "graphql-query-complexity";
|
|
|
|
import * as http from "http";
|
|
|
|
import * as http from "http";
|
|
|
@ -192,11 +192,17 @@ class App {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
// @ts-ignore
|
|
|
|
this.app.use("/graphql", graphqlHTTP(async (request, response, {variables}) => {
|
|
|
|
this.app.use("/graphql", graphqlHTTP(async (request: any, response: any, {variables}) => {
|
|
|
|
response.setHeader("X-Max-Query-Complexity", config.get("api.maxQueryComplexity"));
|
|
|
|
response.setHeader("X-Max-Query-Complexity", config.get("api.maxQueryComplexity"));
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
// @ts-ignore all
|
|
|
|
// @ts-ignore all
|
|
|
|
context: {session: request.session},
|
|
|
|
context: {session: request.session},
|
|
|
|
|
|
|
|
formatError: (err: GraphQLError | any) => {
|
|
|
|
|
|
|
|
if (err.statusCode) {
|
|
|
|
|
|
|
|
response.status(err.statusCode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return err.graphqlError ?? err;
|
|
|
|
|
|
|
|
},
|
|
|
|
graphiql: config.get("api.graphiql"),
|
|
|
|
graphiql: config.get("api.graphiql"),
|
|
|
|
rootValue: resolver(request, response),
|
|
|
|
rootValue: resolver(request, response),
|
|
|
|
schema: buildSchema(importSchema(path.join(__dirname, "./graphql/schema.graphql"))),
|
|
|
|
schema: buildSchema(importSchema(path.join(__dirname, "./graphql/schema.graphql"))),
|
|
|
|