Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.

fix(core): Fix legacy GCG generated Variables types (#3029)

Changed files
+20 -2
.changeset
packages
core
src
+12
.changeset/dry-islands-double.md
···
···
+
---
+
'@urql/core': patch
+
---
+
+
Fix generated empty `Variables` type as passed to generics, that outputs a type of `{ [var: string]: never; }`.
+
A legacy/unsupported version of `typescript-urql`, which wraps `urql`'s React hooks, generates
+
empty variables types as the following code snippet, which is not detected:
+
+
```ts
+
type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
+
type Variables = Exact<{ [key: string]: never }>;
+
```
+8 -2
packages/core/src/types.ts
···
: Variables extends {
[P in keyof Variables]: Exclude<Variables[P], null | void>;
}
-
? {
-
variables: Variables;
}
: {
variables?: Variables;
}))
···
: Variables extends {
[P in keyof Variables]: Exclude<Variables[P], null | void>;
}
+
? Variables extends {
+
[P in keyof Variables]: never;
}
+
? {
+
variables?: Variables;
+
}
+
: {
+
variables: Variables;
+
}
: {
variables?: Variables;
}))