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

Performance issue since version 7 compare to TypeGraphQL #1596

Closed
EdouardBougon opened this issue Jun 23, 2021 · 1 comment
Closed

Performance issue since version 7 compare to TypeGraphQL #1596

EdouardBougon opened this issue Jun 23, 2021 · 1 comment

Comments

@EdouardBougon
Copy link
Contributor

EdouardBougon commented Jun 23, 2021

I'm submitting a...

[ ] Regression
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

For my current project I'm using the version 7.
I'm not using any feature like: Guard, pipe, fieldMiddleware or FieldResolverEnhancers.
It's a big GraphQL API, with heavy payload.

Before NestJS, I was using TypeGraphQL.

Since we migrated to NestJS, we are facing performance issue, the query average duration increase of ~100ms.

I did a profiling, and we can see that the main "thread" is blocked by moment around 1,5sec. (See screenshots).
And we can see lot of call related to nestJS.

Screenshot 2021-06-21 at 16 04 58

Screenshot 2021-06-21 at 16 05 12

In a previous project, I've used NestJs version 6, where it use typeGraphQL for the graphQL part, and I didn't have this kind of issue.
But since the NestJS 7, the graphQL part was entirely rewrite in NestJS, and don't use anymore typeGraphQL.

So, that why, I decided to use the official TypeGraphQL module for nestJS: https://github.com/MichalLytek/typegraphql-nestjs

And now, with quite the exact same code (except the decorator import), I don't have performance issue anymore, and my CPU usage has been devided by 2.

May be we could add a simpleResolvers option to ObjectType like with typeGraphQL: (See: MichalLytek/type-graphql#488).

I can provide an example of a ProcFile if needed.

Minimal reproduction of the problem with instructions

Query with resolver with big array of other resolver with lot of field.

What is the motivation / use case for changing the behavior?

Improve performance for big payload

Environment


   lts/fermium
   "@nestjs/common": "^7.6.16",
    "@nestjs/core": "^7.6.16",
    "@nestjs/graphql": "^7.10.6",
    "@nestjs/platform-express": "^7.6.16",
@kamilmysliwiec
Copy link
Member

Based on the screenshots you shared, it seems that you're using request-scoped resolvers and this is something that, inappropriately used, may be causing perf issues.

We can't really help you without the minimum reproduction repository. Can you please share one?

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

No branches or pull requests

2 participants