Closed shawnjones253 closed 9 months ago
if the intent is to not have undefined values at runtime for unspecified request keys, should useDefineForClassFields: false
be added to the required tsconfig.json options here? (it is only needed when emitTranspiledCode = false
)
@MichalLytek -- are you open to this PR? our team reverted to 0.27.0 due to the above but we're really missing the speed boost that came with 0.27.1 :)
I found this to be a workaround. I need to play with es2022 in typegraphql core itself I've recently merged there a fix to get rid of undefined values from transformed inputs.
@MichalLytek any updates on this issue?
@shawnjones253
Setting target to es2022
makes this tests failing:
Summary of all failing tests
FAIL tests/functional/resolvers.ts
● Resolvers › Functional › shouldn't create properties of nullable args
expect(received).not.toHaveProperty(path)
Expected path: not "optionalField"
Received value: undefined
1818 | expect(mutationResult.errors).toBeUndefined();
1819 |
> 1820 | const result = mutationResult.data!.mutationWithTripleNestedInputs;
| ^
1821 | expect(result).toEqual(30);
1822 |
1823 | expect(mutationInputValue).toBeInstanceOf(classes.SampleTripleNestedInput);
at Object.<anonymous> (tests/functional/resolvers.ts:1820:44)
● Resolvers › Functional › should create instances of nested input fields input objects without undefined
expect(received).not.toHaveProperty(path)
Expected path: not "optionalNestedField"
Received value: undefined
1847 | it("should create instance of root object when root type is provided", async () => {
1848 | const query = `query {
> 1849 | sampleQuery {
| ^
1850 | fieldResolverWithRoot
1851 | getterField
1852 | }
at Object.<anonymous> (tests/functional/resolvers.ts:1849:44)
I think I will just downgrade target in prisma generator to make it matching with type-graphql core.
Closing as superseded by 4c053cc 🔒
@MichalLytek now could I just bug you for a new release 😅
@MichalLytek sorry to nag -- making another plea for a release -- our team is eager to get back to the fast version as it saves us hundreds of seconds when generating typegraphql types
fix for: https://github.com/MichalLytek/typegraphql-prisma/issues/434
This restores the previous behavior of input keys only being set when specified by the api request via
variables
.Unfortunately, this only guarantees a fix when
emitTranspiledCode = true
is used (the default). However, ifoutput = 'someDirOutsideOfNodeModules'
is used WITHOUTemitTranspiledCode = true
, then the consuming app must do one of:"useDefineForClassFields": false
if target == es2022UseDefineForClassFields
Default: true if [target](https://www.typescriptlang.org/tsconfig#target) is ES2022 or higher, including ESNext; false otherwise.
some interesting reading that pointed me in this direction: https://github.com/swc-project/swc/pull/7055 https://github.com/microsoft/TypeScript/issues/45995