dotansimha / graphql-code-generator

A tool for generating code based on a GraphQL schema and GraphQL operations (query/mutation/subscription), with flexible support for custom plugins.
https://the-guild.dev/graphql/codegen/
MIT License
10.78k stars 1.32k forks source link

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

Open nicksrandall opened 2 years ago

nicksrandall commented 2 years ago

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!

patdx commented 2 years ago

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.

flippidippi commented 4 months ago

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.