dotansimha / dotansimha/graphql-code-generator-community

typescript-urql: urql 4 strict generics for passing variables in subscription

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

Description

### Which packages are impacted by your issue?

@graphql-codegen/typescript-urql

### Describe the bug

Recent Urql major version update now have more strict type requirements for passing variable into subscription.
Now it forces variables property to be required in passing object if any variable is not optional, and that breaks code generated by typescript-urql:

```
export function useSubscription(options: Omit, 'query'> = {}, handler?: Urql.SubscriptionHandler) {
return Urql.useSubscription({ query: SubscribeDocument, ...options }, handler);
};

// Property 'variables' is missing in type '{}' but required in type 'Omit, any>, "query">'.
```

### Your Example Website or App

https://the-guild.dev/graphql/codegen

### Steps to Reproduce the Bug or Issue

```
type SomeDataPoint {
id: String!
}

type Subscription {
onUpdate(someVariable: Int!): SomeDataPoint!
}
```

```
subscription SubscribeOnUpdate($someVariable: Int!) {
onUpdate(someVariable: $someVariable) {
id
}
}
```

With plugin
`typescript-urql`

### Expected behavior

```
export function useSubscription(options: Omit, 'query'>, handler?: Urql.SubscriptionHandler) {
return Urql.useSubscription({ query: SubscribeDocument, ...options }, handler);
};
```

### Screenshots or Videos

_No response_

### Platform

- OS: Linux
- NodeJS: 16.14.2, 18.14.0
- `graphql` version: 16.6.0
- "@graphql-codegen/add": "4.0.1"
- "@graphql-codegen/cli": "3.3.1"
- "@graphql-codegen/typescript": "3.0.4"
- "@graphql-codegen/typescript-operations": "3.0.0"
- "@graphql-codegen/typescript-react-apollo": "3.3.7"
- "@graphql-codegen/typescript-urql": "3.7.3"
- "@graphql-codegen/plugin-helpers": "4.2.0"
- "@graphql-codegen/typescript-resolvers": "3.2.1"
- "@graphql-codegen/urql-introspection": "2.2.1"

### Codegen Config File

_No response_

### Additional context

The problem is related to this issue
https://github.com/dotansimha/graphql-code-generator-community/issues/328

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.