(persisted-fetch) - Don't send persisted queries if the hash operation fails#934
Merged
kitten merged 5 commits intourql-graphql:mainfrom Aug 7, 2020
Merged
(persisted-fetch) - Don't send persisted queries if the hash operation fails#934kitten merged 5 commits intourql-graphql:mainfrom
kitten merged 5 commits intourql-graphql:mainfrom
Conversation
🦋 Changeset is good to goLatest commit: a4e2bbc We got this. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
JoviDeCroock
approved these changes
Aug 7, 2020
kitten
reviewed
Aug 7, 2020
| operation, | ||
| body, | ||
| dispatchDebug, | ||
| false |
Member
There was a problem hiding this comment.
We could move up the if-block and let this condition be !!((options as PersistedFetchExchangeOptions) .preferGetForPersistedQueries && sha256Hash) 🤔 may not be worth it though
Contributor
Author
There was a problem hiding this comment.
Good idea, that's definitely cleaner!
Member
|
This has now been released 🙌 Sorry for the delay and thanks for the contribution! ❤️ https://github.com/FormidableLabs/urql/releases/tag/%40urql%2Fexchange-persisted-fetch%401.2.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In insecure browser environments, the
window.crypto.subtleapi isn't available. The default hashing function in the persisted query exchange will resolve an empty string in this case, and send that empty string as the persisted query, which leads to aPersistedQueryNotFoundexception. This is fine, because the exchange will follow up with non-persisted query, but we can improve the default behavior by not sending a persisted query at all if the hash fails.Set of changes
Updates the persisted query exchange to only send a persisted query if there's a non-falsey hash value. Let me know if there's a better way of implementing this with Wonka!