-
Using the Errors plugin, I'm trying to throw errors that have an ErrorCode enum included: export enum ErrorCode {
EMAIL_IN_USE,
SIGN_IN_FAILED,
}
export class ErrorWithCode extends Error {
public code: ErrorCode
constructor(code: ErrorCode, message: string) {
super(message)
this.code = code
}
}
builder.enumType(ErrorCode, { // this line throws the error
name: 'ErrorCode',
})
builder.objectType(ErrorWithCode, {
name: 'ErrorWithCode',
fields: (t) => ({
code: t.expose('code', { type: ErrorCode }),
message: t.exposeString('message'),
}),
}) But when I run the server this causes an error:
Are enums in error types supported? |
Beta Was this translation helpful? Give feedback.
Answered by
garth
Sep 25, 2022
Replies: 1 comment 5 replies
-
I tried running the build via esbuild and swc and they gave different errors that hinted at cyclic dependency issues. After quite a bit of trial an error, it seems that moving the enums and classes out into separate files has resolved the issue. |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
garth
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tried running the build via esbuild and swc and they gave different errors that hinted at cyclic dependency issues.
After quite a bit of trial an error, it seems that moving the enums and classes out into separate files has resolved the issue.