Open lorenries opened 4 years ago
Ah, yeah, it bundles properly in Next.js (which is smart enough to strip out conditionals in if typeof window === undefined
from client bundles, but not in webpack or parcel.
Would you be open to using something like hash.js, which will work on the client and the server? That's what apollo-link-persisted-queries uses. Or alternatively isomorphic-webcrypto.
@Daniel15 Hiya 👋 we actually found some time to implement persisted queries in our main repo. The reason it’s been built from scratch is to test out more reuse of our core fetching logic (since it always ends up being very similar) including some newer debugging events for our new upcoming devtools timeline.
It should be IE11 ready and the SHA256 shim for Node.js should minors away in web environments, with the proper Webpack config. https://github.com/FormidableLabs/urql/tree/master/exchanges/persisted-fetch/src
Thanks @kitten - Sounds like I should archive this repo then :)
This is a wonderful urql exchange but unfortunately can't create persisted queries in server environments like Next.js because it relies on the web crypto api.
This PR checks if
typeof window === "undefined"
, and if it is, hashes queries with node's crypto module.