-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
useQuery typings fails to require required variables from TypedDocumentNode, causing runtime error #10857
Comments
Hey @irond13 that is a great catch! We will see if we can take a look at this. I can't guarantee on timeline on this fix at the moment, but if you have a fix in mind, feel free to submit a PR and we will take a look! |
Please also correct the typing on useQuery(
someTypedQueryDocument,
{} // type checker doesn't detect missing variables property
) |
I have the same problem. How do I fix it? |
This requires a bunch of bigger changes (as it would apply to all hooks). |
Forgive me if I am mistaken, is this the same thing I am experiencing with my generated types through graphql-codegen and @apollo/client which worked fine until a round of dependency updates?
|
@tannerbaum no, that's a different issue. I'd be grateful if you could open a new issue and provide a small reproduction that shows the issue so we can investigate it. |
Do you have any update on this issue?
|
@jigar-riyalto it's an unrelated issue - could you please open a new issue and also show the code that is causing this type error? |
Issue Description
Hi!
The current typings for
useQuery
are as follows:Note that
options
is always optional. This means it is possible to pass aTypedDocumentNode
which defines non-optional variables touseQuery
without actually passing any of the required variables.This will result in runtime error, thrown by the GraphQL evaluator, which would expect said variables.
Link to Reproduction
https://codesandbox.io/p/sandbox/dazzling-borg-o6fr3u?welcome=true
Reproduction Steps
See file
useQueryTest.tsx
in the linked sandbox. The expectation is that the uncommenteduseQuery
should fail to compile, which it doesn't.The text was updated successfully, but these errors were encountered: