Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compatibility for Wonka compiled with ReScript >= 8 #1214

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/preact-urql/src/hooks/useQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,14 @@ function toSuspenseSource<T>(source: Source<T>): Source<T> {
// If we haven't got a previous result then start suspending
// otherwise issue the last known result immediately
if (cache !== undefined) {
const signal = [cache] as [T] & { tag: 1 };
const signal = [cache] as [T] & { tag: 1, TAG: 1, _0: T };
signal.tag = 1;
// ReScript has new variant encoding from version 8 onwards.
// Mirror the variant encoding above to a compatbile version
// so urql works with Wonka no matter with which version of
// ReScript it was compiled.
signal.TAG = signal.tag;
signal._0 = signal[0];
sink(signal);
} else {
hasSuspended = true;
Expand Down
8 changes: 7 additions & 1 deletion packages/react-urql/src/hooks/useQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,14 @@ function toSuspenseSource<T>(source: Source<T>): Source<T> {
// If we haven't got a previous result then start suspending
// otherwise issue the last known result immediately
if (cache !== undefined) {
const signal = [cache] as [T] & { tag: 1 };
const signal = [cache] as [T] & { tag: 1, TAG: 1, _0: T };
signal.tag = 1;
// ReScript has new variant encoding from version 8 onwards.
// Mirror the variant encoding above to a compatbile version
// so urql works with Wonka no matter with which version of
// ReScript it was compiled.
signal.TAG = signal.tag;
signal._0 = signal[0];
sink(signal);
} else {
hasSuspended = true;
Expand Down