graphql-code-generator icon indicating copy to clipboard operation
graphql-code-generator copied to clipboard

Add options to minify document (query) when using documentMode String.

Open nicksrandall opened this issue 3 years ago • 2 comments

Is your feature request related to a problem? Please describe. graphql has a utility function stripIgnoredCharacters that will effectively minify any string document. This could help with code size when strings representing queries are embedded in the source.

Describe the solution you'd like I would like a config option that will run stripIgnoredCharacters right after print on documents.

Describe alternatives you've considered None

Additional context Thanks for this awesome suite of tools!

nicksrandall avatar Feb 24 '22 05:02 nicksrandall

This would also be useful for the @graphql-codegen/schema-ast plugin. Some runtime environments such as Cloudflare Workers are limited to a code size of 1mb so every byte counts.

patdx avatar Sep 09 '22 06:09 patdx

We are running into issues with this also. For now, since we are using Apollo client, I was able to use this method. https://www.apollographql.com/docs/react/networking/advanced-http-networking/#overriding-the-default-print-function

It would be nicer/faster though if we could have the generated already have the stripped version.

flippidippi avatar Apr 24 '24 16:04 flippidippi