-
-
Notifications
You must be signed in to change notification settings - Fork 676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Input logic in 0.18.0-beta.4 #510
Comments
Yes, TypeGraphQL always transform the plain args into classes instance according to the shapes of Input Types.
What do you mean? Can you show your input type classes? |
Here is a sample: @InputType()
export class OrderInput implements Partial<Order> {
@Field(_type => OrderCustomerInput, { nullable: true })
public partialCustomer?: OrderCustomerInput;
@Field(_type => OrderStatus)
public status: OrderStatus;
@Field(_type => [OrderLineItemInput])
public lineItems: OrderLineItemInput[];
} After doing some digging, it seems like this is limited only to nested arrays. In this instance, If this is intended behaviour there's probably not much to be done, I just wanted to check and raise an issue in case anyone else came across this behaviour. I can see the benefits of using classes when performing validation on inputs 😄 |
What is limited? Why it is throwing an error?
You mean that earlier you passed wrong data and now the validation works and it throws validation errors? 😄 |
It's limited because Firestore doesn't accept classes, only plain objects. When I insert into the database, I spread the input, which converts it into a plain object, but any nested properties don't get converted automatically.
Not quite 😉before, I'm going to close this issue, I don't think there's anything wrong with the code! |
All right! So Firebase is the proper guilty one 😄 |
Since 0.18.0-beta.4, the logic for inputs (although only nested inputs, strangely) seems to have changed, resulting in Firestore throwing errors when using their data directly (Firestore only takes plain objects, not instantiated classes)
I've managed to work around it by using
classToPlain() as Type
, but doing this for each instance of an input is quite messy. I'm wondering if this is intended behaviour?The text was updated successfully, but these errors were encountered: