I attempted to create a union type in type-graphql that represents the String, Number, and Boolean classes, but unfortunately, it was not successful. Does anyone have any suggestions on how to achieve this?
export const NonObjectType = createUnionType({
name: "NonObjectType",
types: () => [String, Boolean, Number] as const,
resolveType: (value) => {
console.log(value, typeof value);
switch (typeof value) {
case "string":
return String;
case "number":
return Number;
case "boolean":
return Boolean;
default:
return undefined;
}
},
});
@ArgsType()
@InputType("FindSomeArgsUnitInputType")
export class GqlArgsFindSomeArgsUnit<T extends object>
implements IFindSomeArgsUnit<T> {
@Field(() => String, { defaultValue: "id" })
column: keyof T;
@Field(() => [NonObjectType], { defaultValue: [""] })
values: Array<string | boolean | number>;
}
Error : Error: Cannot determine GraphQL input type for 'values' of 'GqlArgsFindSomeArgsUnit' class