1- import type { SchemaBuilderType } from "../schemaBuilder" ;
2- import type { GenericDrizzleDbTypeConstraints } from "../types/genericDrizzleDbType" ;
3- import { RumbleError } from ".. /types/rumbleError " ;
1+ import type { SchemaBuilderType } from "../../ schemaBuilder" ;
2+ import type { GenericDrizzleDbTypeConstraints } from "../../ types/genericDrizzleDbType" ;
3+ import { type PossibleSQLType , UnknownTypeRumbleError } from "./types" ;
44
55export function mapSQLTypeToGraphQLType <
66 UserContext extends Record < string , any > ,
@@ -13,20 +13,12 @@ export function mapSQLTypeToGraphQLType<
1313 RequestEvent ,
1414 Action
1515 > ,
16- > ( sqlType : string ) {
16+ > ( sqlType : PossibleSQLType ) {
1717 type ReturnType = Parameters <
1818 Parameters < Parameters < SchemaBuilder [ "queryField" ] > [ 1 ] > [ 0 ] [ "field" ]
1919 > [ 0 ] [ "type" ] ;
2020
2121 let ret : ReturnType | undefined = undefined ;
22- // Int
23- // Float
24- // String
25- // ID
26- // Boolean
27- // DateTime
28- // Date
29- // JSON
3022
3123 if (
3224 [ "serial" , "int" , "integer" , "tinyint" , "smallint" , "mediumint" ] . includes (
@@ -36,7 +28,7 @@ export function mapSQLTypeToGraphQLType<
3628 ret = "Int" ;
3729 }
3830
39- if ( [ "real" , "decimal" , "real" , " double", "float" ] . includes ( sqlType ) ) {
31+ if ( [ "real" , "decimal" , "double" , "float" ] . includes ( sqlType ) ) {
4032 ret = "Float" ;
4133 }
4234
@@ -68,7 +60,5 @@ export function mapSQLTypeToGraphQLType<
6860 return ret ;
6961 }
7062
71- throw new RumbleError (
72- `RumbleError: Unknown SQL type '${ sqlType } '. Please open an issue so it can be added.` ,
73- ) ;
63+ throw UnknownTypeRumbleError ( sqlType , "SQL to GQL" ) ;
7464}
0 commit comments