You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When triggering an afterInsert event within a typeormEventSubscriber, any fields that are part of the CreateDTOClass and not part of the DTOClass, are available when the used resolver is an AutoResolver but not when the resolver is a custom CRUDResolver.
Thank you for taking a look. Please let me know if you have any questions.
If someExtraField is added to the entity without the @Column decorator, the entity printed in the EventSubscriber has the field but it is undefined and doesn't have the value provided in the CreateExampleDTO.
Here is a minimum repo with code to reproduce what I found.
Edit: I updated the classes in the description to match what's in the linked repo.
The issue is very weird as when you extend CRUDResolver it will be the same as defining resolvers inside your module. I think the root cause is the code below (which is executed before creating the record).
I cannot seem to find out why in one case the CreateDTOClass extends it's entity and not when you define a resolver your self.
An easy fix in this case is to make sure that your CreateDTOClass extends your entity, in case of your example:
exportclassCreateExampleDTOextendsExampleEntity{
I also do something like this in my own API's, there I extend the main DTO with for example PickType / OmitType from NestJS, the main DTO in it's turn than extends the entity it belongs to.
I'm going to keep this bug open so when I have a bit more time I can debug it a bit more.
Describe the bug
When triggering an
afterInsert
event within atypeorm
EventSubscriber
, any fields that are part of theCreateDTOClass
and not part of theDTOClass
, are available when the used resolver is anAutoResolver
but not when the resolver is a customCRUDResolver
.Thank you for taking a look. Please let me know if you have any questions.
To Reproduce
https://github.com/RyanLackie/nestjs-query-issue-example
Related Example Files:
ExampleEntity:
ExampleDTO:
CreateExampleDTO:
EventSubscriber
createOneExample
mutation with asomeExtraField
valueEventSubscriber
should log an entity with the same fieldsomeExtraField
and value of what was sent in the mutationvs
createOneExample
mutation with asomeExtraField
valueEventSubscriber
should now no longer log an entity with the same fieldsomeExtraField
and value of what was sent in the mutationExpected behavior
I would expect both functionalities to expose the same data to the
typeorm
subscriber functions.Desktop (please complete the following information):
v18.14.1
0.3.17
The text was updated successfully, but these errors were encountered: