dotansimha / dotansimha/graphql-code-generator-community

[typescript-urql] Hook option variables are always optional

Open
#184 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
137
Forks
195
Avg merge
6h 20m
Merged PRs (30d)
16

Description

**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.

```graphql
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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.