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): Implement stricter variable typings on generic #2607

Merged
merged 9 commits into from
Aug 15, 2022

Conversation

kitten
Copy link
Member

@kitten kitten commented Aug 14, 2022

Resolve #2606

Summary

This attempts to introduce a stricter type for variables preventing it from being an optional property or argument (i.e. variables?: Variables) in all parts of the codebase. To do this, we also need to make its type a little more strict with AnyVariables, which explicitly defaults the generic to a type of void | undefined | { ... }. In case of a generic that's passed in, this also becomes the extension type.

This is currently a draft because some methods on Client and some utility functions, like createRequest, are affected by this change. We have to check that these behave as expected (as per the change and RFC) and that we don't break them if that isn't necessary

Set of changes

  • Add AnyVariables and make generics Variables extends AnyVariables = AnyVariables
  • Update core typings where variables were optional
  • Update all typings across bindings (wherever variables?: was used, a special type must be implemented)

@changeset-bot
Copy link

changeset-bot bot commented Aug 14, 2022

🦋 Changeset detected

Latest commit: 9aca906

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@urql/exchange-graphcache Major
@urql/core Major
@urql/preact Major
urql Major
@urql/svelte Major
@urql/vue Major
next-urql Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kitten kitten marked this pull request as ready for review August 14, 2022 19:32
Copy link
Collaborator

@JoviDeCroock JoviDeCroock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These come from #2608

packages/vue-urql/src/useQuery.ts Outdated Show resolved Hide resolved
packages/vue-urql/src/useQuery.ts Outdated Show resolved Hide resolved
packages/vue-urql/src/useSubscription.ts Outdated Show resolved Hide resolved
packages/vue-urql/src/useSubscription.ts Outdated Show resolved Hide resolved
kitten and others added 4 commits August 15, 2022 14:13
Co-authored-by: Jovi De Croock <decroockjovi@gmail.com>
Co-authored-by: Jovi De Croock <decroockjovi@gmail.com>
@crmitchelmore
Copy link

@kitten is the expected pattern to pass empty variables for cases when there are no variables?

e.g. client.query(SomeDocument)

becomes:

client.query(SomeDocument, {})

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.

RFC: Fix for useQuery variables being optional
3 participants