eddeee888 / graphql-code-generator-plugins

List of GraphQL Code Generator plugins that complements the official plugins.
MIT License
51 stars 12 forks source link

[BUG] Performance issue when using mappers #282

Open eddeee888 opened 4 months ago

eddeee888 commented 4 months ago

Describe the bug

There seems to be a performance issue when activating mappers. Could be related to static analysis

To Reproduce

Source: https://github.com/eddeee888/graphql-code-generator-plugins/issues/275#issuecomment-2125386883

One thing I will note here is in regard to the time codegen took to run after adding the mapper. Before the mapper, it took around 6s. With the mapper, it takes 14-15s, over double what it took previously. And that does worry me a bit for adding additional mappers.

Versions

eddeee888 commented 1 month ago

Potentially fixed by https://github.com/eddeee888/graphql-code-generator-plugins/pull/326

Alpha version:

yarn add -DE @eddeee888/typescript-resolver-files@pr326-run597-1
markbussard commented 1 month ago

Hi @eddeee888

I tested this alpha version today and noticed a significant improvement in generation time. For context, we currently have around 250 resolver files, using resolverGeneration: 'minimal'.

Before this update:

Generation time with no mappers: ~6.5s With 1 mapper: ~11.2s With 2 mappers: ~12.5s - 13.6s With 3 mappers: ~12.8s - 13.8s

After this update:

Generation time with no mappers: ~2.2s With 1 mapper: ~7.5s - 8s With 2 mappers: ~8.5s With 3 mappers: ~8.5s - 9s

I ran codegen multiple times for each scenario, and while the times varied slightly, these ranges are representative of what I observed. Although adding mappers still increases the generation time by a factor of two or more, the overall time now is only slightly higher than our initial no-mapper generation time before the update, which is a significant improvement.

eddeee888 commented 1 month ago

Thanks for trying and confirming @markbussard ! This is one of the quick fixes, I'll continue to try different things to make perf better in future releases 🙏