Add new resolver files

pull/4/head
trivernis 5 years ago
parent 8a35195040
commit 164ecb77c6

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

@ -0,0 +1,6 @@
/**
* A class that provides methods to resolve mutations
*/
export class MutationResolver {
}

@ -0,0 +1,5 @@
/**
* A class that provides functions to resolve queries
*/
export class QueryResolver {
}

@ -8,6 +8,7 @@ export class BaseError extends Error {
* The graphql error with a frontend error message
*/
public readonly graphqlError: GraphQLError;
public readonly statusCode: number = 400;
constructor(message?: string, friendlyMessage?: string) {
super(message);

@ -1,5 +1,6 @@
import * as sqz from "sequelize";
import {BelongsTo, BelongsToMany, Column, CreatedAt, ForeignKey, Model, NotNull, Table} from "sequelize-typescript";
import globals from "../globals";
import markdown from "../markdown";
import {Activity} from "./Activity";
import {PostVote, VoteType} from "./PostVote";

Loading…
Cancel
Save