Skip to content
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

"Class constructor ChildClass cannot be invoked without 'new' when using Partial #10

Open
techanyonymous opened this issue Sep 14, 2023 · 4 comments

Comments

@techanyonymous
Copy link

techanyonymous commented Sep 14, 2023

I am trying to get the all the properties from the parent class as optional in typegraphl. But when I used Partial with @inputType decorator it throws this error. If I change the decorator to @ObjectType, there seems to be no issue.

@InputType
class Parent {
   @Field()
   fieldA: string
}

@InputType
class child extends Partial(Parent) {
constructor(){super()}

@Field()
fieldB: string
}

@ChrisLahaye can you please look into this

my versions
"type-graphql": "^2.0.0-beta.2",
"type-graphql-utils": "^2.1.0",
"graphql": "^16.6.0",

@ChrisLahaye
Copy link
Owner

@techanyonymous Could you please share your error and code sample properly formatted with correct syntax?

I will soon be out of office so it might take a while for me to be able to look into it.

@techanyonymous
Copy link
Author

techanyonymous commented Sep 14, 2023

@InputType()
export class ParentClass {

    @Field()
    id: string
}

@InputType()
export class ChildClass extends Partial(ParentClass) {
    constructor() {
        super()
    }

    @Field()
    childId: string
}

I get this error for the above code unhandledRejection TypeError: Class constructor ChildClass cannot be invoked without 'new'

If I change the InputType() to ObjectType() or ArgsType() it works. Please check and verify

@techanyonymous
Copy link
Author

@ChrisLahaye , any updates?

@FezVrasta
Copy link

For what is worth I just tested it and it's working properly on my end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants