graphql-zeus
graphql-zeus copied to clipboard
Reducing Bundle Size
I was testing out the library with a small schema and realized that around 80% of the generated file is the configuration object that holds info on the schema for building the query.
My main issue is that this object really cannot be minimized by build tools, and can grow a lot with bigger schemas.
With that said, I am not familiar with the codebase so I don't know what is possible, but I'll throw in some ideas and see what sticks:
- Make this configuration object tree-shakable (by query/mutation for example)
- This would allow to import only the parts of the schema that you are using to send to the browser
- Remove
false
properties (ie.{ array: false }
) this could reduce the object size around 30% - Create a macro/plugin (for babel or webpack for example) to replace the queries at build time, that way the benefits of the type-safe, and very intuitive client remain and in production there is no need to even ship the query builder code.
Either way, keep doing what you're doing! Thanks for the great tool!
What's the status of this? I'm in the process of adding this to my project but I noticed that my PR currently 5x'ed the number of lines of code. That's fine, but I'd be sad if our page speed would start to suffering as a result of using this.
@aexol - any plans on prioritization for this at all? I think that making the generated schema be on the root level and tree-shakable as @jvcmanke mentioned will solve this issue with proper build tools
Hope a solution can be found for this! Thanks :)