refactor codebase and pothos structure

This commit is contained in:
2024-10-07 10:07:08 +07:00
parent 29ec9c5360
commit dfa6b35399
31 changed files with 997 additions and 664 deletions

View File

@@ -5,7 +5,10 @@ import { Request, Response, NextFunction } from 'express';
export class GraphQLValidationMiddleware implements NestMiddleware {
use(req: Request, res: Response, next: NextFunction) {
// Only handle POST requests
if (req.method === 'POST' && req.headers['content-type'] === 'application/json') {
if (
req.method === 'POST' &&
req.headers['content-type'] === 'application/json'
) {
const { query, mutation, subscription } = req.body;
// If none of these are present, return a custom error response
@@ -13,7 +16,8 @@ export class GraphQLValidationMiddleware implements NestMiddleware {
return res.status(400).json({
errors: [
{
message: 'Must provide a valid GraphQL query, mutation, or subscription.',
message:
'Must provide a valid GraphQL query, mutation, or subscription.',
},
],
});