-
-
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
FieldResolver is too slow #487
Comments
The problem here is not about promises - it's a really small overhead that's hard to measure. The real cause is that field resolvers are a normal resolvers - they have injected transformed args and other params, you can have custom decorators, etc. So they are not generated as
@FieldResolver()
a(@Root() source) {
return source.a;
} It is better to use a getter that is called just like the simple resolver: @Field({ name: "a" })
get getA() {
return this.a;
} |
It is a good idea to use getter instead of FieldResolver. Anyway, getParams for '@root' may be the cause of the performance issue. I tried to optimize by myself, and make a PR #488. Please check it. |
From code readability and performance perspective, I don't like to mix the sync and async stuff just for some percent of use cases that use field resolver for simple sync access. I think that all we can think of now is to add a |
I would love to do |
@benawad |
@MichalLytek I still like writing the resolvers in the TypeGraphQL style, I'd just like to have a raw option if I don't need to use middleware/validation/etc |
For now we will just merge #488 - further optimization will be applied on |
@MichalLytek Awesome, I'm looking forward to that! Are you open to |
With #488 if you don't use middlewares nor auth checker, there's no performance penalty - see the PR and the |
Is your feature request related to a problem? Please describe.
This is an advanced topic of #254
If you use FieldResolver, execution needs more time.
Describe the solution you'd like
I didn't think whether some option likes simple is a solution or not.
But in the end, some optimization technique applied in graphql-js may be needed, I think.
For example,
(from https://github.com/graphql/graphql-js/blob/master/src/execution/execute.js)
In graphql-js, those two declarations become difference result.
The text was updated successfully, but these errors were encountered: