46d1ea6505
Example query Here person has - a N - 1 relationship with company - a N - 1 morph relationship with pet or company <img width="862" height="374" alt="image" src="https://github.com/user-attachments/assets/59bc9b82-c943-43de-ad82-d3393b76904b" /> <img width="415" height="629" alt="image" src="https://github.com/user-attachments/assets/9a3176bc-99cd-4983-8611-68ca3a2cf527" /> truncated response <img width="299" height="447" alt="image" src="https://github.com/user-attachments/assets/45af0322-9e66-4eae-8353-6c0dda487bbe" /> We don't allow grouping by relations of relations. Left to do - rest api - tests on permissions
40 lines
1.5 KiB
TypeScript
40 lines
1.5 KiB
TypeScript
import { assertUnreachable } from 'twenty-shared/utils';
|
|
|
|
import {
|
|
CommonQueryRunnerExceptionCode,
|
|
type CommonQueryRunnerException,
|
|
} from 'src/engine/api/common/common-query-runners/errors/common-query-runner.exception';
|
|
import {
|
|
AuthenticationError,
|
|
InternalServerError,
|
|
NotFoundError,
|
|
UserInputError,
|
|
} from 'src/engine/core-modules/graphql/utils/graphql-errors.util';
|
|
|
|
export const commonQueryRunnerToGraphqlApiExceptionHandler = (
|
|
error: CommonQueryRunnerException,
|
|
) => {
|
|
switch (error.code) {
|
|
case CommonQueryRunnerExceptionCode.RECORD_NOT_FOUND:
|
|
throw new NotFoundError(error);
|
|
case CommonQueryRunnerExceptionCode.ARGS_CONFLICT:
|
|
case CommonQueryRunnerExceptionCode.INVALID_ARGS_FIRST:
|
|
case CommonQueryRunnerExceptionCode.INVALID_ARGS_LAST:
|
|
case CommonQueryRunnerExceptionCode.INVALID_QUERY_INPUT:
|
|
case CommonQueryRunnerExceptionCode.INVALID_ARGS_DATA:
|
|
case CommonQueryRunnerExceptionCode.UPSERT_MULTIPLE_MATCHING_RECORDS_CONFLICT:
|
|
case CommonQueryRunnerExceptionCode.INVALID_CURSOR:
|
|
case CommonQueryRunnerExceptionCode.TOO_MANY_RECORDS_TO_UPDATE:
|
|
case CommonQueryRunnerExceptionCode.BAD_REQUEST:
|
|
throw new UserInputError(error);
|
|
case CommonQueryRunnerExceptionCode.INVALID_AUTH_CONTEXT:
|
|
throw new AuthenticationError(error);
|
|
case CommonQueryRunnerExceptionCode.MISSING_SYSTEM_FIELD:
|
|
case CommonQueryRunnerExceptionCode.INTERNAL_SERVER_ERROR:
|
|
throw new InternalServerError(error);
|
|
default: {
|
|
return assertUnreachable(error.code);
|
|
}
|
|
}
|
|
};
|