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

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

Merged
merged 1 commit into from
Mar 10, 2023

Conversation

kitten
Copy link
Member

@kitten kitten commented Mar 10, 2023

Resolves #3026

Summary

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:

type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
type Variables = Exact<{ [key: string]: never }>;

NOTE: We cannot guarantee that this actually fixes @graphql-codegen/typescript-urql, which will going forward be unsupported. Generally, we choose not to create test harnesses for outside type generators like these, until we'd have our own type/code generator.

We cannot guarantee that types of hook/wrapper generators don't break, and instead recommend and support type/code generators that output TypedDocumentNodes, such as:

  • @graphql-codegen/typed-document-node
  • @graphql-codegen/client-preset

Set of changes

  • Add { [prop: string]: never } check to variables types

@kitten kitten merged commit 3de3cef into main Mar 10, 2023
@kitten kitten deleted the fix/legacy-gcg-generated-types branch March 10, 2023 13:45
@github-actions github-actions bot mentioned this pull request Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

urql@3.0.4 does not work with GCG typescript-urql plugin
2 participants