urql-graphql / urql

The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
https://urql.dev/goto/docs
MIT License
8.65k stars 454 forks source link

fix(persisted): persisted queries can use GETs within URL limits #3192

Closed NWRichmond closed 1 year ago

NWRichmond commented 1 year ago

Summary

This PR aims to resolve https://github.com/urql-graphql/urql/issues/3185.

Currently, @urql/exchange-persisted's options.preferGetForPersistedQueries doesn't allow for persistedOperation.context.preferGetMethod to be set to true or 'within-url-limit', and instead sets persistedOperation.context.preferGetMethod to 'force' when options.preferGetForPersistedQueries is true. This leads to broken GET requests when queries become massive.

Another issue was that although the TSDocs suggest that the default value of options.preferGetForPersistedQueries is true, this wasn't reflected in the logic.

Set of changes

In @urql/exchange-persisted: