fix(core/bindings): Fix conditional/optional variables type based on TypedDocumentNode generic #3022
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #2668
Summary
Previously, we had a couple of cases that wouldn't allow us to correctly identify when the
variables
input should be optional, e.g. allowing for:Additionally, it wasn't always easily possible to proxy generic inputs to our hooks and bindings, e.g. allowing for:
This is now resolved and to prevent future mistakes a
GraphQLRequestParams
utility type has been exposed by@urql/core
which will be maintained/exposed as a public type, but is also reused in all of our bindings.NOTE on patch: This is a patch and not a major/breaking change since we can never break types by making a property optional rather than required. Since we're a) widening the type with the union, and b) fixing cases where
variables
should be optional, this shouldn't break any TS types.Set of changes
GraphQLRequestParams
utility fixing optionalvariables
GraphQLRequestParams
wherequery, variables
inputs are accepted