Replies: 1 comment 16 replies
-
TypeGraphQL uses a trick to detect default values. It creates a new instance of the class and then reads the instance's property value. |
Beta Was this translation helpful? Give feedback.
16 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I use typegraphql in a Next.js project. I am trying to move from Babel to SWC to reduce compile time, and everything works fine except for one thing: typegraphql used to return my default field value with babel when it was undefined in my return statement, and now with SWC, it remains undefined (leading to "cannot return null for non-nullable field" errors).
Here is an example:
When I return a GameOptions objet without this field (not very clean, but it comes from mongoose directly), with Babel, TypeGraphQL was automatically returning MAX_SPARE_TIME. With SWC, it does not.
Here is my Babel configuration:
Do you know why the default class structure was used with Babel, and why it is now used with SWC?
Is there simple way to get property fallback with TypeGraphQL?
@Field({default: ...})
does not work for return types. I can do custom resolvers, but it is a but messy of course. The best solution would be a way to configure SWC to have the same behavior as I use to have with Babel of course, to prevent unexpected regressions...Beta Was this translation helpful? Give feedback.
All reactions