-
-
Notifications
You must be signed in to change notification settings - Fork 677
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
Using only typedefs, not resolvers #339
Comments
TypeGraphQL is all focused on resolvers and runtime improvements. Using it only for object and input typedefs is like driving your car without shifting the gears. You can use simple code generator that will read your interfaces/classes and produce the typedefs SDL or maybe even try the reflection PoC: |
Thanks for the quick response. https://github.com/19majkel94/typegraphql-reflection-poc looks like an interesting start. |
I wrote a small package to fill this need: |
I am reviving this feature as it might be handy to provide a step-by-step migration path and make use of the enhanced reflection plugin 💪 |
@BramKaashoek this seems nice, but it'd be great to handle @19majkel94 this feature seems vital, there are plenty of scenarios which requires to work on typeDefs first without considering resolvers.. Is this complex to implement ? |
You're completely right, I'll add that. Edit: Added in version 0.1.9 https://www.npmjs.com/package/typescript-typedefs |
Yes, it's a requirement of I would have to rewrite the core to just do decorators/reflection -> metadata -> schema string magic - will do in some time in the future with a more modular codebase 😉 |
@BramKaashoek all things considered, this'd be perfect with circular references out of the box ! The workaround is really not convenient... Any idea on how to work around this ? I'm not aware of the root cause: could you please ellaborate ? Would a PR in reflect-metadata help ? Have you considered using an alternative (for example, this one is much lighter on paper)? |
@syffs After doing some more looking around I found forward-ref as used by Angular, this might be a workaround. I'll look into it. |
@BramKaashoek this might help, there's a suggestion on the related issue on typescript repo |
@BramKaashoek good job, it's much more convenient with forwrad-ref !
A suggestion about Interface and inheritence, this might make sense to automatically cascade fields from extended types / interfaces, or you end up with redundant @Interface()
class Book {
@Field()
author: string;
}
// option 1 for implementing
@Type()
class CourseBook extends Book {
@Field()
author: string;
@Field()
course: string;
} what do you think ? |
This is what I was initially hoping to do, but sadly this is not possible due to how decorators work. Let's take further discussion over to https://github.com/BramKaashoek/typescript-typedefs so that we don't bother Majkel as much :). |
I would like to use only the typeDef generating capabilities of this library without using the resolvers, since I prefer the apollo-style resolvers. #222 makes me think it should be possible, but I could not find the way to do it in the documentation. Could you point me to which function to use?
As far as I can see, the
buildTypeDefsAndResolvers
function as described in #233 still requires me to write (minimal) resolvers?Is there a function such as
buildTypeDefs
where I could pass in an array of my ObjectType/InputType classes to generate typeDefs?The text was updated successfully, but these errors were encountered: