Add compatibility for Wonka compiled with ReScript >= 8 #1214
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
It took a bit of investigating but it turns out that when Wonka is compiled with ReScript >= 8 it's variant representation changes. Urql has one location where it manually encodes a variant in
userQuery
, thus this cause problems when Urql expects Wonka to be compiled with ReScript < 8, but that's not the case.The full investigation story can be found in teamwalnut/rescript-urql#232
I searched for the usage of
.tag
in the codebase to find where this manual encoding was performed and only found this inreact-urql
andpreact-urql
.A better change than my fix would be to let Wonka encode the variant (perhaps we can expose a function?) so that it automatically uses whatever encoding ReScript decided. This more properly decouples Urql from ReScript's internal decisions and avoids breakage in the future if they decide to further change this representation.
Set of changes
Urql's useQuery for React and Preact now encodes it's cache results in a manner compatible with ReScript >= 8 as well as ReScript < 8 to ensure that Urql doesn't break when Wonka has been compiled with newer ReScript versions.