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

How to "mixin" InputType/ObjectType classes? #359

Closed
chengjia0807 opened this issue Jun 12, 2019 · 5 comments
Closed

How to "mixin" InputType/ObjectType classes? #359

chengjia0807 opened this issue Jun 12, 2019 · 5 comments
Assignees
Labels
Community 👨‍👧 Something initiated by a community Documentation 📖 Issues about docs Question ❔ Not future request, proposal or bug issue Solved ✔️ The issue has been solved

Comments

@chengjia0807
Copy link

As I know a Javascript class can only extend one another class, and typescript mixin method can mix mulitple classes into one.

I tried to mixin multiple object classes by using mixin but it does not work. However "extends" is working perfectly.

Just want to know that does TypeGraphql support mixin classes on objects?

Thanks
CJ

@georgyfarniev
Copy link

@chengjia0807 can you provide your code sample where your mixing your objects? Code of mixin function you use? What is the final purpose of mixing Input and Output type?

@MichalLytek MichalLytek added the Question ❔ Not future request, proposal or bug issue label Jun 17, 2019
@MichalLytek
Copy link
Owner

@chengjia0807
You can try to use ES class mixins:
https://mariusschulz.com/blog/typescript-2-2-mixin-classes

@MichalLytek
Copy link
Owner

I think I should add an example about this pattern.

In the future I might publish a fork of mix with with TS support.

@MichalLytek MichalLytek added Community 👨‍👧 Something initiated by a community Documentation 📖 Issues about docs labels Jun 23, 2019
@chengjia0807
Copy link
Author

I think I should add an example about this pattern.

In the future I might publish a fork of mix with with TS support.

that would be very helpful! Thank dude. By the way, I love this library

@MichalLytek
Copy link
Owner

MichalLytek commented Sep 21, 2019

Closing via 9af3077 🔒

You can see the example of using mixin classes and inheritance to reduce duplication between input types, and object types too 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community 👨‍👧 Something initiated by a community Documentation 📖 Issues about docs Question ❔ Not future request, proposal or bug issue Solved ✔️ The issue has been solved
Projects
None yet
Development

No branches or pull requests

3 participants