graphql-code-generator-community icon indicating copy to clipboard operation
graphql-code-generator-community copied to clipboard

[typescript-urql] Hook option variables are always optional

Open edkimmel opened this issue 2 years ago • 2 comments

Describe the bug

This is a follow up to https://github.com/dotansimha/graphql-code-generator/issues/7163 The resolution of issue 7163 (release 3.5.0) made the options parameter required when variables are required, but the variables field of that object is still optional, even when the query has required variables.

To Reproduce Write any query with a required variable. When using the hook for that query, you are able to omit the variables field.

query MySubscription($userId: String!) {
  ...
}
useMySubscriptionQuery() // Now fails in 3.5.0
useMySubscriptionQuery({}) // Compiles, but is still incorrect
useMySubscriptionQuery({variables: {userId: "123"}}) // The correct requirement

Expected behavior For queries with required variables, I would expect useMySubscriptionQuery({}) to fail to compile, as variables have not been provided.

edkimmel avatar Apr 14 '22 14:04 edkimmel