-
-
Notifications
You must be signed in to change notification settings - Fork 675
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
Automatic Field Resolver (High Order Field Resolvers) #385
Comments
I think that this will be covered by #44
It uses TypeORM entities metadata to create resolvers for joining relations. |
I've been looking that issue. So the plan is resolving field automatically developing a typeorm helper plugin using a dataloader so queries are much less and optimized? Correct me if I'm wrong please.
Yes, it's very nice. I was using Vesper before, but I changed to use TypeORM + TypeGraphQL because of that double decorator entity definition and auto schema generation that I fell in love with. Great job by the way! However, I miss automatic resolver functionality. I hope that comes soon! What about being able to create high order dynamic field resolver? I suggest adding a @field handler option so that handler can create dynamically it correspondent resolver and many others. Let me explain the idea, entity will look like this:
And this would be the high order resolvers that would create their resolvers:
Again, I don't know even if this or similar is possible. |
This should work: @Resolver(of => Post)
export class PostResolver extends createBaseResolver(Post) {} For multiple relations, you would need something like this: @Resolver(of => Post)
export class PostResolver
extends relationResolver(Post, "field1",
relationResolver(Post, "field2",
relationResolver(Post, "field3", class {})
)
) {} You would need to use the mixins pattern #359. |
Closing for a housekeeping purposes 🔒 |
I've been noticing that many field resolvers derivated from relations use to be simple. Simple enough to be able to resolve them using a simple query with TypeORM query builder. It automatically creates the query based on the relation decorators of fields of entity objects.
This is an example:
What I'm trying to say is: I think we should be able to resolve relation fields automatically using TypeORM query builder so that we don't have to code a lot of simple field resolvers. I think Vesper has this feature.
At least I think it would be amazing if we could somehow create high order field resolver dynamically, so we can create base resolvers that creates all field resolvers depending on the entity.
Maybe something like this:
The problem is that this only works for two fields, and I don't find any way to programmatically create a field resolver function for each relation field depending on the class type. Is it possible?
I'm new to TypeGraphQL, so please be patient. And sorry for my bad english.
The text was updated successfully, but these errors were encountered: