refactor(server): dont convert graphql bad request into internal server error (#10203)

This commit is contained in:
fengmk2
2025-02-17 06:17:00 +00:00
parent 34472fdfa9
commit 57213781a8
7 changed files with 66 additions and 9 deletions
@@ -1,15 +1,14 @@
import type { INestApplication } from '@nestjs/common';
import type { TestFn } from 'ava';
import ava from 'ava';
import request from 'supertest';
import { buildAppModule } from '../../app.module';
import { createTestingApp } from '../utils';
import { createTestingApp, TestingApp } from '../utils';
const gql = '/graphql';
const test = ava as TestFn<{
app: INestApplication;
app: TestingApp;
}>;
test.before('start app', async t => {
@@ -83,3 +82,9 @@ test('should be able to call apis', async t => {
// make sure the request id is set
t.truthy(res.headers['x-request-id']);
});
test('should not throw internal error when graphql call with invalid params', async t => {
await t.throwsAsync(t.context.app.gql(`query { workspace("1") }`), {
message: /Failed to execute gql: query { workspace\("1"\) \}, status: 400/,
});
});