dotansimha / dotansimha/graphql-code-generator
Subscription resolver args are of type any
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 23
Description
**Describe the bug**
It seems to me like arguments for subscription resolvers are all of type `any`. I got this after running the code generator with the Typescript Resolvers plugin:
```ts
export type SubscriptionResolver =
| ((...args: any[]) => SubscriptionObject)
| SubscriptionObject;
```
What is the reason for `...args: any[]`?
**To Reproduce**
Steps to reproduce the behavior:
Run the code generator with the typescript resolvers plugin on a schema with subscriptions. I think this should result in the same issue.
Reproduction Repo: https://codesandbox.io/s/magical-pare-hl1sv?file=/schema.graphql
**Check line 88 in types.ts.**
1. My GraphQL schema:
```graphql
type Query {
user(id: ID!): User!
}
type User {
id: ID!
username: String!
email: String!
}
type Subscription {
userUpdated(id: ID!): User
}
```
2. My GraphQL operations:
```graphql
# None
```
3. My `codegen.yml` config file:
```yml
schema: schema.graphql
documents: document.graphql
generates:
types.ts:
plugins:
- typescript
- typescript-resolvers
```
**Expected behavior**
I would expect subscription resolvers to have typed arguments which should be exactly the same as the arguments for query and mutation resolvers.
**Environment:**
See reproduction repo, or check these version numbers:
```
"dependencies": {
"@graphql-codegen/add": "2.0.2",
"@graphql-codegen/cli": "1.20.1",
"@graphql-codegen/typescript": "1.21.0",
"@graphql-codegen/typescript-operations": "1.17.14",
"@graphql-codegen/typescript-resolvers": "^2.0.0",
"graphql": "15.5.0"
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.