kamilkisiela / apollo-angular

A fully-featured, production ready caching GraphQL client for Angular and every GraphQL server 🎁
https://apollo-angular.com
MIT License
1.5k stars 311 forks source link

feat: strip unncessary characters from the query #1630

Closed damienwebdev closed 3 years ago

damienwebdev commented 3 years ago

See: https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers

This came up in https://github.com/graycoreio/daffodil when trying to send GraphQl queries as GET (for caching reasons with the GraphQL API of the ecommerce system Magento 2).

The deeper a query became, the more %20 characters were added to the URL, which eventually overflowed Chrome's (and various other browser's) max URL length.

This strips the useless characters out, reduces bandwidth consumption, and saves us all from some painful edge-cases.

Checklist:

damienwebdev commented 3 years ago

This also has a performance penalty associated with it -- https://bugs.chromium.org/p/chromium/issues/detail?id=1182806

kamilkisiela commented 3 years ago

It's a breaking change. The stripIgnoredCharacters was introduced in graphql@14.3.0. I will create a PR that will let you intercept the query printing logic so you could use stripIgnoredCharacters + print instead of just print.

kamilkisiela commented 3 years ago

v2.4.0

kamilkisiela commented 3 years ago

We will use your PR and make it the default in next major version!