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

Generated code size on 1.0 exponentially large than 0.51.2 #2740

Closed
tahirmt opened this issue Dec 17, 2022 · 3 comments
Closed

Generated code size on 1.0 exponentially large than 0.51.2 #2740

tahirmt opened this issue Dec 17, 2022 · 3 comments
Labels
bug Generally incorrect behavior needs investigation

Comments

@tahirmt
Copy link
Contributor

tahirmt commented Dec 17, 2022

Summary

Hi for versions 0.5x we have been using the mergeInFieldsFromFragmentSpreads option turned off because the code size was too large using it however with 1.0 that option is no longer optional which is a good thing in terms of ease of use however our code generated files have gone from 68k lines to 364K lines with 1.0.5.

This might not have been an issue however the compiled framework with just the generated code size has gone from 18MB to an over 500MB making it impossible for us to get this update to production.

The compilation time for just the generated swift files has gone from 8s to ~170s.

Is there anything we can do to improve this? We would like to be on the major release but these things are preventing us from adopting the first major release.

Version

1.0.5

Steps to reproduce the behavior

It's hard for me to share the actual schema because it's proprietary but I will provide some additional information... We have a lot of fragments (162). We heavily use directives to include/skip fields/fragments. We have tons of fragments that have other fragments inside it. e.g

fragment GenericFragment on GenericType {
   commonField
   ... FirstSpecificFragment
   ... SecondSpecificFragment
   ... ThirdSpecificFragment
}

fragment FirstSpecificFragment on OtherType {
   ... OneKindOfFragment
   ... OtherKindOfFragment
}

There are 26 mutations, 48 queries and 20 subscriptions that utilize some parts of these fragments or use inline fragments.

Logs

No response

Anything else?

No response

@tahirmt tahirmt added bug Generally incorrect behavior needs investigation labels Dec 17, 2022
@tahirmt tahirmt changed the title Generated code size exponentially large than 0.51.2 Generated code size on 1.0 exponentially large than 0.51.2 Dec 17, 2022
@pm-dev
Copy link

pm-dev commented Dec 17, 2022

@tahirmt This looks like a dupe of #2560

@tahirmt
Copy link
Contributor Author

tahirmt commented Dec 17, 2022

It can be considered as a duplicate but ideally it would be nice if there was a way to reduce the generated code size without losing the benefits. For example not generating the same type under the namespace of every single operation it's used. Not sure how possible that is.

Edit: looks like this solution is already discussed there.

@calvincestari
Copy link
Member

@pm-dev is correct, this issue is the same as #2560.

Currently there is no way to prevent the code explosion you're experiencing; it's directly related to nested fragments. The solution is to implement the same mergeInFieldsFromFragmentSpreads option in the 1.0 code generation engine.

@tahirmt tahirmt closed this as completed Dec 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Generally incorrect behavior needs investigation
Projects
None yet
Development

No branches or pull requests

3 participants