Skip to content

Commit

Permalink
fix(core): Fix legacy GCG generated Variables types (#3029)
Browse files Browse the repository at this point in the history
kitten authored Mar 10, 2023
1 parent 45d88fd commit 3de3cef
Showing 2 changed files with 20 additions and 2 deletions.
12 changes: 12 additions & 0 deletions .changeset/dry-islands-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@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 }>;
```
10 changes: 8 additions & 2 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
@@ -264,9 +264,15 @@ export type GraphQLRequestParams<
: Variables extends {
[P in keyof Variables]: Exclude<Variables[P], null | void>;
}
? {
variables: Variables;
? Variables extends {
[P in keyof Variables]: never;
}
? {
variables?: Variables;
}
: {
variables: Variables;
}
: {
variables?: Variables;
}))

0 comments on commit 3de3cef

Please sign in to comment.